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 |
---|---|---|---|---|---|---|
POST /posts POST /posts.xml | def create
@post = Post.new(params[:post])
@post.user_id = session[:user_id]
respond_to do |format|
if @post.save
flash[:notice] = 'Post was successfully created.'
if params[:images]
counter = 0
for image in params[:images]["file_data"]
if image != ""
@image = Image.create(:file_data => image, :owner_id => @post.id, :owner_type => 'Post', :filename => image.original_filename,
:body => params[:images]["body"][counter] )
counter = counter + 1
end
end
end
format.html { redirect_to :controller => "posts" }
format.xml { head :created, :location => post_url(:id => @post) }
else
format.html { render :action => "new" }
format.xml { render :xml => @post.errors.to_xml }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def test_should_create_post_via_API_XML\r\n get \"/logout\"\r\n post \"/forum_posts.xml\", :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 end",
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def post(*args)\n request :post, *args\n end",
"def post(*args)\n request(:post, *args)\n end",
"def post #:doc:\n end",
"def post(body)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true if uri.scheme == 'https'\n\n request = Net::HTTP::Post.new(uri)\n request['Content-Type'] = 'text/xml'\n request['Accept-Language'] = locale if locale\n request.body = body\n\n response = http.request(request)\n\n Response.new(response, uri)\n end",
"def post\n resource.post(request, response)\n end",
"def post\r\n end",
"def post(*args)\n Request.post(*args)\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.json { render json: @post, status: :created, location: @post }\n format.xml { render xml: @post, status: :created, location: @post }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n format.xml { render xml: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post\n end",
"def create\n respond_with Post.create(params[:posts])\n end",
"def create\n\t@posts = Post.all\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to(@post, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n flash[:notice] = 'Post was successfully created.'\n format.html { redirect_to(posts_url) }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create(params)\n\nxml =<<XML\n<entry xmlns=\"http://purl.org/atom/ns#\">\n <title>#{params[:title]}</title>\n <link rel=\"related\" type=\"text/html\" href=\"#{params[:url]}\" />\n <summary type=\"text/plain\">#{params[:comment]}</summary>\n</entry>\nXML\n\n post('/post', xml)\n end",
"def post(path, **args); end",
"def POST; end",
"def post\n doc = Nokogiri::XML(request.body)\n id= (doc/'id').text\n # p = Post.exists?(id) ? Post.find(id) : Post.new\n p= Post.find_or_create_by_intranet_id id\n p.update_attributes :subject => (doc/'subject').text,\n :body => (doc/'body').text, :post_type => (doc/'post-type').text,\n :pic => (doc/'pic') .text, :begin_on=>(doc/'begin-on').text,\n :pic_postimg => (doc/'pic-postimg').text,\n :video => (doc/'video').text, \n :end_on => (doc/'end-on').text, :stick => (doc/'stick').text \n render :text => \"ok\"\n end",
"def post; end",
"def create\n @post = Post.new(params[:post])\n\n @post.update_attribute(:user_id, current_user.id)\n\n respond_to do |format|\n if @post.save\n flash[:notice] = 'Post was successfully created.'\n format.html { redirect_to(@post) }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n make_rss\n end",
"def post endpoint, data\n do_request :post, endpoint, data\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to(posts_url, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(*args)\n execute(:post, *args)\n end",
"def posts(opts)\n response = get(\"posts\", opts)\n response\n end",
"def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end",
"def create_posts\n end",
"def create_posts\n end",
"def create\n @user = User.find(session[:user_id])\n @post = @user.posts.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to(\"/#{@post.url}\", :notice => t('controller.created')) }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @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 flash[:notice] = 'Post was successfully created.'\n format.html { redirect_to(@post) }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post251 = Post251.new(params[:post251])\n\n respond_to do |format|\n if @post251.save\n format.html { redirect_to(@post251, :notice => 'Post251 was successfully created.') }\n format.xml { render :xml => @post251, :status => :created, :location => @post251 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post251.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 format.html { redirect_to(@post, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @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 format.html { redirect_to(@post, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(path, options={})\n request :post, path, options\n end",
"def create\r\n @post = Post.new(params[:post])\r\n\r\n respond_to do |format|\r\n if @post.save\r\n format.html { redirect_to(@post, :notice => 'Post was successfully created.') }\r\n format.xml { render :xml => @post, :status => :created, :location => @post }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\r\n @post = Post.new(params[:post])\r\n\r\n respond_to do |format|\r\n if @post.save\r\n format.html { redirect_to(@post, :notice => 'Post was successfully created.') }\r\n format.xml { render :xml => @post, :status => :created, :location => @post }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def post(uri, doc = nil, options = {})\n execute(uri, :post, options, doc)\n end",
"def create_post\n begin\n #asks the user for the title, body, and whether it should be anonymous\n print \"Title: \"\n title = STDIN.gets.chomp\n print \"Body: \"\n body = STDIN.gets.chomp\n print \"Post as Anonymous? (y/n): \"\n anonymous = STDIN.gets.chomp.upcase == 'Y' ? true : false\n # check user information from login\n\n # Rails will reject this unless you configure the cross_forgery_request check to\n # a null_session in the receiving controller. This is because we are not sending\n # an authenticity token. Rails by default will only send the token with forms /users/new and\n # /users/1/edit and REST clients don't get those.\n # We could perhaps arrange to send this on a previous\n # request but we would then have to have an initial call (a kind of login perhaps).\n # This will automatically send as a multi-part request because we are adding a\n # File object.\n response = RestClient.post \"#{@@DOMAIN}/api/posts.json\",\n\n {\n post: {\n title: title,\n body: body,\n anonymous: anonymous\n },\n }, authorization_hash\n\n if (response.code == 201)\n puts \"Created successfully\"\n end\n puts \"URL for new resource: #{response.headers[:location]}\"\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def posts; end",
"def post_query( xml )\n url = URI.parse( self.url )\n response = self.http.post_form( url, { \"query\" => xml } )\n return response.body\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n flash[:notice] = 'Post was successfully created.'\n format.html { redirect_to post_url(@post) }\n# format.xml { head :created, :location => post_url(@post) }\n else\n format.html { render :action => \"new\" }\n# format.xml { render :xml => @post.errors.to_xml }\n end\n end\n end",
"def post\n Rentlinx.client.post(self)\n end",
"def create\n post\n end",
"def test_create_on_post\n post :create,\n :post_id => posts(:by_quentin).id,\n :content => 'This is a test note from aaron...'\n assert_response :redirect\n end",
"def create\n @post = Post.new(params[:post])\n @post.published = true\n\n respond_to do |format|\n if @post.save\n flash[:notice] = 'Запись успешно создана.'\n format.html { redirect_to(@post) }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def posts\n posts = @client.entries(content_type: 'post').items\n posts || []\n end",
"def posts\n @url = MYHOST + \"/api/posts/all\"\n\n\n @respuesta = HTTParty.get(\n @url.to_str\n )\n\n @body = @respuesta.body\n if @body \n redirect_to api_resultado_path(:body => @body, :token => @token)\n return\n end\n end",
"def create\n @post246 = Post246.new(params[:post246])\n\n respond_to do |format|\n if @post246.save\n format.html { redirect_to(@post246, :notice => 'Post246 was successfully created.') }\n format.xml { render :xml => @post246, :status => :created, :location => @post246 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post246.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def save\n self.client.api_post(\"/feed\", self.create_params)\n end",
"def create\r\n @post = current_user.posts.new(params[:post])\r\n respond_to do |format|\r\n if @post.save\r\n flash[:notice] = 'Post was successfully created.'\r\n format.html { redirect_to(@post) }\r\n format.xml { render :xml => @post, :status => :created, :location => @post }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @post78 = Post78.new(params[:post78])\n\n respond_to do |format|\n if @post78.save\n format.html { redirect_to(@post78, :notice => 'Post78 was successfully created.') }\n format.xml { render :xml => @post78, :status => :created, :location => @post78 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post78.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(data = \"\")\n submit :Post, data\n end",
"def post(data = {})\n call data, method: :post\n end",
"def post(path, data={})\n request(:post, path, data)\n end",
"def post(uri, params = {})\n send_request(uri, :post, params)\n end",
"def post(path, params={})\n request(:post, path, params)\n end",
"def post(path, params={})\n request(:post, path, params)\n end",
"def post(path, params={})\n request(:post, path, params)\n end",
"def post(path, params = {})\n\t\trequest(path, :post, params)\n\tend",
"def post(path, options={})\n send_request 'post', path, options\n end",
"def create\n @post157 = Post157.new(params[:post157])\n\n respond_to do |format|\n if @post157.save\n format.html { redirect_to(@post157, :notice => 'Post157 was successfully created.') }\n format.xml { render :xml => @post157, :status => :created, :location => @post157 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post157.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n post_service = PostService.new(current_user, params)\n post_service.create_post\n #post_service.create\n respond_to do |format|\n if post_service.save?\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { redirect_to new_post_url, alert: post_service.errors }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_headers\n {\"Content-Type\" => 'text/xml; charset=utf-8'}\n end",
"def send_post(data_xml,url)\r\n result = @client.post(self.target_uri(url), :body => data_xml , :head => {'Content-Type' => 'application/xml'} ) \r\n raise \"Invalid status #{result.http_status} from server #{@host}:#{@port}\" if(result.http_status != '200') \r\n #reply = Reply.from_xml(result.http_body)\r\n if block_given?\r\n yield(result.http_body)\r\n else\r\n result.http_body\r\n end\r\n end",
"def post(path, options = {})\n request(:post, path, options)\n end",
"def post(path, options = {})\n request(:post, path, options)\n end",
"def post(path, options = {})\n request(:post, path, options)\n end",
"def post!\n request! :post\n end",
"def create\n respond_with Post.create(post_params)\n end",
"def api_post(action, data)\n api_request(action, data, 'POST')\n end",
"def create\n @post405 = Post405.new(params[:post405])\n\n respond_to do |format|\n if @post405.save\n format.html { redirect_to(@post405, :notice => 'Post405 was successfully created.') }\n format.xml { render :xml => @post405, :status => :created, :location => @post405 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post405.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(path, options = {})\n request(:post, path, options)\n end",
"def post(path, options = {})\n request(:post, path, options)\n end",
"def post(path, options = {})\n request(:post, path, options)\n end",
"def create\n @post57 = Post57.new(params[:post57])\n\n respond_to do |format|\n if @post57.save\n format.html { redirect_to(@post57, :notice => 'Post57 was successfully created.') }\n format.xml { render :xml => @post57, :status => :created, :location => @post57 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post57.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post445 = Post445.new(params[:post445])\n\n respond_to do |format|\n if @post445.save\n format.html { redirect_to(@post445, :notice => 'Post445 was successfully created.') }\n format.xml { render :xml => @post445, :status => :created, :location => @post445 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post445.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(method, params = {})\n url = make_url method, params\n query = url.query\n url.query = nil\n\n req = Net::HTTP::Post.new url.path\n req.body = query\n req.content_type = 'application/x-www-form-urlencoded'\n\n res = Net::HTTP.start url.host, url.port do |http|\n http.request req\n end\n\n xml = Nokogiri::XML(res.body, nil, nil, 0)\n\n check_error xml\n\n parse_response xml\n rescue SystemCallError, SocketError, Timeout::Error, IOError,\n Nokogiri::XML::SyntaxError => e\n raise CommunicationError.new(e)\n rescue Net::HTTPError => e\n xml = Nokogiri::XML(e.res.body) { |cfg| cfg.strict }\n check_error xml\n raise CommunicationError.new(e)\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n make_rss\n end",
"def render_post\n respond_to do |wants| \n wants.html {render :to_xml => 'POST.xml.builder', :layout => false, :status => 201}\n wants.json {render :to_json => 'POST.xml.builder', :status => 201}\n wants.xml {render :to_xml => 'POST.xml.builder', :layout => false, :status => 201}\n wants.yaml {render :to_yaml => 'POST.xml.builder', :status => 201}\n end \n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def create\n res = self.class.post('/', body: attrs)\n res.created?\n end",
"def create\n @post = postable.posts.build(params[:post])\n @post.author = current_agent\n\n respond_to do |format|\n if @post.save\n flash[:success] = t('post.created')\n format.html { redirect_to(polymorphic_path([ postable.container, postable ], :anchor => dom_id(@post))) }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create(name=\"Default name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Post.new(@url)\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n response.body\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def create\n @post = current_user.posts.build(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to(@post, :notice => 'Post created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post125 = Post125.new(params[:post125])\n\n respond_to do |format|\n if @post125.save\n format.html { redirect_to(@post125, :notice => 'Post125 was successfully created.') }\n format.xml { render :xml => @post125, :status => :created, :location => @post125 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post125.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(content)\n post_to(\"/api/v1/messages/\", {:body => content})\n end",
"def create\n @posts = Post.find_all_by_kiez(get_kiez, :order => 'updated_at DESC')\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n flash[:notice] = 'Die Anzeige wurde erfolgreich erstellt.'\n puts @post.inspect\n ContactMailer.deliver_notify(@post)\n format.html { redirect_to(@post) }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params.to_xml, signature_params)\n end",
"def create\n \n @onpost = Onpost.new(params[:onpost])\n respond_to do |format|\n if @onpost.save\n flash[:notice] = 'Onpost was successfully created.'\n format.html { redirect_to :back }\n format.xml { render :xml => @onpost, :status => :created, :location => @onpost }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @onpost.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post168 = Post168.new(params[:post168])\n\n respond_to do |format|\n if @post168.save\n format.html { redirect_to(@post168, :notice => 'Post168 was successfully created.') }\n format.xml { render :xml => @post168, :status => :created, :location => @post168 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post168.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create \n\t\tif params[:message] != ''\n\t\t\t@post = Post.create(:message => params[:message]) \n\t\t\t@post.user = current_user\n\t\t\trespond_to do |format| \n\t\t\t\tif @post.save \n\t\t\t\t\tflash[:notice] = 'Post was successfully created.'\n\t\t\t\t\tformat.html { redirect_to :back } \n\t\t\t\t\tformat.xml { render:xml => @post}\n\t\t\t\telse \n\t\t\t\t\tflash[:notice] = \"Message failed to save.\" \n\t\t\t\t\tformat.html { redirect_to :back }\n\t\t\t\t\tformat.xml { render :xml => @post.errors, \n\t\t\t\t\t\t\t\t\t:status => :unprocessable_entity } \n\t\t\t\tend \n\t\t\tend\n\t\telse\n\t\t\tredirect_to(posts_url)\n\t\tend\n \tend",
"def create\n @post = Post.new(params[:post])\n @post.user = find_current_user\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to(posts_url, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post245 = Post245.new(params[:post245])\n\n respond_to do |format|\n if @post245.save\n format.html { redirect_to(@post245, :notice => 'Post245 was successfully created.') }\n format.xml { render :xml => @post245, :status => :created, :location => @post245 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post245.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(attrs = nil)\n attrs ||= attributes\n\n execute_request('POST') do |uri, headers|\n HTTP.http_client.post(\n uri,\n body: adapter.serialize(attrs),\n header: headers.merge(CONTENT_TYPE_HEADERS)\n )\n end\n end",
"def post(body)\n request = Net::HTTP::Post.new(bind_uri)\n request.body = body\n request.content_length = request.body.size\n request[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\n Jabber.debug(\"Sending POST request - #{body.strip}\")\n\n response = Net::HTTP.new(domain, port).start { |http| http.request(request) }\n\n Jabber.debug(\"Receiving POST response - #{response.code}: #{response.body.inspect}\")\n\n unless response.is_a?(Net::HTTPSuccess)\n raise Net::HTTPBadResponse, \"Net::HTTPSuccess expected, but #{response.class} was received\"\n end\n\n response\n end"
] | [
"0.68471384",
"0.68003213",
"0.66374344",
"0.66279626",
"0.6584102",
"0.63851535",
"0.63196474",
"0.6277413",
"0.6249678",
"0.62304235",
"0.6226135",
"0.62150663",
"0.6205251",
"0.61857855",
"0.6185225",
"0.6155584",
"0.61525047",
"0.6142964",
"0.61428297",
"0.6131127",
"0.61247337",
"0.61076224",
"0.6103737",
"0.6070569",
"0.6058065",
"0.6053793",
"0.60498804",
"0.60409755",
"0.60409755",
"0.6004638",
"0.5989346",
"0.59597903",
"0.59476167",
"0.59476167",
"0.59242433",
"0.5914419",
"0.5914419",
"0.5912093",
"0.5881676",
"0.5839714",
"0.5838631",
"0.58315504",
"0.5830813",
"0.58177096",
"0.5810519",
"0.5802787",
"0.5797865",
"0.5789947",
"0.5788231",
"0.57877904",
"0.57801086",
"0.5771",
"0.5760989",
"0.5755013",
"0.575382",
"0.5748013",
"0.57437325",
"0.57437325",
"0.57437325",
"0.57362705",
"0.5735199",
"0.57238376",
"0.5719261",
"0.5718615",
"0.5716112",
"0.5708743",
"0.5708743",
"0.5708743",
"0.5706486",
"0.57037926",
"0.5703017",
"0.57011425",
"0.5688773",
"0.5688773",
"0.5688773",
"0.5686529",
"0.5684923",
"0.56809235",
"0.567994",
"0.56747174",
"0.56727564",
"0.56727564",
"0.56727564",
"0.56727564",
"0.56727564",
"0.5664196",
"0.56614447",
"0.5661383",
"0.56596106",
"0.56577134",
"0.5657693",
"0.5652858",
"0.56523",
"0.56426215",
"0.56390405",
"0.5637395",
"0.56365585",
"0.5630175",
"0.56301606",
"0.5628614",
"0.56277245"
] | 0.0 | -1 |
PUT /posts/1 PUT /posts/1.xml | def update
respond_to do |format|
if @post.update_attributes(params[:post])
flash[:notice] = 'Post was successfully updated.'
if params[:images]
counter = 0
for image in params[:images]["file_data"]
if image != ""
@image = Image.create(:file_data => image, :owner_id => @post.id, :owner_type => 'Post', :filename => image.original_filename,
:body => params[:images]["body"][counter] )
counter = counter + 1
end
end
end
format.html { redirect_to posts_path }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @post.errors.to_xml }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to(@post) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n make_rss\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(post_params)\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n format.xml { render xml: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_with Post.update(params[:id], params[:posts])\n end",
"def put(*args)\n request :put, *args\n end",
"def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(\"/#{@post.url}\", :notice => t('controller.updated')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def update\n @post = Post.find(params[:id])\n\t@posts = Post.all\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_with post.update(params[:id], params[:post])\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to(@post) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(uri, doc = nil, options = {})\n execute(uri, :put, options, doc)\n end",
"def put(*args)\n request(:put, *args)\n end",
"def update\n respond_to do |format|\n if @post.update_attributes(params[:post])\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, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.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 post.update_attributes(params[:post])\n flash[:success] = t('post.updated')\n format.html { redirect_to(polymorphic_path([ postable.container, postable ], :anchor => dom_id(@post))) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.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 format.html { redirect_to(posts_url, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.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 format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.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 format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.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 format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\r\n @post = Post.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @post.update_attributes(params[:post])\r\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_with Post.update(params[:id],post_params)\n end",
"def update\n @post = Post.find(params[:id])\n \n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => t('posts.show.post_updated')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.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 @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to post_url(@post) }\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 r = PostRepository.new\n @post = r.GetPost(\"PostID\", params[:id])\n @post.PostID = params[:id].to_i\n @post.title = params[:title]\n\n respond_to do |format|\n if r.save(@post)\n flash[:notice] = 'Post was successfully created.'\n format.html { redirect_to(@post) }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.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 test_update_post\n data = {\n title: \"Roll lemon\",\n content: \"Gingerbread bear claw muffin danish danish marzipan. Toffee lollipop wafer carrot cake dessert.\",\n description: \"Chocolate tootsie roll lemon drops. Chupa chups chocolate bar apple pie\",\n image: \"chocolate.png\",\n status: 1\n }\n expected = 200\n post_id = 1\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s)\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def update(*args)\n put(*args)\n end",
"def update(*args)\n put(*args)\n end",
"def update\n update! { posts_url }\n end",
"def update\n @post251 = Post251.find(params[:id])\n\n respond_to do |format|\n if @post251.update_attributes(params[:post251])\n format.html { redirect_to(@post251, :notice => 'Post251 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post251.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n @title = @post.title\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :flash => { :success => 'Post was successfully updated.' } ) }\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, doc = nil, options = {})\n execute('PUT', path, options, doc)\n end",
"def update\n respond_to do |format|\n @post.title = params[:title]\n @post.body = params[:body]\n @tags = params[:tags].split(',') unless params[:tags].blank?\n Post.transaction do\n if @post.save\n destroy_tags(@post, @tags)\n create_tags(@post, @tags)\n format.html { redirect_to posts_path, notice: 'Post was successfully updated.' }\n format.json { render :show, status: :ok, location: @post }\n else\n @action_path = post_path @post\n @method = :put\n format.html { render :edit }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def put_datastream(pid, dsID, xml)\n uri = URI.parse(@fedora + '/objects/' + pid + '/datastreams/' + dsID ) \n RestClient.put(uri.to_s, xml, :content_type => \"application/xml\")\n rescue => e\n e.response \n end",
"def update\n @post182 = Post182.find(params[:id])\n\n respond_to do |format|\n if @post182.update_attributes(params[:post182])\n format.html { redirect_to(@post182, :notice => 'Post182 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post182.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n update_resource_response(@post, blog_post_params)\n end",
"def update\n redirect_to '/posts'\n end",
"def update\n @post157 = Post157.find(params[:id])\n\n respond_to do |format|\n if @post157.update_attributes(params[:post157])\n format.html { redirect_to(@post157, :notice => 'Post157 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post157.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]) then\n Feed.update_post(@post)\n format.js { render :action => \"update.rjs\" } if request.xhr?\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n title = params[:title]\n body = params[:body]\n\n @post.update!(title: title, body: body)\n\n if @post.save!\n json_response(@post)\n else\n json_response(@post.errors)\n end\n end",
"def update\n put :update\n end",
"def update\n @post231 = Post231.find(params[:id])\n\n respond_to do |format|\n if @post231.update_attributes(params[:post231])\n format.html { redirect_to(@post231, :notice => 'Post231 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post231.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def post\n doc = Nokogiri::XML(request.body)\n id= (doc/'id').text\n # p = Post.exists?(id) ? Post.find(id) : Post.new\n p= Post.find_or_create_by_intranet_id id\n p.update_attributes :subject => (doc/'subject').text,\n :body => (doc/'body').text, :post_type => (doc/'post-type').text,\n :pic => (doc/'pic') .text, :begin_on=>(doc/'begin-on').text,\n :pic_postimg => (doc/'pic-postimg').text,\n :video => (doc/'video').text, \n :end_on => (doc/'end-on').text, :stick => (doc/'stick').text \n render :text => \"ok\"\n end",
"def update\r\n @post = Post.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @post.update_attributes(params[:post])\r\n format.html { redirect_to(:action => 'adminlist') }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @post275 = Post275.find(params[:id])\n\n respond_to do |format|\n if @post275.update_attributes(params[:post275])\n format.html { redirect_to(@post275, :notice => 'Post275 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post275.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post.author ||= current_user\n @post.current_revision.user = current_user\n check_for_draft\n respond_to do |format|\n if @post.update_attributes(params[:post])\n handle_pingbacks\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to(@post) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post253 = Post253.find(params[:id])\n\n respond_to do |format|\n if @post253.update_attributes(params[:post253])\n format.html { redirect_to(@post253, :notice => 'Post253 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post253.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end",
"def put(path, options={})\n request :put, path, options\n end",
"def update\n @post78 = Post78.find(params[:id])\n\n respond_to do |format|\n if @post78.update_attributes(params[:post78])\n format.html { redirect_to(@post78, :notice => 'Post78 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post78.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post81 = Post81.find(params[:id])\n\n respond_to do |format|\n if @post81.update_attributes(params[:post81])\n format.html { redirect_to(@post81, :notice => 'Post81 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post81.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post246 = Post246.find(params[:id])\n\n respond_to do |format|\n if @post246.update_attributes(params[:post246])\n format.html { redirect_to(@post246, :notice => 'Post246 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post246.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post245 = Post245.find(params[:id])\n\n respond_to do |format|\n if @post245.update_attributes(params[:post245])\n format.html { redirect_to(@post245, :notice => 'Post245 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post245.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\r\n @post = Post.find(params[:id])\r\n @root_post = root_post_of(@post)\r\n\r\n respond_to do |format|\r\n if @post.update_attributes(params[:post])\r\n @root_post.touch(:updated_at)\r\n update_child_posts(@post)\r\n\r\n format.html { redirect_to @post, notice: 'Post 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: @post.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @post.update_attributes(params[:post])\n respond_with(@post)\n end",
"def update\n @post321 = Post321.find(params[:id])\n\n respond_to do |format|\n if @post321.update_attributes(params[:post321])\n format.html { redirect_to(@post321, :notice => 'Post321 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post321.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post328 = Post328.find(params[:id])\n\n respond_to do |format|\n if @post328.update_attributes(params[:post328])\n format.html { redirect_to(@post328, :notice => 'Post328 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post328.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post181 = Post181.find(params[:id])\n\n respond_to do |format|\n if @post181.update_attributes(params[:post181])\n format.html { redirect_to(@post181, :notice => 'Post181 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post181.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n post = current_user.posts.find_by_uuid(params[:id])\n return render_item_not_found('Post') unless post\n post.update_attributes(post_params)\n broadcast(post, 'update')\n head :ok\n end",
"def update\n @request.accept\n redirect_to posts_url\n end",
"def put(path = '/files/', params = {})\n request :put, path, params\n end",
"def update\n id = Post.find(params[:id])._id\n \n respond_to do |format|\n if ((@post.update_attributes(params[:post])) && (@post._id = id))\n format.html { redirect_to @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 @post273 = Post273.find(params[:id])\n\n respond_to do |format|\n if @post273.update_attributes(params[:post273])\n format.html { redirect_to(@post273, :notice => 'Post273 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post273.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n @post.tag_list = params[:tags]\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n @post.update_attributes(params[:post])\n format.html { redirect_to posts_url, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n end \n end",
"def update\n @post193 = Post193.find(params[:id])\n\n respond_to do |format|\n if @post193.update_attributes(params[:post193])\n format.html { redirect_to(@post193, :notice => 'Post193 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post193.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post107 = Post107.find(params[:id])\n\n respond_to do |format|\n if @post107.update_attributes(params[:post107])\n format.html { redirect_to(@post107, :notice => 'Post107 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post107.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @onpost = Onpost.find(params[:id])\n\n respond_to do |format|\n if @onpost.update_attributes(params[:onpost])\n flash[:notice] = 'Onpost was successfully updated.'\n format.html { redirect_to(@onpost) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @onpost.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post483 = Post483.find(params[:id])\n\n respond_to do |format|\n if @post483.update_attributes(params[:post483])\n format.html { redirect_to(@post483, :notice => 'Post483 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post483.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 update\n @post120 = Post120.find(params[:id])\n\n respond_to do |format|\n if @post120.update_attributes(params[:post120])\n format.html { redirect_to(@post120, :notice => 'Post120 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post120.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post134 = Post134.find(params[:id])\n\n respond_to do |format|\n if @post134.update_attributes(params[:post134])\n format.html { redirect_to(@post134, :notice => 'Post134 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post134.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post66 = Post66.find(params[:id])\n\n respond_to do |format|\n if @post66.update_attributes(params[:post66])\n format.html { redirect_to(@post66, :notice => 'Post66 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post66.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = @contest.posts.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to(@post) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post101 = Post101.find(params[:id])\n\n respond_to do |format|\n if @post101.update_attributes(params[:post101])\n format.html { redirect_to(@post101, :notice => 'Post101 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post101.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post143 = Post143.find(params[:id])\n\n respond_to do |format|\n if @post143.update_attributes(params[:post143])\n format.html { redirect_to(@post143, :notice => 'Post143 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post143.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(doc, uri=nil, content_type=nil)\n return _put_doc(doc, uri, content_type)\n end",
"def update\n @post284 = Post284.find(params[:id])\n\n respond_to do |format|\n if @post284.update_attributes(params[:post284])\n format.html { redirect_to(@post284, :notice => 'Post284 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post284.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post125 = Post125.find(params[:id])\n\n respond_to do |format|\n if @post125.update_attributes(params[:post125])\n format.html { redirect_to(@post125, :notice => 'Post125 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post125.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n@post = Post.find(params[:id])\nrespond_to do |format|\nif @post.update_attributes(params[:post])\nflash[:notice] = 'Post was successfully updated.'\nformat.html { redirect_to posts_path(\n:forum_id => params[:forum_id],\n:topic_id => params[:topic_id]) }\nformat.xml { head :ok }\nelse\nformat.html { render :action => \"edit\" }\nformat.xml { render :xml => @post.errors.to_xml }\nend\nend\nend",
"def update\n @post = Post.find(params[:id])\n\tpublished = false\n\tif params[:post][:published] == 1\n\t published = true\n\tend\n\n respond_to do |format|\n if @post.update_attributes(params[:post] )\n format.html { redirect_to(@post, :notice => 'Post updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put endpoint, data\n do_request :put, endpoint, data\n end",
"def update\n @post156 = Post156.find(params[:id])\n\n respond_to do |format|\n if @post156.update_attributes(params[:post156])\n format.html { redirect_to(@post156, :notice => 'Post156 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post156.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 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"
] | [
"0.6867673",
"0.66907144",
"0.6294395",
"0.62794256",
"0.6099675",
"0.6098852",
"0.6035446",
"0.59057415",
"0.590173",
"0.58895403",
"0.5880021",
"0.58741546",
"0.5867954",
"0.5849058",
"0.5837317",
"0.5833679",
"0.58261484",
"0.5825736",
"0.5818691",
"0.58159804",
"0.58100533",
"0.58100533",
"0.58100533",
"0.58100533",
"0.58056474",
"0.58053356",
"0.5782647",
"0.5746143",
"0.57334566",
"0.57311493",
"0.57014084",
"0.56923133",
"0.56901574",
"0.56901574",
"0.5686076",
"0.56612194",
"0.56555593",
"0.5654249",
"0.5653651",
"0.5651996",
"0.5651102",
"0.5643569",
"0.56417733",
"0.5635933",
"0.5610392",
"0.5608158",
"0.5603139",
"0.5600439",
"0.5599689",
"0.55984175",
"0.55961937",
"0.5575449",
"0.557458",
"0.55743843",
"0.5568167",
"0.5568106",
"0.5567454",
"0.55669326",
"0.5555517",
"0.55506414",
"0.5550475",
"0.55434495",
"0.5539862",
"0.5538768",
"0.55309653",
"0.5527094",
"0.55199236",
"0.5517754",
"0.551749",
"0.5514836",
"0.5507115",
"0.5503528",
"0.5486096",
"0.548296",
"0.5476181",
"0.54727274",
"0.54707205",
"0.5467842",
"0.54669976",
"0.5462694",
"0.5462694",
"0.5462694",
"0.5462614",
"0.5461398",
"0.5459898",
"0.54595584",
"0.5453652",
"0.54493564",
"0.5446812",
"0.54454684",
"0.5444855",
"0.5444017",
"0.5439702",
"0.5423656",
"0.5415436",
"0.54132944",
"0.54132944",
"0.54132944",
"0.54132944",
"0.54132944",
"0.54132944"
] | 0.0 | -1 |
DELETE /posts/1 DELETE /posts/1.xml | def destroy
@post.destroy
respond_to do |format|
format.html { redirect_to posts_url }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n r = PostRepository.new\n @post = r.GetPost(\"PostID\", params[:id].to_i)\n r.delete @post\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.deleted = 1\n @post.save\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n make_rss\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(root_path, :notice => t('controller.deleted')) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\r\n @post = Post.find(params[:id])\r\n @post.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(posts_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\r\n @post = Post.find(params[:id])\r\n @post.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(posts_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def delete_post\n\t \n \tend",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n \n respond_to do |format|\n format.html { redirect_to(posts_url, notice: t('posts.index.post_deleted')) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(root_url, :notice => 'Post was successfully removed.') }\n format.xml { head :ok }\n end\n end",
"def destroy\n if @post.destroy\n flash[:notice] = \"post deleted!\"\n end\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n# format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end",
"def destroy\n @post251 = Post251.find(params[:id])\n @post251.destroy\n\n respond_to do |format|\n format.html { redirect_to(post251s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n respond_to do |format|\n format.html { redirect_to(admin_posts_url, :notice => 'Successfully deleted') }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post445 = Post445.find(params[:id])\n @post445.destroy\n\n respond_to do |format|\n format.html { redirect_to(post445s_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @post246 = Post246.find(params[:id])\n @post246.destroy\n\n respond_to do |format|\n format.html { redirect_to(post246s_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n @post = Post.find(params[:id])\n end",
"def delete(url)\n raise Error, \"Missing URL\" unless url\n get('posts/delete?uri=' << u(url))\n nil\n end",
"def destroy\n @post446 = Post446.find(params[:id])\n @post446.destroy\n\n respond_to do |format|\n format.html { redirect_to(post446s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post.destroy\n\n head :no_content\n end",
"def destroy\n destroy_q(@post, posts_url)\n end",
"def destroy\n @post405 = Post405.find(params[:id])\n @post405.destroy\n\n respond_to do |format|\n format.html { redirect_to(post405s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post134 = Post134.find(params[:id])\n @post134.destroy\n\n respond_to do |format|\n format.html { redirect_to(post134s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post321 = Post321.find(params[:id])\n @post321.destroy\n\n respond_to do |format|\n format.html { redirect_to(post321s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post66 = Post66.find(params[:id])\n @post66.destroy\n\n respond_to do |format|\n format.html { redirect_to(post66s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n #@post = @contest.posts.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @post = Post.find(params[:id])\r\n @post.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(:action => 'adminlist') }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @post.destroy\n head :no_content\n end",
"def destroy\n @post.destroy\n head :no_content\n end",
"def destroy\n @post407 = Post407.find(params[:id])\n @post407.destroy\n\n respond_to do |format|\n format.html { redirect_to(post407s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post57 = Post57.find(params[:id])\n @post57.destroy\n\n respond_to do |format|\n format.html { redirect_to(post57s_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n@post = Post.find(params[:id])\n@post.destroy\nrespond_to do |format|\nformat.html { redirect_to posts_path(:forum_id => params[:forum_id],\n:topic_id => params[:topic_id]) }\nformat.xml { head :ok }\nend\nend",
"def destroy\n @post55 = Post55.find(params[:id])\n @post55.destroy\n\n respond_to do |format|\n format.html { redirect_to(post55s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\t@post = Post.find(params[:id])\n @post.destroy\n flash[:success] = \"Post deleted\"\n respond_to do |format|\n format.html { redirect_to(user_posts_path(@post.user)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @offpost = Offpost.find(params[:id])\n @offpost.destroy\n\n respond_to do |format|\n format.html { redirect_to(offposts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post78 = Post78.find(params[:id])\n @post78.destroy\n\n respond_to do |format|\n format.html { redirect_to(post78s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post447 = Post447.find(params[:id])\n @post447.destroy\n\n respond_to do |format|\n format.html { redirect_to(post447s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post54 = Post54.find(params[:id])\n @post54.destroy\n\n respond_to do |format|\n format.html { redirect_to(post54s_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id, post)\n File.unlink(post_path(post))\n\n update_digests do |digests|\n digests.delete(id)\n end\n end",
"def destroy\n @post157 = Post157.find(params[:id])\n @post157.destroy\n\n respond_to do |format|\n format.html { redirect_to(post157s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n save_notice(\"文章删除成功.\")\n format.html { redirect_to(cpanel_posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post328 = Post328.find(params[:id])\n @post328.destroy\n\n respond_to do |format|\n format.html { redirect_to(post328s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post.destroy\n head :no_content\n end",
"def destroy\n @post.destroy\n back_to = params[:back_to] || posts_url\n respond_to do |format|\n format.html { redirect_to(back_to) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post182 = Post182.find(params[:id])\n @post182.destroy\n\n respond_to do |format|\n format.html { redirect_to(post182s_url) }\n format.xml { head :ok }\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 @post245 = Post245.find(params[:id])\n @post245.destroy\n\n respond_to do |format|\n format.html { redirect_to(post245s_url) }\n format.xml { head :ok }\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(project_topic_url(@project, @topic)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post483 = Post483.find(params[:id])\n @post483.destroy\n\n respond_to do |format|\n format.html { redirect_to(post483s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post75 = Post75.find(params[:id])\n @post75.destroy\n\n respond_to do |format|\n format.html { redirect_to(post75s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n Post.find(params[:id]).delete\n\n redirect_to '/'\n end",
"def destroy\n @post149 = Post149.find(params[:id])\n @post149.destroy\n\n respond_to do |format|\n format.html { redirect_to(post149s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post154 = Post154.find(params[:id])\n @post154.destroy\n\n respond_to do |format|\n format.html { redirect_to(post154s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post125 = Post125.find(params[:id])\n @post125.destroy\n\n respond_to do |format|\n format.html { redirect_to(post125s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n post.destroy\n\n respond_to do |format|\n format.html { redirect_to(polymorphic_path([@postable.container, @postable], :anchor => 'posts')) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post453 = Post453.find(params[:id])\n @post453.destroy\n\n respond_to do |format|\n format.html { redirect_to(post453s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post10 = Post10.find(params[:id])\n @post10.destroy\n\n respond_to do |format|\n format.html { redirect_to(post10s_url) }\n format.xml { head :ok }\n end\n end",
"def delete_post\n post = Post.find_by_id(params[:id])\n if !post.nil?\n post.destroy\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @post184 = Post184.find(params[:id])\n @post184.destroy\n\n respond_to do |format|\n format.html { redirect_to(post184s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post74 = Post74.find(params[:id])\n @post74.destroy\n\n respond_to do |format|\n format.html { redirect_to(post74s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post464 = Post464.find(params[:id])\n @post464.destroy\n\n respond_to do |format|\n format.html { redirect_to(post464s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post.destroy\n end",
"def destroy\n @post.destroy\n end",
"def destroy\n @post.destroy\n end",
"def destroy\n @post.destroy\n end",
"def destroy\n @post150 = Post150.find(params[:id])\n @post150.destroy\n\n respond_to do |format|\n format.html { redirect_to(post150s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post.destroy\n\n end",
"def destroy\n @post129 = Post129.find(params[:id])\n @post129.destroy\n\n respond_to do |format|\n format.html { redirect_to(post129s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post21 = Post21.find(params[:id])\n @post21.destroy\n\n respond_to do |format|\n format.html { redirect_to(post21s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post409 = Post409.find(params[:id])\n @post409.destroy\n\n respond_to do |format|\n format.html { redirect_to(post409s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post99 = Post99.find(params[:id])\n @post99.destroy\n\n respond_to do |format|\n format.html { redirect_to(post99s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url, :notice => \"Post (#{@post.title}) was successfully deleted.\") }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @blog_post = BlogPost.find(params[:id])\n @blog_post.destroy\n\n respond_to do |format|\n format.html { redirect_to(blog_posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @blog_post = BlogPost.find(params[:id])\n @blog_post.destroy\n\n respond_to do |format|\n format.html { redirect_to(blog_posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post_note = PostNote.find(params[:id])\n @post_note.destroy\n\n respond_to do |format|\n format.html { redirect_to(post_notes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post101 = Post101.find(params[:id])\n @post101.destroy\n\n respond_to do |format|\n format.html { redirect_to(post101s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to blog_posts_path, notice: 'Post was successfully destroyed.' }\n format.xml {head :ok }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post81 = Post81.find(params[:id])\n @post81.destroy\n\n respond_to do |format|\n format.html { redirect_to(post81s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post181 = Post181.find(params[:id])\n @post181.destroy\n\n respond_to do |format|\n format.html { redirect_to(post181s_url) }\n format.xml { head :ok }\n end\n end"
] | [
"0.7365624",
"0.7322596",
"0.715179",
"0.715179",
"0.70919865",
"0.7068259",
"0.7068259",
"0.7068259",
"0.7068259",
"0.7068259",
"0.7068259",
"0.7068259",
"0.7068259",
"0.7068259",
"0.7068259",
"0.7068259",
"0.7068259",
"0.7068259",
"0.7068259",
"0.7068259",
"0.70451736",
"0.7041529",
"0.7040201",
"0.7003356",
"0.6966629",
"0.69642085",
"0.691911",
"0.6913336",
"0.6886652",
"0.683633",
"0.68302375",
"0.68173075",
"0.68145967",
"0.68008894",
"0.68001777",
"0.67938507",
"0.6780227",
"0.6773315",
"0.67686003",
"0.67588013",
"0.6755028",
"0.67485183",
"0.67350566",
"0.67339945",
"0.6731557",
"0.67295295",
"0.67281026",
"0.67281026",
"0.6726317",
"0.6715316",
"0.6706418",
"0.67061573",
"0.67017454",
"0.66882473",
"0.6683431",
"0.6681235",
"0.66810334",
"0.66785",
"0.6675209",
"0.6674261",
"0.66676027",
"0.66579735",
"0.66576815",
"0.665357",
"0.664931",
"0.6647831",
"0.66473997",
"0.664443",
"0.66437715",
"0.66428995",
"0.66392773",
"0.6638891",
"0.6633285",
"0.6628",
"0.66277605",
"0.6627475",
"0.6624094",
"0.66194755",
"0.6619459",
"0.6615494",
"0.66104335",
"0.6608262",
"0.66078746",
"0.66078746",
"0.66078746",
"0.66078746",
"0.6605365",
"0.66036683",
"0.6598655",
"0.65969294",
"0.65967304",
"0.6595475",
"0.6594835",
"0.6592946",
"0.6592946",
"0.6583013",
"0.6582412",
"0.65808076",
"0.6579295",
"0.65787655"
] | 0.72059286 | 2 |
Remove comment from GitHub and then remove from database if successful. comment_id is unique identifier within repo scope. | def remove_comment repo, comment_id
response = @@connection.delete do | request |
request.url "repos/#{repo}/issues/comments/#{comment_id}"
request.headers['Authorization'] = "token #{@@token}"
end
# look for Status: 204 No Content
return if response.env[:status] != 204
# Comment successfully deleted from GitHub so remove from comment.db
@@db.execute "delete from comment where id == #{comment_id}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_pull_request_comment(repo, comment_id, options = {})\n boolean_from_response(:delete, \"#{Repository.path repo}/pulls/comments/#{comment_id}\", options)\n end",
"def delete_comment(user_name, repo_name, comment_id, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n _validate_presence_of comment_id\n _normalize_params_keys(params)\n\n delete(\"/repos/#{user}/#{repo}/comments/#{comment_id}\", params)\n end",
"def delete(user_name, repo_name, comment_id, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n _validate_presence_of comment_id\n\n normalize! params\n # _merge_mime_type(:issue_comment, params)\n\n delete_request(\"/1.0/repositories/#{user}/#{repo.downcase}/issues/comments/#{comment_id}\", params)\n end",
"def delete_review_comment(repo, comment_id, options = {})\n boolean_from_response :delete, \"#{Repository.path repo}/pulls/comments/#{comment_id}\", options\n end",
"def delete_issue_comment(user_name, repo_name, comment_id, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n _validate_presence_of comment_id\n\n _normalize_params_keys(params)\n _merge_mime_type(:issue_comment, params)\n\n delete(\"/repos/#{user}/#{repo}/issues/comments/#{comment_id}\", params)\n end",
"def delete_issue_comment(repo, comment_id, options = {})\n boolean_from_response :delete, \"#{Repository.path repo}/issues/comments/#{comment_id}\", options\n end",
"def delete_comment(issue_id_or_key, comment_id)\n delete(\"issues/#{issue_id_or_key}/comments/#{comment_id}\")\n end",
"def remove_comment(xid,comment_id)\n post('facebook.comments.remove', :xid=>xid, :comment_id =>comment_id)\n end",
"def destroy_comment(resource_id, comment_id)\n http.delete(\"#{comment_endpoint(resource_id)}/#{comment_id}\") do |response|\n true\n end\n end",
"def del_comment\n @comment = ''\n end",
"def delete_gist_comment(id, comment_id)\n boolean_request :delete, \"/gists/#{id}/comments/#{comment_id}\"\n end",
"def delete_comment(comment_id, params={})\n _normalize_params_keys(params)\n _validate_presence_of(comment_id)\n # _merge_mime_type(:gist_comment, params)\n\n delete(\"/gists/comments/#{comment_id}\", params)\n end",
"def destroy_comment!(session_key, comment_id)\n comment = find_comment_by_session_and_id!(session_key, comment_id)\n comment.destroy!\n end",
"def delete_comment\n comment = Comment.find_by_id(params[:id])\n if !comment.nil?\n comment.destroy\n end\n end",
"def delete_gist_comment(comment_id, params={})\n _normalize_params_keys(params)\n _merge_mime_type(:gist_comment, params)\n\n delete(\"/gists/comments/#{comment_id}\", params)\n end",
"def delete_comment\n verify_post_request\n verify_ajax_request\n require_parameters :id\n\n comment = Internal.issues.deleteComment(params[:id])\n\n @issue_results = Api.issues.find(comment.issueKey)\n render :partial => 'issue/issue', :locals => {:issue => @issue_results.issues.get(0)}\n end",
"def remove_comment\n\t if current_usertype.account_id == params[:account_id].to_i || current_admin\n \t\tcomment = Comment.find(params[:id])\n \t\tcomment.destroy\n \t\tflash[:notice] = \"Comment removed\"\n \t\tredirect_to :controller => :projects, :action => :comments_show, :id => params[:project_id]\n\t else\n\t flash[:error] = \"You do not have access to this page\"\n\t redirect_to root_url\n\t end\n\tend",
"def destroy\n\t\t@comment = Comment.find( params[:id] )\n\t\t\n\t\tif @comment.commentable.class.comments_extension.can_remove?( @comment.commentable, @comment, current_user_get )\t\t\n\t\t\t@removed_ids = [ @comment.id ]\n\t\t\t\n\t\t\tfor comment in @comment.descendants do\n\t\t\t\t@removed_ids << comment.id\n\t\t\tend\n\t\t\t\n\t\t\t@comment.destroy\n\t\t\t\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { redirect_to comments_url }\n\t\t\t\tformat.xml { head :ok }\n\t\t\t\tformat.js\n\t\t\tend\n\t\telse\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { redirect_to comments_url }\n\t\t\t\tformat.xml { head :err }\n\t\t\t\tformat.js\t{ render :update do |page| page.alert \"You can't remove this comment\" end }\n\t\t\tend\n\t\tend\n\tend",
"def delete_gist_comment(gist_id, comment_id, options = {})\n boolean_from_response :delete, \"gists/#{Gist.new gist_id}/comments/#{comment_id}\", options\n end",
"def delete_comment(cmt)\n @comments.delete(cmt)\n return self\n end",
"def destroy\n comment = Comment.find(params[:id])\n if current_user.id == comment.user_id\n post = comment.post\n post.data['comments'] = post.data['comments'] - 1\n if comment.destroy && post.save\n render json: {status: \"success\", data: {id: Integer(params[:id]), comments: post.data['comments']}}, status: :ok\n else\n render json: {status: \"failure\", data: nil}, status: 404\n end\n\n else\n render json: {status: \"failure\", data: nil}, status: 404\n end\n end",
"def destroy\n @comment = Comment.destroy(params[:id])\n end",
"def destroy\n @comment = Comment.destroy(params[:id])\n end",
"def remove_comment comment\n return if @comments.empty?\n\n case @comments\n when Array then\n @comments.delete_if do |my_comment|\n my_comment.file == comment.file\n end\n when RDoc::Markup::Document then\n @comments.parts.delete_if do |document|\n document.file == comment.file.name\n end\n else\n raise RDoc::Error, \"BUG: unknown comment class #{@comments.class}\"\n end\n end",
"def delete_comment_with_prefix(issue_id, repo, comment_prefix, comments=nil)\n comment = get_comment_with_prefix(issue_id, repo, comment_prefix, comments)\n if comment && comments\n comments.delete_if { |c| c['id'] == comment['id'] }\n end\n delete_comment(comment['id'], repo) if comment\n return comment\n end",
"def destroy\n @comment.destroy\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n end",
"def destroy\n @comment.destroy!\n head :no_content\n end",
"def delete_comment(comment_id)\n options = { :comment_id => comment_id }\n post('/delete_comment', options)\n end",
"def delete_comment(id)\n record \"/msg/delete_comment/#{id}\"\n end",
"def delete_comments\n end",
"def delete_comment\n @comment=Comment.find(params[:comment_id])\n @comment.destroy\n end",
"def delete(gist_id, comment_id, params={})\n normalize! params\n assert_presence_of comment_id\n # _merge_mime_type(:gist_comment, params)\n\n delete_request(\"/gists/#{gist_id}/comments/#{comment_id}\", params)\n end",
"def destroy\n @comment.destroy\n head :no_content\n end",
"def destroy\n @comment.destroy\n head :no_content\n end",
"def destroy\n if @commentable.comments.find(params[:id]).destroy\n render json: { success: true }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n redirect_to comments_url, :message => 'Comment deleted.'\n end",
"def delete_comment(article_id, id)\n delete \"articles/#{article_id}/comments/#{id}\"\n end",
"def delete_comment(permlink)\n @operations << {\n type: :delete_comment,\n author: account_name,\n permlink: permlink\n }\n \n self\n end",
"def destroy\n hack = @comment.hack\n @comment.destroy\n redirect_to hack_path(hack.id)\n end",
"def destroy\n\t\t@comment = current_user.\n\t\t\tprojects.find(params[:project_id]).\n\t\t\ttasks.find(params[:task_id]).\n\t\t\tcomments.find(params[:id]).destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def delete_comment\n Jhead.call(\"-dc\", @match, @pattern)\n end",
"def delete_comment\n comment = Admin::QueueItemComment.find_by_id(params['comment_id'])\n raise ArgumentError.new( 'Could not find this comment.') if comment.nil?\n if can?(:destroy, comment)\n comment.delete\n notice = 'Comment deleted.'\n else\n notice = 'You may not delete this comment.'\n end\n redirect_to @admin_digitization_queue_item,\n notice: notice\n end",
"def destroy\n @comment = @commentable.comments.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\n\t\t#find the post in question\n\t\t@post = Post.find(params[:post_id])\n\t\t\n\t\t#locate the comment in question within the @post.comments collection\n\t\t@comment = @post.comments.find(params[:id])\n\t\t\n\t\t#remove comment from the database\n\t\t@comment.destroy\n\t\t\n\t\t#send user back to original post\n\t\tredirect_to post_path(@post)\n\tend",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { render :nothing => true }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project_comment = ProjectComment.find(params[:id])\n @project_comment.destroy\n\n respond_to do |format|\n format.html { redirect_to project_comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy_comment\n @comment = Comment.find(params[:id])\n @comment.destroy\n \n respond_to do |format|\n flash[:notice] = 'Comment was successfully deleted.'\n format.html { redirect_to(:back) }\n format.xml { head :ok }\n end\n end",
"def leave_failure_comment\n most_recent_comment = @pull_request.comments.last || Curry::PullRequestComment.new\n potential_comment = @pull_request.comments.new(\n unauthorized_commit_authors: unauthorized_commit_emails_and_logins\n )\n\n if potential_comment.mentioned_commit_authors != most_recent_comment.mentioned_commit_authors\n @octokit.add_comment(\n @repository.full_name,\n @pull_request.number,\n failure_message\n ).tap do |comment|\n potential_comment.github_id = comment.id\n potential_comment.save!\n end\n else\n most_recent_comment.touch\n end\n end",
"def destroy\n @comment_id = params[:commenter]\n if @comment_id.eql? current_user.id.to_s\n @comment.destroy\n redirect_to @issue_path, notice: 'Comment is succesfully destroyed.'\n else\n redirect_to @issue_path, notice: \"This comment wasn't created by you\"\n end\n end",
"def destroy\n @comment = @experiment.comments.find(params[:id])\n @comment.destroy\n\tredirect_to experiment_path(@experiment)\n end",
"def destroy\n Comment.find(params[:id]).destroy\n flash[:success] = 'Comment deleted!'\n redirect_to request.referer || root_url\n end",
"def clear_comment\n @comment = nil\n end",
"def destroy\n @comment = @repository.comments.find(params[:id])\n authorize @comment\n @comment.destroy\n respond_with @comment\n end",
"def destroy\n @fbcomment.destroy\n\n head :no_content\n end",
"def delete_comment user\n edit_comment user, nil\n end",
"def delete_comment(project_id, id_or_key, comment_id, opts = {})\r\n data, _status_code, _headers = delete_comment_with_http_info(project_id, id_or_key, comment_id, opts)\r\n return data\r\n end",
"def delete_media_comment(media_id, comment_id, options = {})\n response = delete(\"media/#{media_id}/comments/#{comment_id}\", options, signature = true)\n response\n end",
"def destroy\n Comment.transaction do\n post = @object.post\n id = @object.id\n @object.destroy\n create_change_log_entry(id)\n respond_to do |format|\n format.html { redirect_to post }\n format.xml { head :ok }\n end\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to project_sprint_user_story_comments_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n unless @comment.present?\n @comment.destroy\n end\n\n respond_to do |format|\n format.html { redirect_to admin_comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project_todo_comment = @project_todo.project_todo_comments.find(params[:id])\n @project_todo_comment.destroy\n respond_to do |format|\n format.html { redirect_to project_project_todo_project_todo_comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_blog_post_comments_url(@comment.post.blog, @comment.post)) }\n format.xml { head :ok }\n end\n end",
"def delete_comment!(permlink); delete_comment(permlink).broadcast!(true); end",
"def delete_comment(post_num_input)\n numbered_comments(post_num_input)\n puts \"Which comment would you like to delete? (Type the corresponding number).\"\n number = gets.chomp.to_i\n array_number = number - 1\n BLOG[post_num_input].comments.delete_at(array_number)\n puts ''\n puts \"Comment number #{number} has been deleted.\"\n show_comments(post_num_input)\n end",
"def unlink_github\n @project = Project.find(params[:project_id])\n Project.delete_hooks(@project) \n @project.github_token = nil\n @project.github_user = nil\n @project.repo_name = nil\n @project.save\n redirect_to boards_project_path(@project)\n end",
"def destroy\n @comment = Comment.find(params[:comment_id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def comment_delete\n @memorial = Memorial.find(params[:id])\n Comment.find(params[:comment]).destroy\n redirect_to :action => \"show\", :id => @memorial\n end",
"def comment_delete\n @memorial = Memorial.find(params[:id])\n Comment.find(params[:comment]).destroy\n redirect_to :action => \"show\", :id => @memorial\n end",
"def destroy_comments\n Comment.where(user_id: id).destroy_all\n end",
"def destroy\n @blog = Blog.find(params[:blog_id])\n @comment = @blog.comments.find(params[:id])\n @comment.destroy\n redirect_to blogs_path\n end",
"def destroy\n if @comment.destroy\n flash[:notice] = t('views.message.destroy.success')\n else\n flash[:alert] = CommentDecorator.flash(@comment, flash)\n end\n redirect_to \"/posts/#{@comment.id}?comments=deleted\"\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @comment.nil?\n render json: {error: \"Not found\"}, status: :not_found\n else\n @comment.destroy\n render json: @comment, status: :ok\n\n end\n end",
"def clean_coverage_comments(client)\n comment_page = 0\n loop do\n comment_page += 1\n cur_page_comment = client.pull_request_comments(REPO, PULL_REQUEST, { :per_page =>100, :page => comment_page })\n if cur_page_comment.length == 0\n break\n end\n for cmt in cur_page_comment do\n # Remove comments when the comment body meets the REMOVE_PATTERN.\n if cmt.body =~ REMOVE_PATTERN\n client.delete_pull_request_comment(REPO,cmt.id)\n end\n end\n end\nend",
"def destroy\n @blog_comment = BlogComment.find(params[:id])\n @blog_comment.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\r\n @comment = Comment.find(params[:id])\r\n @comment.destroy\r\n\r\n redirect_to :back\r\n end",
"def destroy\n @comment.destroy\n flash[:notice] = \"Successfully destroyed comment.\"\n redirect_to reported_comments_path\n end",
"def destroy\n @comment = Comment.find_by(id: params[:id])\n @user = @comment.user\n\n return false unless authorized_user?(@user.id)\n\n if @comment.destroy\n render 'api/comments/destroy.json.jbuilder'\n else\n render json: @comment.errors.full_messages, status: 422\n end\n\n end",
"def destroy\n @comment = BrandComment.find(params[:id])\n @comment.destroy\n\n render :update do |page|\n page.visual_effect :highlight, @comment.dom_id\n page.remove @comment.dom_id\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n redirect_to request_path(@comment.request)\n end",
"def destroy\n @comment = Comment.find(params[:id])\n \t@comment.in_recycling = true\n \n if (can? :delete, @comment)\n \tif @comment.save\n \t\trespond_to do |format|\n \t\t format.html { redirect_to it_category_content_url(@comment.content.category.it, \n \t\t @comment.content.category, @comment.content) }\n \t\t format.json { head :ok }\n \t\tend\n \tend\n \tend\n end",
"def delete_commit_comment(id)\n boolean_from_response :delete, \"training_logs/#{id}\"\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n comment = Comment.find(params[:id])\n if comment.destroy\n render json: {destroyed: true}\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :ok }\n end\n end",
"def delete_comments(name, author = nil, password = nil, folder = nil, storage = nil)\n delete_comments_with_http_info(name, author, password, folder, storage)\n nil\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.7429408",
"0.73979867",
"0.72943497",
"0.72670454",
"0.72373676",
"0.71700996",
"0.71538055",
"0.709939",
"0.70149136",
"0.70120627",
"0.7011715",
"0.6923734",
"0.6894902",
"0.6873935",
"0.68291354",
"0.6713199",
"0.67110544",
"0.664785",
"0.66473407",
"0.6607416",
"0.65296257",
"0.6520211",
"0.6520211",
"0.6495403",
"0.64607877",
"0.6438591",
"0.6429922",
"0.6414804",
"0.6404959",
"0.63873",
"0.63800746",
"0.63581896",
"0.63524556",
"0.63458204",
"0.63458204",
"0.6344981",
"0.6325451",
"0.63231444",
"0.6315479",
"0.63107437",
"0.62548405",
"0.6250053",
"0.6239712",
"0.6235744",
"0.6230936",
"0.62285084",
"0.6213609",
"0.6168094",
"0.61644673",
"0.616263",
"0.6158778",
"0.61541116",
"0.6152709",
"0.6147302",
"0.6145585",
"0.61211866",
"0.61175555",
"0.61170816",
"0.6115729",
"0.6114977",
"0.6101176",
"0.6090836",
"0.6089028",
"0.6078928",
"0.60605776",
"0.605906",
"0.60471314",
"0.6023558",
"0.6023558",
"0.6020747",
"0.60129374",
"0.60111696",
"0.6010865",
"0.6010544",
"0.60087925",
"0.6008557",
"0.60085523",
"0.6008188",
"0.6002523",
"0.6001902",
"0.59917766",
"0.5979772",
"0.5963686",
"0.5963207",
"0.5962188",
"0.5957599",
"0.5957599",
"0.5957599",
"0.59551996",
"0.5953397",
"0.5952354",
"0.5952354",
"0.5952354",
"0.5952354",
"0.5952354",
"0.5952354",
"0.5952354",
"0.5952354",
"0.5952354",
"0.5952354"
] | 0.8985965 | 0 |
Returns head of pull request. Head represents the last SHA1 of the pull request. nil is returned on failure. repo the repo name. Example: owner/repo issue the issue number. Example: 3 | def get_last_sha repo, issue
response = @@connection.get do | request |
request.url "repos/#{repo}/pulls/#{issue}"
request.headers['Authorization'] = "token #{@@token}"
end
return nil if response.env[:status] != 200
body = MultiJson.load(response.env[:body])
return body['head']['sha']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def head\n git.get_head(branch)\n end",
"def head\n git.get_head(branch)\n end",
"def head_path\n \"#{path}/refs/heads/#{branch}\"\n end",
"def getHeadTag\n head_commit_id = @gop.revparse(\"HEAD\")\n\n begin\n @gop.describe(head_commit_id, :contains => true)\n rescue Git::GitExecuteError => giterror\n # do nothing, continue\n end\n end",
"def pr_has_head_repo(req)\n not req['head']['repo'].nil?\n end",
"def head(uuid, repo_uuid = @uuid)\n @tc_heads.get(uuid + repo_uuid)\n end",
"def head_path\n \"#{git_path}/refs/heads/#{branch}\"\n end",
"def pr_log_msg(req)\n head = if pr_has_head_repo(req)\n req['head']['repo']['full_name']\n else\n '(head deleted)'\n end\n\n <<-eos.gsub(/\\s+/, ' ').strip\n pull_req #{req['number']}\n #{head} -> #{req['base']['repo']['full_name']}\n eos\n end",
"def head\n \"HEAD\"\n end",
"def head\n \"HEAD\"\n end",
"def get_head(project)\n get(\"/projects/#{project}/HEAD\")\n end",
"def read_head_id\n if File.exists?(head_path)\n File.read(head_path).strip\n elsif File.exists?(\"#{path}/packed-refs\")\n File.open(\"#{path}/packed-refs\", 'rb') do |io|\n while line = io.gets\n line.strip!\n next if line[0..0] == '#'\n line = line.split(' ')\n return line[0] if line[1] == \"refs/heads/#{branch}\"\n end\n end\n end\n end",
"def get_master_head_sha(oauth_token)\n client = Octokit::Client.new(access_token: oauth_token)\n client.ref(full_repo_name, 'heads/master')[:object][:sha]\n end",
"def current\n R10K::Git::Head.new('HEAD', self)\n end",
"def head\n options, subprocess_options = self.options\n options.unshift(\"-I\")\n options << @source\n\n @logger.info(\"HEAD: #{@source}\")\n result = execute_curl(options, subprocess_options)\n result.stdout\n end",
"def first_commit\n\tcommit = nil\n\tresp = github_api(\"commits\")\n\tsha = resp[-1][\"commit\"][\"sha\"]\n\twhile true\n\t\tr = github_api(\"commits?sha=#{sha}&per_page=100\")\n\t\tif r.count != 1 \n\t\t\tsha = r[-1][\"sha\"]\n\t\t\tnext\n\t\tend\n\t\tcommit = r[0]\n\t\tbreak\n\tend\n\tcommit\nend",
"def find_github_issue\n\n issue = github.branch_for_head.match(/(issue\\/\\d+)/)\n if issue\n return issue[1]\n end\n\nend",
"def pull_requests repo\n name = full_name repo\n \n %w[open closed].reduce([]) do |memo, state|\n memo | octokit.pulls(name, state, :per_page=>100)\n end\n end",
"def git_HEAD\n Dir.chdir(@dir) do\n commit = `git rev-parse HEAD`\n raise \"git rev-parse HEAD failed: #{$?.exitstatus}\" if $?.exitstatus != 0\n commit.chomp\n end\n end",
"def get_repo\n raise \"can't get a repo without the repo's full_name (eg. 'fubar/ofxTrickyTrick')\" unless full_name\n\n begin\n response = GithubApi::repository(full_name: full_name)\n rescue => ex\n Rails.logger.debug \"Failed to get repository: #{ex.message} (#{ex.class})\"\n return\n end\n\n unless response.success?\n Rails.logger.debug response.inspect.to_s.red\n return\n\tend\n\n @repo_json = response.parsed_response\n end",
"def get_repo\n repos = get_repos\n unless repos.size == 1\n fail Error.new('unexpected that number of matching repos is not equal to 1')\n end\n\n repos.first\n end",
"def same_repo_pull_request?\n payload = Hashr.new(self.payload)\n\n pull_request = payload.pull_request\n return false unless pull_request\n\n head = pull_request.head\n base = pull_request.base\n return false if head.nil? or base.nil?\n\n base_repo = base.repo.try(:full_name)\n head_repo = head.repo.try(:full_name)\n return false if base_repo.nil? or base_repo.nil?\n return false if head.sha.nil? or head.ref.nil?\n\n # it's not the same repo PR if repo names don't match\n return false if head_repo != base_repo\n\n # it may not be same repo PR if ref is a commit\n return false if head.sha =~ /^#{Regexp.escape(head.ref)}/\n\n true\n rescue => e\n Travis::Scheduler.logger.error \"[request:#{id}] Couldn't determine whether pull request is from the same repository: #{e.message}\"\n false\n end",
"def create_pull_request_for_issue(repo, base, head, issue, options = {})\n pull = {\n :base => base,\n :head => head,\n :issue => issue\n }\n post \"#{Repository.path repo}/pulls\", options.merge(pull)\n end",
"def repository\n @repository ||= Github::Repository.find user: user, name: name\n end",
"def fetch_repository(payload)\n repo_path = repository_path(payload)\n if(File.directory?(repo_path))\n debug \"Pulling changes to: #{repo_path}\"\n repo = Git.open(repo_path)\n repo.checkout('master')\n repo.pull\n repo.fetch\n else\n debug \"Initiating repository clone to: #{repo_path}\"\n Git.clone(github_url(payload), repo_path)\n end\n repo_path\n end",
"def head\n nil\n end",
"def get_base_tree_for_branch(oauth_token, head_sha)\n client = Octokit::Client.new(access_token: oauth_token)\n client.commit(full_repo_name, head_sha)[:commit][:tree][:sha]\n end",
"def pull_request(_input)\n puts 'TODO: Implement Git.pull_request'\n # TODO: Validate input\n # input[:issue].to_s\n # input[:base_branch].to_s\n end",
"def show\n @gitHubRepo = GitHubRepo.where(:id => @git_hub_issue.repo_id).first.repo\n end",
"def pull_requests_for_branch(repo, branch)\n head_name = \"#{repo.split('/').first}:#{branch}\"\n github_api_request \"GET\", \"repos/#{repo}/pulls?head=#{head_name}\"\n end",
"def http_head\n return @head if defined?(@head)\n begin\n @head = conn.request(http_request(:head, resource[:source]))\n fail \"#{resource[:http_verb].to_s.upcase} #{resource[:source]} \" +\n \"returned #{@head.code}\" unless @head.code == '200'\n rescue Exception => e\n fail \"Failed to fetch file: #{resource[:source]} - #{e.message}\"\n end\n @head\n end",
"def repo_name\n return unless @url\n @repo_name ||= Octokit::Repository.from_url(@url).to_s.chomp('.git')\n end",
"def same_repo_pull_request?\n # When we're starting to archive payloads after N months we'll also disallow\n # restarting builds older than N months. Once we do so we can also return\n # false if Scheduler.config.enterprise is not true.\n\n # It's not the same repo PR if repo names don't match\n return false if head_repo_vcs_id != repository.vcs_id\n # It may not be the same repo if head_ref or head_sha are missing\n return false if head_ref.nil? or head_sha.nil?\n # It may not be same repo PR if ref is a commit\n return false if head_sha =~ /^#{Regexp.escape(head_ref)}/\n true\n rescue => e\n Travis::Scheduler.logger.error \"[request:#{id}] Couldn't determine whether pull request is from the same repository: #{e.message}\"\n false\n end",
"def parse_repo\n matches = @source_url.match @github_regexp\n return unless matches\n owner = matches[:owner]\n name = matches[:name]\n \"#{owner}/#{name}\"\n end",
"def create_pull_request(repo, base, head, title, body = nil, options = {})\n pull = {\n :base => base,\n :head => head,\n :title => title,\n }\n pull[:body] = body unless body.nil?\n post \"#{Repository.path repo}/pulls\", options.merge(pull)\n end",
"def get_head\n raise \"Not implemented\"\n end",
"def branch(tag=@current_branch)\n get_head(tag)\n end",
"def first_response(pr)\n q = <<-QUERY\n select min(created) as first_resp from (\n select min(prc.created_at) as created\n from pull_request_comments prc, users u\n where prc.pull_request_id = ?\n and u.id = prc.user_id\n and u.login not in ('travis-ci', 'cloudbees')\n and prc.created_at < (\n select max(created_at)\n from pull_request_history\n where action = 'closed' and pull_request_id = ?)\n union\n select min(ic.created_at) as created\n from issues i, issue_comments ic, users u\n where i.pull_request_id = ?\n and i.id = ic.issue_id\n and u.id = ic.user_id\n and u.login not in ('travis-ci', 'cloudbees')\n and ic.created_at < (\n select max(created_at)\n from pull_request_history\n where action = 'closed' and pull_request_id = ?)\n ) as a;\n QUERY\n resp = db.fetch(q, pr[:id], pr[:id], pr[:id], pr[:id]).first[:first_resp]\n unless resp.nil?\n (resp - pr[:created_at]).to_i / 60\n else\n -1\n end\n end",
"def fork_repo(src)\n response = HTTParty.post(\n GIT_BASE_URL + 'projects/fork/' + src.to_s,\n :headers => {\n 'PRIVATE-TOKEN' => self.git_token\n }\n )\n Rails.logger.info \"Git server response (fork repo): #{response}\"\n if response.has_key? 'id'\n return response['id']\n end\n -1\n end",
"def create_pull(repo, title, head, base, options = {})\n opts = options.dup\n opts[:title] = title\n opts[:head] = head\n opts[:base] = base\n post \"#{Repository.path repo}/pulls\", opts\n end",
"def base_sha\n default_branch = client.repo(repo)[:default_branch]\n branches.find { |branch| branch[:name] == default_branch }[:commit][:sha]\n end",
"def determine_branch_name(repo)\n name = \"\"\n repo.branches.each do |branch|\n if branch.head?\n name = branch.name\n break\n end\n end\n return name\nend",
"def head\n @head\n end",
"def head_commit_sha\n if persisted? && super.nil?\n last_commit_sha\n else\n super\n end\n end",
"def get_Head()\n return @head\n end",
"def gh_pull_request(data, config)\n action = data['action'] || nil\n pr = data['pull_request'] || nil\n\n Cyclid.logger.debug \"action=#{action}\"\n return true unless action == 'opened' \\\n or action == 'reopened' \\\n or action == 'synchronize'\n\n # Get the list of files in the root of the repository in the\n # Pull Request branch\n html_url = URI(pr['base']['repo']['html_url'])\n pr_sha = pr['head']['sha']\n ref = pr['head']['ref']\n\n Cyclid.logger.debug \"sha=#{pr_sha} ref=#{ref}\"\n\n # Get some useful endpoints & interpolate the SHA for this PR\n url = pr['head']['repo']['statuses_url']\n statuses = url.gsub('{sha}', pr_sha)\n\n url = pr['head']['repo']['trees_url']\n trees = url.gsub('{/sha}', \"/#{pr_sha}\")\n\n # Get an OAuth token, if one is set for this repo\n Cyclid.logger.debug \"attempting to find auth token for #{html_url}\"\n auth_token = nil\n config['repository_tokens'].each do |entry|\n entry_url = URI(entry['url'])\n auth_token = entry['token'] if entry_url.host == html_url.host && \\\n entry_url.path == html_url.path\n end\n\n # XXX We probably don't want to be logging auth tokens in plain text\n Cyclid.logger.debug \"auth token=#{auth_token}\"\n\n # Set the PR to 'pending'\n GithubStatus.set_status(statuses, auth_token, 'pending', 'Preparing build')\n\n # Get the Pull Request\n begin\n trees_url = URI(trees)\n Cyclid.logger.debug \"Getting root for #{trees_url}\"\n\n request = Net::HTTP::Get.new(trees_url)\n request.add_field('Authorization', \"token #{auth_token}\") \\\n unless auth_token.nil?\n\n http = Net::HTTP.new(trees_url.hostname, trees_url.port)\n http.use_ssl = (trees_url.scheme == 'https')\n response = http.request(request)\n\n Cyclid.logger.debug response.inspect\n raise \"couldn't get repository root\" \\\n unless response.code == '200'\n\n root = Oj.load response.body\n rescue StandardError => ex\n Cyclid.logger.error \"failed to retrieve Pull Request root: #{ex}\"\n return_failure(500, 'could not retrieve Pull Request root')\n end\n\n # See if a .cyclid.yml or .cyclid.json file exists in the project\n # root\n job_url = nil\n job_type = nil\n root['tree'].each do |file|\n match = file['path'].match(/\\A\\.cyclid\\.(json|yml)\\z/)\n next unless match\n\n job_url = URI(file['url'])\n job_type = match[1]\n end\n\n Cyclid.logger.debug \"job_url=#{job_url}\"\n\n if job_url.nil?\n GithubStatus.set_status(statuses, auth_token, 'error', 'No Cyclid job file found')\n return_failure(400, 'not a Cyclid repository')\n end\n\n # Pull down the job file\n begin\n Cyclid.logger.info \"Retrieving PR job from #{job_url}\"\n\n request = Net::HTTP::Get.new(job_url)\n request.add_field('Authorization', \"token #{auth_token}\") \\\n unless auth_token.nil?\n\n http = Net::HTTP.new(job_url.hostname, job_url.port)\n http.use_ssl = (job_url.scheme == 'https')\n response = http.request(request)\n raise \"couldn't get Cyclid job\" unless response.code == '200'\n\n job_blob = Oj.load response.body\n case job_type\n when 'json'\n job_definition = Oj.load(Base64.decode64(job_blob['content']))\n when 'yml'\n job_definition = YAML.load(Base64.decode64(job_blob['content']))\n end\n\n # Insert this repository & branch into the sources\n #\n # XXX Could this cause collisions between the existing sources in\n # the job definition? Not entirely sure what the workflow will\n # look like.\n job_sources = job_definition['sources'] || []\n job_sources << { 'type' => 'git',\n 'url' => html_url.to_s,\n 'branch' => ref,\n 'token' => auth_token }\n job_definition['sources'] = job_sources\n\n Cyclid.logger.debug \"sources=#{job_definition['sources']}\"\n rescue StandardError => ex\n GithubStatus.set_status(statuses,\n auth_token,\n 'error',\n \"Couldn't retrieve Cyclid job file\")\n Cyclid.logger.error \"failed to retrieve Github Pull Request job: #{ex}\"\n raise\n end\n\n Cyclid.logger.debug \"job_definition=#{job_definition}\"\n\n begin\n callback = GithubCallback.new(statuses, auth_token)\n job_from_definition(job_definition, callback)\n rescue StandardError => ex\n GithubStatus.set_status(statuses, auth_token, 'failure', ex)\n return_failure(500, 'job failed')\n end\n end",
"def github_repo_name path\n origin = remote_origin_url path\n\n if origin == \"\"\n raise NotGitHubRepo.new \"No remote origin URL: #{path}\"\n end\n\n clone_url = parse_url origin\n\n if clone_url.host.downcase != \"github.com\"\n raise NotGitHubRepo.new \"Not a GitHub repo: #{path}\"\n end\n\n chop_extension chop_leading_slash clone_url.path\n end",
"def commit\n\t$VP.join('.git/refs/heads/master').read[0..8] rescue nil\nend",
"def repo_commits(repos)\n repos_commits = []\n repos.each do |repo|\n repos_commits << HTTParty.get(repo[\"commits_url\"].gsub(\"{/sha}\", \"\"))[0]\n end\n repos_commits\nend",
"def branch\n 'refs/heads/master'\nend",
"def github_repo\n # GitHub allows underscores, hyphens and dots in repo names\n # but only hyphens in user/organisation names (as well as alphanumeric).\n repository_url.scan(/:([A-Za-z0-9-]+\\/[\\w.-]+)\\.git$/).join\n end",
"def fetch\n return nil if !repo || !user\n if fetched?\n pull\n else\n clone\n end\n end",
"def git_source\n `git remote -v`.\n split(/\\n/).\n map(&:chomp).\n map { |s| s.split(/\\t/)[1].split(/ /)[0] }.\n first\n end",
"def branch\n %x[cd #{repo_path};git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'}].chomp\n end",
"def head\n return @head\n end",
"def get_tree_sha\n sha = nil\n trees = open('https://api.github.com/repos/twitter/bootstrap/git/trees/master').read\n trees = JSON.parse trees\n trees['tree'].find{|t| t['path'] == 'less'}['sha']\n end",
"def github_repo\n self.github_url&.gsub(\"https://github.com/\", \"\")\n end",
"def from_commit_sha\n from_sha = nil\n last_commit = nil\n ActiveRecord::Base.connection_pool.with_connection do \n last_commit = RepoCommit.where(supplier_project_repo_id: @repo.id).order(:full_date).first\n end\n from_sha = last_commit.sha if last_commit\n end",
"def repository repoid\n @repos[repoid] or raise \"unknown repository #{repoid.inspect}\"\n end",
"def get_repo_name(repo_id)\n repo_name = client.repository(repo_id).name\n rescue Octokit::NotFound\n \"not available\"\n end",
"def get_my_pull_requests\n repos_to_get = GITHUB_REPOS.kind_of?( Array ) ? GITHUB_REPOS : get_my_repos\n\n repos_to_get.each do |repo|\n status = []\n pulls_url = \"#{ GITHUB_REPOS_URL }/#{ repo }/pulls?state=open\"\n\n get_json( pulls_url ).each_with_index do |item, index|\n sha = item[ 'head' ][ 'sha' ]\n status_url = \"#{ GITHUB_REPOS_URL }/#{ repo }/commits/#{ sha }/status\"\n\n status << get_json( status_url )\n\n unless item[ 'assignee' ].nil?\n if item[ 'assignee' ][ 'login' ] == ENV[ 'GITHUB_USERNAME' ]\n color = ''\n state = status[ index ][ 'state' ]\n\n unless status[ index ][ 'statuses' ].empty?\n color = \"| color=#{ determine_status_color( state )}\"\n end\n\n puts \"#{ repo }: ##{ item[ 'number' ] } #{ item[ 'title' ] } #{ color } | href=#{ item[ 'html_url' ] }\"\n end\n end\n end\n end\nend",
"def repo_github_path\n descrip = %x{git remote -v}.match(/^.+git@github\\.com:(.+\\/.+)\\.git/)\n raise \"Could not find a Github remote\" if descrip.nil?\n descrip[1]\n end",
"def head\n self.class.head(url)\n end",
"def get_pull_request(repo_full_name, pull_request_id)\n @client.pull_request(repo_full_name, pull_request_id)\n end",
"def safe_start_commit_sha\n start_commit_sha || merge_request.target_branch_sha\n end",
"def source_branch\n @client.branch(repo, options[:source]).commit.sha\n end",
"def repo\n read_attribute(:repo).presence || self.original_repo\n end",
"def single_pull_request(repo, pull_request_number)\n response = self.class.get(\"/repos/#{owner}/#{repo}/pulls/#{pull_request_number}\", options)\n\n return_value_for response\n end",
"def git\n # log \"Thread.current[:repo] nil? \" + Thread.current[:repo].nil?.to_s\n Thread.current[:repo] ||= clone(ARGV[0], ARGV[1])\n Thread.current[:repo]\n end",
"def default_branch\n @default_branch ||= Nokogiri::HTML(open(branches_url)).at_css('tr.base td.name h3').text.strip.chomp\n rescue OpenURI::HTTPError => err\n raise GithubMetadata::RepoNotFound, err.to_s\n end",
"def head\n\t\t@head\n\tend",
"def head\n return nil if @head.nil?\n @head.data\n end",
"def http_head(uri)\n http(uri, :http_method => 'head')\n end",
"def fetch_sha(source_repository, sha)\n source_repository = RemoteRepository.new(source_repository) unless source_repository.is_a?(RemoteRepository)\n\n env = source_repository.fetch_env(git_config_options: [GIT_ALLOW_SHA_UPLOAD])\n\n args = %W[fetch --no-tags #{GITALY_INTERNAL_URL} #{sha}]\n message, status = run_git(args, env: env, include_stderr: true)\n raise Gitlab::Git::CommandError, message unless status.zero?\n\n sha\n end",
"def pull_request(repo, number, options = {})\n get \"#{Repository.path repo}/pulls/#{number}\", options\n end",
"def fetch_github_information\n self.associated_commit_shas = []\n self.branch_name = nil\n self.username = nil\n\n return if self.dev_build\n\n GithubService.run(self.project.github_root_url, self.project.github_repo) do |service|\n if self.is_branch_build\n self.associated_commit_shas = service.github_commits(10, self.commit_sha)\n self.branch_name = nil\n self.username = nil\n else\n self.associated_commit_shas = []\n info = service.user_and_branch_for_pull_request(self.pull_request_number)\n self.username = info[:user]\n self.branch_name = info[:branch]\n end\n end\n end",
"def head(request)\n do_request(request) { |client| client.http_head }\n end",
"def get_pull_number(payload)\n if payload[:pull_request]\n return payload[:pull_request][:number]\n elsif payload[:issue]\n return payload[:issue][:number]\n elsif payload[:comment][:pull_request_url]\n return payload[:comment][:pull_request_url].split('/')[-1]\n else\n return nil\n end\n end",
"def head\n\t\treturn @head\n\tend",
"def first_committed_commit\n get_all_commits_in_repo.last\n end",
"def HEAD()\n self.class.open @dir, \"HEAD\"\n end",
"def status_image pull_request\n pull_request.html_url.sub \"github.com\", \"pullstat.us\"\n end",
"def path_to_sha(path, head=@current_branch)\n # Return the root of the repo if no path is specified\n return root_sha(head) if (not path) || (path.empty?)\n\n if staging?\n @staging_index.sync\n head = @staging_index.current_tree.id\n end\n\n dir = tree(head, [path])\n (dir && dir.contents.length > 0) ? dir.contents.first.id : nil\n end",
"def determine_branch_or_tag_name(repo)\n name = \"\"\n type = :none\n\n # first check if repo is in detached HEAD state\n if repo.head_detached?\n # check if current commit has a tag\n repo.tags.each do |tag|\n if tag.target.oid == repo.head.target_id\n name = tag.name\n type = :tag\n break\n end\n end\n\n # check if we got a tag name, otherwise it's a wild commit\n if type == :none\n name = repo.head.target_id[0..7]\n type = :commit\n end\n else\n # HEAD is not detached, so we are in a branch\n name = $branch_name\n type = :branch\n end\n\n return { name: name, type: type }\nend",
"def set_head(project, branch)\n url = \"/projects/#{project}/HEAD\"\n body = {\n ref: 'refs/heads/' + branch\n }\n put(url, body)\n end",
"def ensure_pull_request(owner, repo, pullreq_id,\n comments = true, commits = true, history = true,\n state = nil, actor = nil, created_at = nil)\n pulls_reqs = db[:pull_requests]\n\n project = ensure_repo(owner, repo)\n\n if project.nil?\n warn \"Could not find repo #{owner}/#{repo} for retrieving pull request #{pullreq_id}\"\n return\n end\n\n retrieved = retrieve_pull_request(owner, repo, pullreq_id)\n\n if retrieved.nil?\n warn \"Could not retrieve pull_req #{owner}/#{repo} -> #{pullreq_id}\"\n return\n end\n\n base_repo = ensure_repo(retrieved['base']['repo']['owner']['login'],\n retrieved['base']['repo']['name'])\n\n base_commit = ensure_commit(retrieved['base']['repo']['name'],\n retrieved['base']['sha'],\n retrieved['base']['repo']['owner']['login'])\n\n if pr_is_intra_branch(retrieved)\n head_repo = base_repo\n head_commit = ensure_commit(retrieved['base']['repo']['name'],\n retrieved['head']['sha'],\n retrieved['base']['repo']['owner']['login'])\n debug pr_log_msg(retrieved) + ' is intra-branch'\n else\n head_repo = if pr_has_head_repo(retrieved)\n ensure_repo(retrieved['head']['repo']['owner']['login'],\n retrieved['head']['repo']['name'])\n end\n\n head_commit = if not head_repo.nil?\n ensure_commit(retrieved['head']['repo']['name'],\n retrieved['head']['sha'],\n retrieved['head']['repo']['owner']['login'])\n end\n end\n\n pull_req_user = ensure_user(retrieved['user']['login'], false, false)\n\n merged = if retrieved['merged_at'].nil? then false else true end\n closed = if retrieved['closed_at'].nil? then false else true end\n\n pull_req = pulls_reqs.first(:base_repo_id => project[:id],\n :pullreq_id => pullreq_id)\n if pull_req.nil?\n pulls_reqs.insert(\n :head_repo_id => if not head_repo.nil? then head_repo[:id] end,\n :base_repo_id => if not base_repo.nil? then base_repo[:id] end,\n :head_commit_id => if not head_commit.nil? then head_commit[:id] end,\n :base_commit_id => if not base_commit.nil? then base_commit[:id] end,\n :pullreq_id => pullreq_id,\n :intra_branch => pr_is_intra_branch(retrieved)\n )\n info 'Added ' + pr_log_msg(retrieved)\n else\n debug pr_log_msg(retrieved) + ' exists'\n end\n\n pull_req = pulls_reqs.first(:base_repo_id => project[:id],\n :pullreq_id => pullreq_id)\n\n # Add a fake (or not so fake) issue in the issues table to serve\n # as root for retrieving discussion comments for this pull request\n issues = db[:issues]\n issue = issues.first(:pull_request_id => pull_req[:id])\n\n if issue.nil?\n issues.insert(:repo_id => base_repo[:id],\n :assignee_id => nil,\n :reporter_id => nil,\n :issue_id => pullreq_id,\n :pull_request => true,\n :pull_request_id => pull_req[:id],\n :created_at => date(retrieved['created_at']))\n debug 'Added accompanying_issue for ' + pr_log_msg(retrieved)\n else\n debug 'Accompanying issue for ' + pr_log_msg(retrieved) + ' exists'\n end\n\n if history\n # Actions on pull requests\n opener = pull_req_user[:login]\n ensure_pull_request_history(pull_req[:id], date(retrieved['created_at']),\n 'opened', opener)\n\n merger = if retrieved['merged_by'].nil? then actor else retrieved['merged_by']['login'] end\n ensure_pull_request_history(pull_req[:id], date(retrieved['merged_at']),\n 'merged', merger) if (merged && state != 'merged')\n\n closer = if merged then merger else actor end\n ensure_pull_request_history(pull_req[:id], date(retrieved['closed_at']),\n 'closed', closer) if (closed && state != 'closed')\n ensure_pull_request_history(pull_req[:id], date(created_at), state, actor) unless state.nil?\n end\n ensure_pull_request_commits(owner, repo, pullreq_id, pull_req, retrieved) if commits\n ensure_pullreq_comments(owner, repo, pullreq_id, pull_req) if comments\n ensure_issue_comments(owner, repo, pullreq_id, pull_req[:id]) if comments\n\n pull_req\n end",
"def getGitRepo config\n\tworkingDir = config[\"workingDir\"]\n\tbranch = config[\"git\"][\"branch\"]\n\trepository = config[\"git\"][\"repository\"]\n\t\n\t# when working directory does not exist, create it and clone the repository\n\t# otherwise just pull changes\n\tif not Dir.exists? workingDir then\n\t\tDir.mkdir workingDir\n\t\tg = Git.clone(repository, branch, :path => workingDir)\n\t\tlatestCommit = g.log.last\n\telse\n\t\tg = Git.open(workingDir + \"/\" + branch)\n\t\tg.pull\n\t\tlatestCommit = g.log.last\n\tend\n\t\n\treturn latestCommit\nend",
"def head(path,headers={})\n request(:head,path,headers)\n end",
"def repository(uri, client)\n repo = client.repo uri\n repo\n rescue Octokit::InvalidRepository\n raise gem.to_s + ' didnt have github repo'\n end",
"def head(options = nil)\n options ||= {}\n options[:method] = :head\n call options\n end",
"def get_master_ref(papers)\n github_client.refs(papers).select { |r| r[:ref] == \"refs/heads/master\" }.first.object.sha\n end",
"def determine_submodule_sha\n stdout.out_success \"\\nFirst, I'll determine the sha for the HEAD of branch: '#{settings['target_submodule_target_branch']}' for the submodule to be updated.\"\n stdout.out_success 'With that known, I can determine if a given repo is \"Up to Date\" for that particular submodule.'\n submodule_head_sha = get_sha_for_branch_origin_head\n stdout.out_success(\"\\nDetermined [#{settings['target_submodule_name']}]'s branch [#{settings['target_submodule_target_branch']}]'s HEAD sha to be: #{submodule_head_sha}\")\n submodule_head_sha\n end",
"def oldest_for(issues_or_pulls)\n return nil if issues_or_pulls.empty?\n\n sort_iops_by_created_at(issues_or_pulls).first\n end",
"def head(path, headers = {})\n request(:head, path, build_request_headers(headers, :head))\n end",
"def get_branch_sha\n cmd = \"git ls-remote '#@repo_url' | awk '/#@branch/ {print $1}'\"\n puts cmd\n @branch_sha ||= %x[#{cmd}].chomp\n raise 'Could not get branch sha!' unless $?.success?\n @branch_sha\n end",
"def current_branch\n repo.branches.find(&:head?)\n end",
"def url\n \"http://github.com/#{repo.owner.login}/#{repo.name}/#{name}\"\n end",
"def git_sha(length = 40)\n Pkg::Util.in_project_root do\n stdout, _, _ = Pkg::Util::Execution.capture3(\"#{GIT} rev-parse --short=#{length} HEAD\")\n stdout.strip\n end\n end",
"def read_head_id\n File.read(head_path).strip if File.exists?(head_path)\n end",
"def update(state = 'open')\n @current_requests = @github.pull_requests(source_repo, state)\n repos = @current_requests.collect do |request|\n repo = request.head.repository\n \"#{repo.owner}/#{repo.name}\" if repo\n end\n repos.uniq.compact.each do |rep|\n git_call \"fetch git@github.com:#{rep}.git +refs/heads/*:refs/pr/#{rep}/*\"\n end\n end"
] | [
"0.69913304",
"0.69913304",
"0.6551737",
"0.6510847",
"0.6499988",
"0.6362922",
"0.63157475",
"0.620106",
"0.6129432",
"0.6128853",
"0.6098599",
"0.6092042",
"0.59948915",
"0.5931964",
"0.5805091",
"0.5797808",
"0.5781474",
"0.5738283",
"0.5711827",
"0.5678033",
"0.56583184",
"0.56361324",
"0.56156015",
"0.5597763",
"0.55611914",
"0.5535673",
"0.55333894",
"0.5529621",
"0.55228114",
"0.5518086",
"0.5504947",
"0.54935724",
"0.54862857",
"0.5481421",
"0.54715794",
"0.5460254",
"0.545463",
"0.5450487",
"0.5444486",
"0.54402596",
"0.54300034",
"0.5429395",
"0.54241115",
"0.54219973",
"0.5413208",
"0.5411186",
"0.53905827",
"0.537192",
"0.5366049",
"0.53639394",
"0.5360216",
"0.5347204",
"0.53262806",
"0.53209895",
"0.5300922",
"0.5292814",
"0.528572",
"0.5285096",
"0.52783877",
"0.52728593",
"0.5254033",
"0.5242873",
"0.52399725",
"0.5238411",
"0.5235698",
"0.52310836",
"0.5229537",
"0.52283406",
"0.5218239",
"0.52159834",
"0.5211065",
"0.5208048",
"0.5203973",
"0.5202804",
"0.52007496",
"0.51873326",
"0.51834357",
"0.51767474",
"0.51739824",
"0.5168004",
"0.5167883",
"0.51660067",
"0.5161829",
"0.5157443",
"0.51571447",
"0.51566374",
"0.51491016",
"0.514897",
"0.5148464",
"0.51463807",
"0.5142176",
"0.5139358",
"0.51388747",
"0.51378673",
"0.5133431",
"0.5130465",
"0.5121659",
"0.511654",
"0.5114589",
"0.51144016"
] | 0.68978834 | 2 |
2. I can find a list of exercises I did on a day | def exercise_on_a_day(date)
#iterate through workouts and find workouts.user_id == self
my_workouts = Workout.all.select do |workout|
workout["user_id"] == self["id"]
end
# find where date == workout date
workouts_for_date = my_workouts.find_all do |workouts|
workouts["date"] == date
end.map {|workout_instance| workout_instance.exercise_id}
exercise_array = []
exercise_list = workouts_for_date.each do |exercise_id|
Exercise.all.each do |exercise_instances|
exercise_array << exercise_instances.name if (exercise_instances.id == exercise_id)
end
end
if exercise_array == []
return "Sorry. Doesn't look like you worked out on #{date}.".colorize(:light_cyan)
else
return exercise_array
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_exercises_list\n exercises_list = []\n inst_sections.each do |inst_section|\n exercises_ids = inst_section.inst_book_section_exercises.collect(&:inst_exercise_id).compact\n exercises_objs = InstExercise.where(id: exercises_ids)\n exercises_list.concat exercises_objs.collect(&:short_name)\n end\n return exercises_list\n end",
"def exercises\n ids = self.exercise_records.pluck(:exercise_id)\n Exercise.where(id: ids)\n end",
"def index\n @user = User.find(params[:user_id])\n @exercises = @user.exercises.all\n end",
"def index\n @performed_exercises = PerformedExercise.all.order(done_on: :desc)\n end",
"def index\n @programme_exercises = ProgrammeExercise.all\n end",
"def index\n @oncourse_exercises = OncourseExercise.all\n\n\n\n end",
"def index\n @user = User.find(current_user.id)\n @exercises = Exercise.all\n end",
"def index\n @exercises = Exercise.where(published: true).all\n @user_exercises = current_user.exercises.all\n \n end",
"def index\n @workout_routines = WorkoutRoutine.all\n @exercises = Exercise.all\n end",
"def fetch_type name\n exercises = []\n data.exercises.each do |exe|\n if exe.target === name\n exercises.push(exe.name)\n end\n end\n exercises\n end",
"def show\n @exercises = Exercise.all\n @workout_routines = WorkoutRoutine.all\n end",
"def show\n @exercises = @programme.exercises\n if params[:search]\n @search = Exercise.search do\n fulltext params[:search]\n end\n @exSearch = @search.results\n else\n @exSearch = Exercise.all\n end\n end",
"def index\n @exercises = Exercise.search(params)\n # @exercises = Kaminari.paginate_array(@exercises).page(params[:exercise_page]).per(PER_PAGE_RECORDS)\n end",
"def show\n @task = Task.find(params[:id])\n @exercises = (@task.visible_to_admin_only && !current_user.master?) ? [] : @task.exercises\n\n @exercise = if @task.finished?(current_user)\n Exercise.where(:user_id => current_user.id, :task_id => @task.id).first\n else\n Exercise.new(:date => Date.current, :task_id => @task.id, :user_id => current_user.id)\n end\n end",
"def index\n @api_v1_exercises = Api::V1::Exercise.all\n end",
"def add_demonstrator\n @courses = current_staff.courses\n # find future practicals\n current_time = DateTime.now\n @practicals_of_course = {}\n @courses.each do |course|\n @practicals_of_course[course.course_title] = course.practicals.where('start_time >= ?', current_time)\n end\n end",
"def show\n @workout_day = WorkoutDay.find(params[:id])\n\n @exercises = @workout_day.exercises\n\n assign_exercises_selection_list\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workout_day }\n end\n end",
"def index\n @exercises = Exercise.where(is_public: true)\n end",
"def index\n @exercise_names = ExerciseName.all\n end",
"def index\n\tif (params.has_key?(:workout_id))\n\t\tset_workout\n\t\t@exercises = @workout.exercises.paginate(page: params[:page])\n\t\t\t\n\t\t#@exercises = current_user.exercises.find(params[:workout_exercises][:workout_id])\n\telse\n\t\t@exercises = current_user.exercises.paginate(page: params[:page])\n\tend\t\n\t\n end",
"def index\n @exerciseoverviews = Exerciseoverview.all\n end",
"def print_quests(difficulty)\n self.get_recommended_quests(difficulty).each_with_index do |quest, i|\n puts \"#{i+1}: #{quest.title}\"\n end\n end",
"def list_details(list = \"all\")\n\n #Iterates over the arrays\n for i in 0..@exercises.size-1 do\n\n #In the case of all, it will list all details of the exercise\n if list == \"all\"\n exercise_info = \"Name: \" + @exercises[i].name + \" | Number of Repeats: \" + @repititions[i] + \" | Rest Time (sec): \" + break_time[i]\n\n #In the case of exercise, it will just list the name of the exercise\n elsif list == \"exercise\"\n exercise_info = \"Name: \" + @exercises[i].name\n end\n\n #outputs the information\n puts exercise_info\n\n end\n end",
"def get_bk_sec_exercises()\n InstBookSectionExercise.includes(:inst_exercise)\n .joins(:inst_section)\n .where(inst_sections: {inst_chapter_module_id: self.id})\n end",
"def nextExercise() \n last_done_question = last_question(auto_sequence.user)\n unless last_done_question.nil? \t \n last_exerc = Question.find(last_done_question.from_question_id).exercise.id\n ind_last_exerc = index_of(last_exerc)\n user_sequence[ind_last_exerc][2] = true\n if last_done_question.correct?\n # save as correct answer \n user_sequence[ind_last_exerc][3] = true\n save\n nxt_exerc = next_exercise_minimal_path_not_done\n if nxt_exerc.nil? # no more exercises\n return last_exerc\n # verify if the last exercise index + step size is before of the next exercise of the minimal path\n elsif ind_last_exerc + STEP_SIZE < index_of(Moped::BSON::ObjectId.from_string(nxt_exerc))\n # goes to first exercise not done after the last solved in minimal path\n return first_not_done_exercise\n else \n return nxt_exerc\n end\n else \n save \n nro_tentativas = last_attempt_number(auto_sequence.user)\n mediana = question_median(last_done_question.from_question_id) \n \tif nro_tentativas >= mediana\n min_ind_exerc = last_exercise_minimal_path_correctly_done\n min_index = 0\n if min_ind_exerc.nil? # student failed on every exercises of the minimal path\n # find the last correct exercise before the actual\n min_ind_exerc = last_exercise_correctly_done_before(ind_last_exerc)\n if min_ind_exerc.nil? # no exercise found, then find the last done before the actual\n min_ind_exerc = last_exercise_done_before(ind_last_exerc) \n end\n end\n min_index = index_of(Moped::BSON::ObjectId.from_string(min_ind_exerc)) \n medium_index = (min_index + ind_last_exerc)/2\n return first_not_done_exercise_after_index(medium_index)\n \telse # continues at the same exercise \n \t\treturn last_exerc\n \tend \n end \n else # returns the first exercise\n return self.user_sequence[0][0]\n end\n end",
"def get_exercise_progresses(user_id)\n OdsaExerciseProgress.joins(inst_book_section_exercise: [:inst_section])\n .where(inst_sections: {inst_chapter_module_id: self.id}, user_id: user_id)\n end",
"def index\n @exercise_tasks = ExerciseTask.all\n end",
"def muscle_groups_on_given_day(date)\n # exercise_name = self.exercise_on_a_day(date)\n\n\n my_workouts = Workout.all.select do |workout|\n workout[\"user_id\"] == self[\"id\"]\n end\n \n # find where date == workout date\n workouts_for_date = my_workouts.find_all do |workouts|\n workouts[\"date\"] == date\n end.map {|workout_instance| workout_instance.exercise_id}\n \n exercise_array = []\n muscle_groups = workouts_for_date.each do |exercise|\n Exercise.all.each do |exercise_instances|\n exercise_array << exercise_instances.muscle_group if (exercise_instances.id == exercise)\n end\n end\n \n if exercise_array == []\n \n return \"Sorry. Doesn't look like you worked out on #{date}.\".colorize(:light_cyan)\n else\n \n exercise_array\n end\n\n end",
"def index\n @exercise_executions = ExerciseExecution.all\n end",
"def exercise_instances\n Workout.all.select{|workout_instance| workout_instance.gym_id == self.id}\n end",
"def find_someday\n self.all(\n :completed_at => nil, \n :someday => true,\n :order => [:title])\n end",
"def view_info(db, user_id)\n puts \"Which exercise would you like to view?\"\n exercise = gets.chomp\n until is_existing_exercise(db, exercise) do\n puts \"Invalid exercise. Please retry.\"\n exercise = gets.chomp\n end\n\n results = db.execute(\"SELECT * FROM exercises_users WHERE user_id=? AND exercise_id=?\", [user_id, exercise_id])\n puts \"You last did #{results[0][1]} reps of #{exercise} at #{results[0][2]} pounds\"\nend",
"def index\n # TODO: Find personal quests\n quests = UsersQuest.where(:assignor_id => @current_user.id).pluck(:quest_id)\n @quests = Quest.where(:id => quests).order('due_date')\n end",
"def find_recipes_by_calories\n list_recipes(Recipe.where('calorie < ?' , ask('Maximum number of calories? >:')).order(:title)) # prompt user for max calories, query the database and list results \n end",
"def exec(query_hash)\n outputs[:exercises] = []\n OpenStax::Exercises::V1.exercises(query_hash)['items'].each do |wrapper|\n exercise = Content::Models::Exercise.find_or_initialize_by(url: wrapper.url)\n uid = wrapper.uid\n number_version = uid.split('@')\n exercise.number = number_version.first\n exercise.version = number_version.last\n exercise.title = wrapper.title\n exercise.content = wrapper.content\n exercise.save\n transfer_errors_from(exercise, {type: :verbatim}, true)\n\n lo_tags = wrapper.los\n non_lo_tags = wrapper.tags - lo_tags\n run(:tag, exercise, lo_tags, tag_type: :lo)\n run(:tag, exercise, non_lo_tags)\n\n outputs[:exercises] << exercise\n end\n end",
"def view_all(db, user_id)\n results = db.execute(\"SELECT exercises.name, exercises_users.reps, exercises_users.weight \n FROM users \n JOIN exercises_users ON users.id = exercises_users.user_id \n JOIN exercises ON exercises_users.exercise_id = exercises.id WHERE users.id = ?\", [user_id])\n results.each do |info_array|\n puts \"#{info_array[0]}:\\t #{info_array[1]} reps\\t #{info_array[2]} pounds\"\n end\nend",
"def add_exercise(new_exercise, new_repeats, new_break)\n @exercises.push(new_exercise)\n @repititions.push(new_repeats)\n @break_time.push(new_break)\n end",
"def exam_details(ex)\n exams_data = ex.exams.all\n flag = false\n exams_data.each do |exam|\n exam.exam_scores.each do |es|\n flag = true if es.is_failed?\n end\n exams << exam if flag == true\n end\n exams\n end",
"def index\n\t\t@exercises = Exercise.liked_by(current_user.id).search_by_name(params[:search_name]).search_by_type(params[:search_type]).search_by_owner(params[:search_owner]).published\n\t\t\t.concat(Exercise.owned_by(current_user.id).search_by_name(params[:search_name]).search_by_type(params[:search_type]).search_by_owner(params[:search_owner]).published)\n\t\t\t.concat(Exercise.owned_by(current_user.id).search_by_name(params[:search_name]).search_by_type(params[:search_type]).search_by_owner(params[:search_owner]).unpublished)\n\t\t\t.paginate(:page => params[:page], :per_page => 10)\n\t\t\t#Exercise.liked_by(current_user.id).published.paginate(:page => params[:page], :per_page => 30)\n\t\tlogger.debug \"wisport #{@exercises}\"\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n\t\t\tformat.js\n end\n end",
"def relatedQuestions(section)\n relQuestions = []\n\n questions = sectionQuestions(pretest())\n questions.each do |question|\n question.getActivityReferences.getVector.each do |reference|\n if section.equals(reference.getReferencedObject)\n relQuestions << question\n break\n end\n end\n end\n \n relQuestions\nend",
"def relatedQuestions(section)\n relQuestions = []\n\n questions = sectionQuestions(pretest())\n questions.each do |question|\n question.getActivityReferences.getVector.each do |reference|\n if section.equals(reference.getReferencedObject)\n relQuestions << question\n break\n end\n end\n end\n \n relQuestions\nend",
"def exercices\n @exercices ||= begin\n lignes_exercices.collect do |ligne_ex|\n ExerciceFingers::new ligne_ex.strip\n end\n end\n end",
"def index\n @exercises = Exercise.paginate(:page => params[:page], :per_page => 10).order('created_at DESC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @exercises }\n end\n end",
"def 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 get_stories(number_of_hours)\n date_range_start = Time.now-number_of_hours.hours\n words = Word.where(\"name = ? and story_date > ?\", self, date_range_start)\n stories = []\n words.each do |w|\n stories << w.story\n end \n return stories\n end",
"def index\n @exercises = Exercise.all\n @user = current_user # changed get logged user\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end",
"def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @exercises }\n end\n end",
"def show\n\tset_exercise\n end",
"def show\n p exercise_id = params[:exercise_id]\n p @exercise = Exercise.find(exercise_id)\n p @texts = Text.where(exercise_id: @exercise.id)\n p @inputs = Input.where(exercise_id: @exercise.id)\n end",
"def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end",
"def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end",
"def get_recommended_quests(difficulty)\n self.get_uncompleted_quests.select do |quest|\n quest.difficulty == difficulty\n end\n end",
"def show\n set_exercise\n \n end",
"def find_expirations\n expired_embargoes = []\n expiration_date = solrize_date(@date)\n\n @work_types.each do |work_type|\n expired_works = work_type.where(\"embargo_release_date_dtsi:[* TO #{RSolr.solr_escape(expiration_date)}]\")\n expired_embargoes << expired_works\n end\n\n expired_embargoes.flatten\n end",
"def load_workouts(file)\n workout_num = 0\n exercise_num = 0\n workout_list = []\n \n File.foreach(file) { |line| \n if line =~ /^Start Time: (\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}).[0-9]* +|-\\d*$/ then\n workout_num += 1\n exercise_num = -1\n workout_list << Workout.new.start_time=($1)\n elsif line =~ /^\\s*Exercise name: (\\w*\\D+\\s*\\w*) Exercise Type: (\\w+)$/ then\n exercise_num += 1\n exercise = Exercise.new()\n exercise.exercise_name = $1\n exercise.exercise_type = $2\n workout_list[workout_num] << exercise\n end\n }\n \n workout_list #return created workoutlist \n end",
"def list_overdue\n @checked_out.each do |book|\n book.is_overdue\n end\n \n puts \"The following books are overdue:\"\n @overdue.each { |book| puts \"#{book.title} - #{book.author}\" }\n end",
"def index\n @exercises = current_company.exercises.all\n flash[:notice] = t('flash.actions.index.notice') if @exercises.empty?\n respond_with(@exercises)\n end",
"def index\n @do_exercises = DoExercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @do_exercises }\n end\n end",
"def is_existing_exercise(db, name)\n exercises_arr = db.execute(\"SELECT name FROM exercises\")\n exercises_arr.each do |exercise|\n if exercise[0] == name\n return true\n end\n end\n return false\nend",
"def lectures\n Lecture.where(id: Lecture.all.select { |l| in_lecture?(l) }.map(&:id))\n end",
"def index\n @exam_results = ExamResult.order(:week_s => :desc).first(200)\n @exam_results_all = ExamResult.all\n\n @exam_results_weeks = ExamResult.count(:week_s)\n @exams_results_exams = ExamResult.sum(:taken)\n end",
"def index\n @exercise_types_in_users = ExerciseTypesInUser.all\n end",
"def display\n print_out = $db.execute(\"SELECT Exercise.name, Workouts.date, Workouts.weight FROM Workouts JOIN Exercise ON Exercise.id = Workouts.exercise_id \")\n #print print_out\n puts \"Date: #{print_out[0][1]}\"\n puts \"Exercise: #{print_out[0][0]}\"\n\nend",
"def ordre_exercices\n return [] if data_exercices.nil?\n data_exercices[:ordre] || []\n end",
"def get_meets\n Meet.where(\"date > ?\", Date.today - 1.year)\n end",
"def demonstrator_list\n @hash = {}\n # retrieves courses which are supervised by the course coordinator\n @courses = current_staff.courses\n @courses.each do |course|\n # starts building a hash containing the neccessary information\n @hash[course.course_title] = {}\n # retrieves all the practicals for the course\n course.practicals.each do |practical|\n @hash[course.course_title][practical.start_time] = {}\n # retrieves the demonstrators for the practicals\n demonstrators_on_given_practical = Demonstrator.where(\"practical_id = ?\", practical.id)\n # counts how many demonstrators will be on the practical\n counter = demonstrators_on_given_practical.count\n # initialising a hash for each demonstrator\n counter.times do |i|\n @hash[course.course_title][practical.start_time][i] = {}\n end\n counter = 0\n # goes through each demonstrator for a practical and restrieves their necessary information\n demonstrators_on_given_practical.each do |demonstrate_on|\n # checks whether the demonstrator is a staff member or a student\n demonstrator = Student.find_by(sam_student_id: demonstrate_on.sam_demonstrator_id)\n if demonstrator.nil?\n demonstrator = Staff.find_by(sam_staff_id: demonstrate_on.sam_demonstrator_id)\n end\n # stores the details of the demonstrator which will be presented in the corresponding view\n @hash[course.course_title][practical.start_time][counter][:sam_demonstrator_id] = demonstrate_on.sam_demonstrator_id\n @hash[course.course_title][practical.start_time][counter][:first_name] = demonstrator.first_name\n @hash[course.course_title][practical.start_time][counter][:last_name] = demonstrator.last_name\n @hash[course.course_title][practical.start_time][counter][:email] = demonstrator.email\n counter = counter + 1\n end\n end\n end\n end",
"def show\n @workout_session = WorkoutSession.find(params[:id])\n if !user_is_allowed?(@workout_session)\n redirect_to workout_sessions_path\n return\n end\n\n exercises = @workout_session.exercises\n exerciseWorkoutThrills = @workout_session.exercises_workout_thrills\n\n @exerciseList = Hash.new\n exercises.each do |e|\n if !@exerciseList.has_key?(e)\n @exerciseList[e] = []\n end\n end\n exerciseWorkoutThrills.each do |ewt|\n @exerciseList[ewt.exercise] << {:id => ewt.id, :multiplier => ewt.multiplier, :value => ewt.value}\n end\n\n #render :text => @exerciseList.as_json.to_s, :layout => false\n #return\n\n #if @workout_session.workout_day.nil?\n # @day = \"No Training Day in WorkOut Session\"\n # else\n # @day = @workout_session.workout_day.day\n #end\n\n\n #@exercises = []\n #exerciseWorkoutThrills.each do |e|\n # @exercises << {:e => e.exercise, :id => e.id, :value => e.value, :multiplier => e.multiplier}\n #end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workout_session }\n end\n end",
"def browse\n todaydate = Time.now.in_time_zone(\"US/Pacific\").to_date\n now = Time.now\n\n # grab upcoming contests that user can enter.\n @contests = Contest.in_range(current_user, todaydate, todaydate+1).eligible(current_user, now)\n \n # for realtime push testing: show fake contests only when user is admin\n if current_user.try(:admin)\n @contests += Contest.where(\"contest_start > ?\", Date.strptime(\"2030\",\"%Y\"))\n end\n\n end",
"def siblings\n self.drill.exercises.sort\n end",
"def explore\n end",
"def explore\n end",
"def explore\n end",
"def explore\n end",
"def explore\n end",
"def index\n @exercise_types = ExerciseType.all.order(id: :asc)\n end",
"def index\n @exercise = Exercise.find(params[:exercise_id])\n load_course\n\n if @course.has_teacher(current_user)\n @available_groups = Group.where('course_instance_id=?', @course_instance.id).joins(:users).order(:name).all.select { |group| group.users.size <= @exercise.groupsizemax }\n else\n @available_groups = Group.where('course_instance_id=? AND user_id=?', @course_instance.id, current_user.id).joins(:users).order(:name).all.select { |group| group.users.size <= @exercise.groupsizemax }\n end\n end",
"def list\n puts \"Events for Tech:\"\n puts \"\"\n TechCliApp::Tech.all.each.with_index(1) do |tech, i|\n puts \"#{i}. #{tech.title}\"\n end\n end",
"def chapters_with_problems\n get_chapters.inject Hash.new do |chapters_with_sections,chapter|\n challenges = Dir[\"ch#{chapter}/challenge/*\"]\n chapters_with_sections[chapter] = challenges.map { |challenge| challenge[%r([^/]+?$)].to_i }.sort\n chapters_with_sections\n end\nend",
"def list_details\n puts \"Name: \" + @name\n puts \"Description: \" + @details\n puts \"Exercise Time: \" + @duration\n end",
"def index\n @quizzes = Quiz.all.where(lesson_id: current_lesson.id)\n end",
"def get_completed_quests\n\n#check if the player has actually completed any quests\n#if he has not, tell him\n if self.quests.size == 0\n puts \"You have not completed any quests!!!\".red\n\n#otherwise, pull the completed quest objects and print the quest titles\n else\n puts \"Completed Quests:\".underline\n self.quests.each_with_index do |quest, i|\n puts \"#{i+1}: #{quest.title}\"\n end\n end\n end",
"def index\n @introexams = Introexam.all\n end",
"def index\n# @exercise_programs = ExerciseProgram.where('exercise_programs.user_id = ?', current_user.id).limit(10).offset(@page.to_i * 10)\n @exercise_programs = ExerciseProgram.for_page(@page, current_user)\n end",
"def day_meetings\n days = []\n @course.weekdays.each_char.each_with_index do |w, i|\n days.push(DAYS_AS_SYM[i]) if w.to_i == 1\n end\n days\n end",
"def initialize(new_name = \"workout\")\n @name = new_name\n @exercises = Array.new\n @repititions = Array.new\n @break_time = Array.new\n end",
"def completed_tests()\n test_array = []\n self.problems.each do |problem|\n problem.tests.each do |test|\n test_array.push(test)\n end\n end\n test_array\n end",
"def list_of_days_worked_out\n array = []\n workouts = Workout.all.find_all do |workout| \n workout.user_id == self.id \n end\n dates = workouts.each do |workout|\n array << workout.date\n end\n array\n end",
"def main\n @trainings = Training.limit(12).order(date: :desc)\n #En el root muestro los 12 últimos entrenamientos, de quien sean\n end",
"def appointments\n\n Appointment.all.select {|appointment| appointment.doctor == self}\n # binding.pry\n # [1,2,3,4,5].select { |num| num.even? }\n end",
"def editions\n works.map {|work| work.editions}.flatten.map\n end",
"def index\n @examquestions = Examquestion.all\n end",
"def show\n @hack_meets = @hack_member.hack_meets.order(:hack_date)\n end",
"def index\n if current_user.admin?\n @exams = Exam.all\n else\n professional_list = Exam.where(user: @list).pluck(:id)\n user_list = Exam.where(user: current_user).pluck(:id)\n @exams = Exam.where(id: [professional_list, user_list].flatten)\n end\n end",
"def get_todo model, cohort\n return [] unless model && cohort\n ids = adminned_memberships_by_tag(cohort).map(&:id)\n records = model.where(membership_id: ids).todo\n end",
"def index\n if current_user.admin\n # (10 years is a suitably long time to not matter chasing debts...)\n @lessons_to_debrief = Lesson.where(\n start_time: 10.years.ago..Time.now,\n attended: nil )\n .order(\"start_time DESC\")\n @lessons_not_paid = Lesson.where( start_time: 10.years.ago..Time.now )\n .where.not( attended: nil )\n .where( paid: false )\n .order(\"start_time DESC\")\n @lessons_completed = Lesson.where(\n start_time: 1.month.ago..Time.now,\n attended: true,\n paid: true)\n .order(\"start_time DESC\")\n else\n @lessons = current_user.lessons.where.not( student_notes: nil )\n .where( student_has_read_note: false )\n end\n end",
"def relatedQuestions(section)\n relQuestions = []\n \n questions = sectionQuestions(pretest())\n questions.each do |question|\n question.getActivityReferences.getVector.each do |reference|\n if section.equals(reference.getReferencedObject)\n relQuestions << question\n break\n end\n end\n end\n \n relQuestions\n end",
"def opened\n @exercises = current_company.exercises.opened\n flash[:notice] = t('flash.actions.index.notice') if @exercises.empty?\n respond_with(@exercises) do |format|\n format.html { render :action => :index }\n end\n end",
"def index\n @questionfives = Questionfive.all\n end",
"def find_instructor_solution(prob,instr_dir)\n # returns [found,file,figs_dir]\n found = false\n found_file = nil\n topics = [\"intro\",\"mechanics\",\"waves\",\"em-dc\",\"em-fields\",\"em-general\",\"optics\",\"relativity\",\"quantum\"]\n topics.each { |subdir|\n found_file = \"#{instr_dir}/#{subdir}/#{prob}.tex\"\n if File.exist?(found_file) then return[true,found_file,\"#{instr_dir}/#{subdir}/figs\"] end\n }\n return [false,nil,nil]\nend",
"def exercise_119 (number)\n end"
] | [
"0.69004864",
"0.66495",
"0.6513002",
"0.6421902",
"0.6390747",
"0.62667465",
"0.62470347",
"0.62356615",
"0.613157",
"0.61276317",
"0.6090618",
"0.60681695",
"0.6051292",
"0.60158235",
"0.60089785",
"0.600201",
"0.5993537",
"0.5925204",
"0.58687156",
"0.58635896",
"0.58453566",
"0.58369803",
"0.5804028",
"0.57650596",
"0.5738043",
"0.57332",
"0.5730182",
"0.57249653",
"0.56813264",
"0.5659902",
"0.56579417",
"0.5647656",
"0.5639048",
"0.5569313",
"0.54983354",
"0.54909205",
"0.5489908",
"0.5456834",
"0.5443782",
"0.54417807",
"0.54417807",
"0.5409242",
"0.5401392",
"0.5393899",
"0.5392421",
"0.538612",
"0.5386116",
"0.53821135",
"0.5381506",
"0.53707963",
"0.53707963",
"0.5354138",
"0.53472495",
"0.53453267",
"0.53433424",
"0.53428745",
"0.5339975",
"0.5330724",
"0.53166085",
"0.53039455",
"0.529715",
"0.5286579",
"0.52806336",
"0.5280453",
"0.5256463",
"0.52561915",
"0.5243778",
"0.52303433",
"0.52238435",
"0.5223333",
"0.5223333",
"0.5223333",
"0.5223333",
"0.5223333",
"0.5222751",
"0.5217907",
"0.5215089",
"0.5211892",
"0.5205985",
"0.5202112",
"0.5201379",
"0.51985985",
"0.51882535",
"0.5179164",
"0.51788384",
"0.51784223",
"0.5172559",
"0.517237",
"0.5162988",
"0.5162426",
"0.5161382",
"0.51608783",
"0.5146513",
"0.5145336",
"0.5144795",
"0.51444703",
"0.51429015",
"0.5142869",
"0.51364225",
"0.51349676"
] | 0.67958313 | 1 |
3. I can see what muscle_groups I'm working on, ON a specific day | def muscle_groups_on_given_day(date)
# exercise_name = self.exercise_on_a_day(date)
my_workouts = Workout.all.select do |workout|
workout["user_id"] == self["id"]
end
# find where date == workout date
workouts_for_date = my_workouts.find_all do |workouts|
workouts["date"] == date
end.map {|workout_instance| workout_instance.exercise_id}
exercise_array = []
muscle_groups = workouts_for_date.each do |exercise|
Exercise.all.each do |exercise_instances|
exercise_array << exercise_instances.muscle_group if (exercise_instances.id == exercise)
end
end
if exercise_array == []
return "Sorry. Doesn't look like you worked out on #{date}.".colorize(:light_cyan)
else
exercise_array
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_by_day\n\n\tend",
"def create_groups\n Group.create(name: \"MWF Morning\", days: [\"Monday\", \"Wednesday\", \"Friday\"], \n start_time: Time.local(2014, 8, 25, 8, 30, 0),\n end_time: Time.local(2014, 8, 25, 11, 30, 0)\n )\n Group.create(name: \"TTH Morning\", days: [\"Tuesday\", \"Thursday\"], \n start_time: Time.local(2014, 8, 25, 8, 30, 0),\n end_time: Time.local(2014, 8, 25, 11, 30, 0)\n )\n Group.create(name: \"Afternoon\", days: [\"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\"], \n start_time: Time.local(2014, 8, 25, 12, 30, 0),\n end_time: Time.local(2014, 8, 25, 15, 30, 0)\n )\nend",
"def all_scheduled(db)\r\n\t\tall_array=[]\r\n\t\tall_array = db.execute(\"SELECT * FROM playgroups\")\r\n\t\tall_array.each do |i|\r\n\t\t\tputs \"Host:#{i[1]}, Location:#{i[3]}, Kids attending:#{i[2]}\"\r\n\t\tend\t\t\r\n\tend",
"def view_symptoms_specific_date(day)\n day_symptoms = $db.execute( <<-SQL\n SELECT * FROM symptoms\n WHERE date=\"#{day}\";\n SQL\n )\n puts \"_____________________________\"\n puts \"Symptoms that occurred on #{day}:\"\n day_symptoms.each do | symptom |\n puts \"#{symptom['symptom']}\"\n end\n puts \"_____________________________\"\nend",
"def update_muscle_groups groups\n groups = {} unless groups.is_a?(Hash)\n groups.symbolize_keys\n self.muscle_groups = \"\"\n Activity::MUSCLE_GROUP_VALUES.each do |name|\n bit = groups[name] == \"1\" ? \"1\" : \"0\"\n self.muscle_groups = self.muscle_groups + bit\n end\n end",
"def groups; end",
"def groups; end",
"def groups; end",
"def show\n @event_data_by_category_and_minute = Event.where(whatspp_message_id: @whatspp_message_ids).group(:category).group_by_minute(:created_at).count\n @event_data_by_category = Event.where(whatspp_message_id: @whatspp_message_ids).group(:category).count\n end",
"def groups\n if groups_last_update.blank? || ((Time.now - groups_last_update) > 24 * 60 * 60)\n return groups!\n end\n group_list.split(\";?;\")\n end",
"def exercise_on_a_day(date)\n #iterate through workouts and find workouts.user_id == self\n my_workouts = Workout.all.select do |workout|\n workout[\"user_id\"] == self[\"id\"]\n end\n # find where date == workout date\n workouts_for_date = my_workouts.find_all do |workouts|\n workouts[\"date\"] == date\n end.map {|workout_instance| workout_instance.exercise_id}\n \n exercise_array = []\n exercise_list = workouts_for_date.each do |exercise_id|\n Exercise.all.each do |exercise_instances|\n exercise_array << exercise_instances.name if (exercise_instances.id == exercise_id)\n end\n end\n \n if exercise_array == []\n return \"Sorry. Doesn't look like you worked out on #{date}.\".colorize(:light_cyan)\n else\n return exercise_array\n end\n end",
"def girl_groups; end",
"def get_report_by_date(date, group)\n if group\n self.reports.find(:first, :conditions => [\"group_id = ? and created_date like ?\" , group.id, date.to_s + \"%\"])\n else\n self.reports.find(:first, :conditions => [\"group_id is ? and created_date like ?\" , nil, date.to_s + \"%\"])\n end\n end",
"def list_events(calendar, how, month_to_view=false)\n puts \" Here are your events...(#{how})\"\n events = Event.where(calender_id: calendar.id).order('start_time')\n events.each_with_index do |event, index|\n begin\n case how\n when \"today\"\n if DateTime.now.to_date == event.start_time.to_date\n puts \" #{index+1}. #{event.name}\"\n end\n when \"week\"\n if DateTime.now.to_date <= event.start_time.to_date && event.start_time.to_date <= DateTime.now.to_date + 7.days\n puts \" #{index+1}. #{event.name}\"\n end\n when \"month\"\n if month_to_view\n if month_to_view == event.start_time.to_s[5..6]\n puts \" #{index+1}. #{event.name}\"\n end\n else\n if DateTime.now.to_s[5..6] == event.start_time.to_s[5..6]\n puts \" #{index+1}. #{event.name}\"\n end\n end\n else\n puts \" #{index+1}. #{event.name}\"\n end\n rescue\n error\n end\n end\nend",
"def index\n session[:page] = 'index'\n @talks=[]\n @parent_ids = []\n @talks << Talk.last(1)\n @talks << Talk.order('id DESC').limit(31).where('topic LIKE ? or topic LIKE ?', '%嗎%', '%呢%').sample(1)\n hour_groups = [1, 2, 4, 8]\n hour_groups.each {|t| @talks << Talk.where(created_at: Time.now-t.hour-1.hour..Time.now-t.hour).order(id: :desc).sample(1)}\n\n day_groups = [1.day, 2.day, 4.day, 1.week]\n # , 2.week, 1.month, 3.month, 6.month, 1.year]\n day_groups.each {|t| @talks << Talk.where(created_at: Time.now-t-1.day..Time.now-t).order(id: :desc).sample(3)}\n\n @shiritori_last = Talk.last[:topic].split('').last\n end",
"def index\r\n if current_user.master_user?\r\n @groups = current_user.account.groups\r\n else\r\n @groups = current_user.groups\r\n end\r\n @ids_for_earth = []\r\n @groups.each { |group| @ids_for_earth << group.id unless group.incivents.unarchived.count == 0 && group.tasks.unarchived.count == 0 && group.stories.unarchived.count == 0 && group.measurements.unarchived.count == 0 }\r\n end",
"def browse_by_day\n # Checkeo de parametros. El parametro date contiene la fecha seleccionada, pero puede venir tambien star_date,\n # con el mismo uso. Hay dos, porque el weekly_viewer usa start_date, pero habria que unificarlo.\n # Si hay algo en esos parametros se usa eso, y si no se usa la fecha de hoy.\n if params[:date].nil?\n if params[:start_date].nil?\n @search_by_date = Date.today\n else\n @search_by_date = params[:start_date].to_date\n end\n else\n if @search_by_date.nil?\n begin\n @search_by_date = Date.parse(params[:date][:year] + '-' + params[:date][:month] + '-' + params[:date][:day])\n rescue => e\n @search_by_date = Date.today\n end\n end\n end\n\n @events = []\n if params.include? :business_hours\n @business_hours = params[:business_hours]\n end\n if not params[:carrera].nil?\n @carrera_selected = params[:carrera][:carrera_id]\n end\n\n # busqueda de los eventos por año, los del año \"0\" son los eventos no recurrentes en este momento, pero eso esta mal, deberian ser los que no estan\n # asignados a una materia. Lo de que sean recurrentes o no recurrentes, ya no es tan asi en esta busqueda y debemos cambiarlo, pero me termino de avivar recien\n # y ya es tarde\n @free_spaces = Espacio.all\n 6.times do |an|\n @calendar = nil\n @calendar = get_calendar :date => @search_by_date, :career => (params.include? :carrera) ? params[:carrera][:carrera_id] : nil, :year => an\n @calendar.events.each do |event|\n\n temp = SimpEvent.new\n temp.starts_at = event.dtstart\n temp.ends_at = event.dtend\n temp.name = event.description + ' - ' + Espacio.find(:first, :conditions => {:id => event.location.to_i}).codigo\n temp.original_id = event.comment[0].to_i\n temp.anio = an\n @events.push temp\n\n @free_spaces.delete(Espacio.find_by_id event.location.to_i) if DateTime.now.strftime('%H%M').to_i.between? event.dtstart.strftime('%H%M').to_i, event.dtend.strftime('%H%M').to_i\n end\n end\n @ver_horas = params[:ver_horas] == \"1\" ? false : true\n redirect_to \"/eventos/browse_by_day?business_hours=#{@ver_horas}&start_date=#{@search_by_date}\" unless params[:ver_horas].nil?\n end",
"def found_events\n @mood.events\n end",
"def shows_at_venue_per_day(week_day)\n festival_start = find_days_start_time(week_day)\n shows_at_venue = Event.where(\"venue_id\" => @venue.id)\n @shows_at_venue_per_day = []\n shows_at_venue.each do |show|\n if show.weekday == week_day\n @shows_at_venue_per_day << show\n end\n end\n if @shows_at_venue_per_day != []\n @shows_at_venue_per_day.sort_by! { |obj| obj.start_date_time}\n shows_with_blanks(festival_start)\n fill_out_final_blanks(festival_start)\n end\n return @shows_with_blanks\n end",
"def print_daily_list(db, day)\r\n\tputs \"Chores for #{day}\"\r\n\tprint_chores = db.execute(\"SELECT chores.name, family.name FROM chores, family WHERE chores.complete_by_day = ? AND chores.family_id = family.id\", [day])\r\n\tprint_chores.each do |x|\r\n\t\tputs \"#{x[1]} : #{x[0]}\"\r\n\tend\r\nend",
"def mday\n end",
"def get_features_by_date(date, group)\n key = Feature.convert_date_key(date)\n if group\n self.features.find(:all, :conditions => [\"group_id = ? and year_week = ?\", group.id, key])\n else\n self.features.find(:all, :conditions => [\"group_id is ? and year_week = ?\", nil, key])\n end\n end",
"def i_groups; end",
"def get_list_for(day, hour, dayname, today)\n months = [_(:january), _(:february), _(:march), _(:april), _(:may), _(:june),\n _(:july), _(:august), _(:september), _(:october), _(:november), _(:december)]\n nobroad = \" #{_(:no_broadcast_on)}\"\n broad = \"#{_(:broadcast_on)}\"\n\n aday = DatesSchedule.get_day(@language, day)\n if aday.kind_of?(Array) and !aday.blank?\n d = aday[0].d\n m = aday[0].m - 1\n else\n d = 1\n m = 0\n end\n dm = \"#{d} #{months[m]}\"\n\n alist = Listing.get_day(@language, day)\n return \"<h3>#{nobroad} #{dayname}, #{dm}</h3>\" if alist.blank?\n list = \"<h3>#{broad} #{dayname}, #{dm}</h3>\"\n alist.each_with_index { |item, index|\n time = sprintf(\"<div class='time'>%02d:%02d - %s</div>\",\n item.start_time / 100,\n item.start_time % 100,\n calc_end_time(item.start_time, item.duration))\n title = item.title.gsub '[\\r\\n]', ''\n title.gsub! '<div>', ''\n title.gsub! '</div>', ''\n descr = item.descr.gsub '[\\r\\n]', ''\n descr.gsub!(/href=([^\"])(\\S+)/, 'href=\"\\1\\2\" ')\n descr.gsub!('target=_blank', 'class=\"target_blank\"')\n descr.gsub!('target=\"_blank\"', 'class=\"target_blank\"')\n descr.gsub!('&main', '&main')\n descr.gsub!('<br>', '<br/>')\n descr.gsub!(/<font\\s+color\\s*=\\s*[\"\\'](\\w+)[\"\\']>/, '<span style=\"color:\\1\">')\n descr.gsub!(/<font\\s+color\\s*=\\s*[\"\\'](#[0-9A-Fa-f]+)[\"\\']>/, '<span style=\"color:\\1\">')\n descr.gsub!('</font>', '</span>')\n list += \"<div class='item#{index % 2}'>#{time}<div class='title icon-plus'>#{title}</div><div style='display:none;' class='descr'>#{descr}</div></div>\"\n }\n\n list + '<div class=\"item2\"> </div>'\n end",
"def groups\n if (groups_last_update.blank? || ((Time.now-groups_last_update) > 24*60*60 ))\n return groups!\n end\n return self.group_list.split(\";?;\")\n end",
"def groups\n if (groups_last_update.blank? || ((Time.now-groups_last_update) > 24*60*60 ))\n return groups!\n end\n return self.group_list.split(\";?;\")\n end",
"def events_on_day(day_num)\n events = []\n event.each { |e| events << e if e.days.include? day_num }\n events.sort_by(&:start_time)\n end",
"def all_day ; true ; end",
"def mday() end",
"def memberships_to_notify(date)\n treatment_group_memberships\n .status_enrolled\n .joins(treatment_group: :reminder_templates)\n .where(\"date_trunc('day', experiment_inclusion_date) + make_interval(days := reminder_templates.remind_on_in_days) = ?\", date)\n end",
"def get_group racer\n if racer && racer.birth_year && racer.gender\n quotient=(date.year-racer.birth_year)/10\n min_age=quotient*10\n max_age=((quotient+1)*10)-1\n gender=racer.gender\n name=min_age >= 60 ? \"masters #{gender}\" : \"#{min_age} to #{max_age} (#{gender})\"\n Placing.demongoize(:name=>name)\n end\n end",
"def my\n open_season_ids = Season.is_not_ended.select(:id).map{|s| s.id }\n\n # Why refine? If user tags a meeting out form his affikliation it should be shown\n browsable_season_ids = open_season_ids\n # Refine the list of open seasons:\n #browsable_season_ids = open_season_ids.select{ |season_id|\n # ! current_user.find_team_affiliation_id_from_badges_for( season_id ).nil?\n #} + open_season_ids.select{ |season_id|\n # ! current_user.find_team_affiliation_id_from_team_managers_for( season_id ).nil?\n #}\n #browsable_season_ids.uniq!\n\n # Extract the user-tagged browsable meetings:\n meeting_id_list = Meeting\n .where( \"meetings.season_id IN (?)\", browsable_season_ids )\n .tagged_with( \"u#{ current_user.id }\", on: :tags_by_users )\n .select( :id, :season_id )\n .map{ |meeting| meeting.id }\n\n # If user has an associated swimmer look for team tagged and attended meetings too\n if current_user.has_associated_swimmer?\n # Add also the team-tagged browsable meetings.\n # Find the current, browsable team affiliations that may have tagged the meetings,\n # and, for each, add any tagged meeting found to the list:\n browsable_season_ids\n .map{ |season_id| current_user.find_team_affiliation_id_from_badges_for(season_id) }\n .compact.each do |tagger_team_affiliation_id|\n meeting_id_list += Meeting\n .where( [\"meetings.season_id IN (?)\", browsable_season_ids] )\n .tagged_with( \"ta#{ tagger_team_affiliation_id }\", on: :tags_by_teams )\n .select( :id, :season_id )\n .map{ |meeting| meeting.id }\n end\n\n # .where( [\"meetings.id not in (?) and meetings.season_id IN (?)\", meeting_id_list, browsable_season_ids] )\n\n # Add also any already attended and closed meeting belonging to the browsable\n # seasons: (the relationship w/ swimmer is through MIRs, so the inner join is enough)\n meeting_id_list += current_user.swimmer.meetings\n .where( [\"meetings.season_id IN (?)\", browsable_season_ids] )\n .select( :id, :season_id )\n .map{ |meeting| meeting.id }\n end\n\n# .where( [\"meetings.id not in (?) and meetings.season_id IN (?)\", meeting_id_list, browsable_season_ids] )\n\n @calendarMeetingPicker = CalendarMeetingPicker.new( nil, nil, nil, meeting_id_list.uniq! )\n @calendarDAO = @calendarMeetingPicker.pick_meetings( 'DESC', false, current_user )\n @meetings = @calendarDAO.get_meetings\n\n end",
"def said_hello_groups\n #checks if user said hello to groups recently when app is killed and restarted \n\n #@user = User.find_by(access_token: params[:access_token])\n\n minutes = 10 # minutes someone will be active in group \n countdown_timer = minutes * 60 \n filter_time = DateTime.now.utc - minutes.minutes\n\n last_said_hello_program = GroupConnection.where(\"created_at > ?\", filter_time).where(outgoing_user_id: current_user.id, acceptor_user_id: nil).last\n last_said_hello_custom_group = CustomGroupConnection.where(\"created_at > ?\", filter_time).where(outgoing_user_id: current_user.id, acceptor_user_id: nil).last\n\n if last_said_hello_program\n render json: { last_said_hello: last_said_hello_program.created_at, countdown_timer: countdown_timer, is_success: true }, status: :ok \n elsif last_said_hello_custom_group\n render json: { last_said_hello: last_said_hello_custom_group.created_at, countdown_timer: countdown_timer, is_success: true }, status: :ok \n else\n render json: { is_success: false }, status: :ok \n end\n end",
"def show \n @conne = StudentGroup.find_by(student_id: current_student.id)\n @group = Group.find(params[:id])\n @events = @group.events.order(\"created_at DESC\").page(params[:page]).per(3)\n @today = Date.today\n end",
"def w_day; end",
"def view_existing_list(database, date)\n\ttime1AM = database.execute(\"SELECT schedules.'1:00AM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime2AM = database.execute(\"SELECT schedules.'2:00AM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime3AM = database.execute(\"SELECT schedules.'3:00AM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime4AM = database.execute(\"SELECT schedules.'4:00AM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime5AM = database.execute(\"SELECT schedules.'5:00AM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime6AM = database.execute(\"SELECT schedules.'6:00AM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime7AM = database.execute(\"SELECT schedules.'7:00AM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime8AM = database.execute(\"SELECT schedules.'8:00AM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime9AM = database.execute(\"SELECT schedules.'9:00AM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime10AM = database.execute(\"SELECT schedules.'10:00AM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime11AM = database.execute(\"SELECT schedules.'11:00AM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime12PM = database.execute(\"SELECT schedules.'12:00PM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime1PM = database.execute(\"SELECT schedules.'1:00PM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime2PM = database.execute(\"SELECT schedules.'2:00PM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime3PM = database.execute(\"SELECT schedules.'3:00PM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime4PM = database.execute(\"SELECT schedules.'4:00PM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime5PM = database.execute(\"SELECT schedules.'5:00PM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime6PM = database.execute(\"SELECT schedules.'6:00PM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime7PM = database.execute(\"SELECT schedules.'7:00PM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime8PM = database.execute(\"SELECT schedules.'8:00PM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime9PM = database.execute(\"SELECT schedules.'9:00PM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime10PM = database.execute(\"SELECT schedules.'10:00PM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime11PM = database.execute(\"SELECT schedules.'11:00PM' FROM schedules WHERE schedules.day=(?)\",[date])\n\ttime12AM = database.execute(\"SELECT schedules.'12:00AM' FROM schedules WHERE schedules.day=(?)\",[date])\n\n\tputs \"\\n1:00AM - #{time1AM[0][0]}\"\n\tputs \"2:00AM - #{time2AM[0][0]}\"\n\tputs \"3:00AM - #{time3AM[0][0]}\"\n\tputs \"4:00AM - #{time4AM[0][0]}\"\n\tputs \"5:00AM - #{time5AM[0][0]}\"\n\tputs \"6:00AM - #{time6AM[0][0]}\"\n\tputs \"7:00AM - #{time7AM[0][0]}\"\n\tputs \"8:00AM - #{time8AM[0][0]}\"\n\tputs \"9:00AM - #{time9AM[0][0]}\"\n\tputs \"10:00AM - #{time10AM[0][0]}\"\n\tputs \"11:00AM - #{time11AM[0][0]}\"\n\tputs \"12:00PM - #{time12PM[0][0]}\"\n\tputs \"1:00PM - #{time1PM[0][0]}\"\n\tputs \"2:00PM - #{time2PM[0][0]}\"\n\tputs \"3:00PM - #{time3PM[0][0]}\"\n\tputs \"4:00PM - #{time4PM[0][0]}\"\n\tputs \"5:00PM - #{time5PM[0][0]}\"\n\tputs \"6:00PM - #{time6PM[0][0]}\"\n\tputs \"7:00PM - #{time7PM[0][0]}\"\n\tputs \"8:00PM - #{time8PM[0][0]}\"\n\tputs \"9:00PM - #{time9PM[0][0]}\"\n\tputs \"10:00PM - #{time10PM[0][0]}\"\n\tputs \"11:00PM - #{time11PM[0][0]}\"\n\tputs \"12:00AM - #{time12AM[0][0]}\"\nend",
"def get_grouphistory(users)\n known_group_sids = {\n 'S-1-5-113' => 'Local Account',\n 'S-1-5-114' => 'Local Administrator',\n 'S-1-1-0' => 'Everyone',\n 'S-1-5-32-545' => 'Builtin Group',\n 'S-1-5-32-544' => 'Builtin Administrator',\n 'S-1-5-4' => 'Interactive Logon',\n 'S-1-2-0' => 'Local Logon',\n 'S-1-2-1' => 'Console Logon',\n 'S-1-5-11' => 'Authenticated User',\n 'S-1-5-15' => 'This Organization',\n 'S-1-5-13' => 'Terminal Service Logon',\n 'S-1-5-6' => 'Service Logon',\n 'S-1-5-2' => 'Network Logon',\n 'S-1-18-5' => 'Multi Factor Authentication',\n 'S-1-5-32-578' => 'Hyper-V Admins',\n 'S-1-5-9' => 'Domain Controller',\n 'S-1-5-14' => 'Remote Interactive Logon',\n 'S-1-5-17' => 'IUSR',\n 'S-1-5-18' => 'Local System',\n 'S-1-5-19' => 'Local Service',\n 'S-1-5-20' => 'Network Service',\n 'S-1-5-32-546' => 'BuiltIn Guests',\n 'S-1-5-32-547' => 'BuiltIn PowerUser',\n 'S-1-5-32-548' => 'Account Operators',\n 'S-1-5-32-549' => 'Server Operators',\n 'S-1-5-32-550' => 'Printer Operators',\n 'S-1-5-32-551' => 'Backup Operators',\n 'S-1-5-32-555' => 'Remote Desktop',\n 'S-1-16-12288' => 'High Integrity Level',\n 'S-1-18-1' => 'Asserted Identiry',\n 'S-1-5-64-10' => 'NTLM Authentication',\n 'S-1-16-8192' => 'Medium Integrity'\n }\n\n dom_known_rids = {\n '498' => 'Domain Controllers',\n '500' => 'Machine Administrator',\n '501' => 'Machine Guest',\n '502' => 'KRBGT',\n '512' => 'Domain Admins',\n '513' => 'Domain Users',\n '514' => 'Domain Guests',\n '515' => 'Domain Computer',\n '516' => 'Domain Controller',\n '517' => 'Cert Publisher',\n '518' => 'Schema Administrator',\n '519' => 'Enterprise Administrators',\n '520' => 'GPO Creator/Owner',\n '521' => 'RODC',\n '522' => 'Clonable Controllers',\n '525' => 'Protected Users',\n '526' => 'Key Admins',\n '527' => 'Enterprise Key Admins',\n '553' => 'RAS Server',\n '571' => 'RODC Password Replicator',\n '572' => 'Denied RODC Password Replicator'\n\n }\n reg_key = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Group Policy'\n group_history = []\n users.each do |u|\n results_table = Rex::Text::Table.new(\n 'Header' => 'Groups',\n 'Indent' => 1,\n 'SortIndex' => 0,\n 'Columns' => ['Name', 'SID']\n )\n print_status(\"Group Membership for #{u[:account]}\")\n groupmembership_key = \"#{reg_key}\\\\#{u[:sid]}\\\\GroupMembership\"\n key_vals = registry_enumvals(groupmembership_key)\n key_vals.each do |g|\n if g =~/Group\\d+/\n group_sid = registry_getvaldata(groupmembership_key, g)\n if group_sid =~ /^S-\\d-\\d+-(\\d+-){3,14}\\d+$/\n rid = (group_sid.split(\"-\"))[-1]\n if dom_known_rids.key?(rid)\n results_table << [dom_known_rids[\"#{rid}\"], group_sid]\n else\n results_table << [dom_known_rids[\"#{rid}\"], group_sid]\n end\n else\n if known_group_sids.key?(group_sid)\n results_table << [known_group_sids[\"#{group_sid}\"], group_sid]\n else\n results_table << [known_group_sids[\"#{group_sid}\"], group_sid]\n end\n end\n end\n end\n results_table.to_s.each_line do |l|\n if l =~ /admin|operator|owner/i\n print_line(\"%red#{l.chomp}%clr\")\n elsif l =~ /term|network|service/i\n print_line(\"%yel#{l.chomp}%clr\")\n else\n print_line(l.chomp)\n end\n end\n print_line\n report_note(\n :host => session.session_host,\n :type => 'host.info.user_groups',\n :data => {\n :user => u[:account],\n :data => results_table.to_csv} ,\n :update => :unique_data)\n end\n end",
"def groups()\n\t\t\tend",
"def date_group_items\n @date_group_items ||= []\n end",
"def obj_group_by_time(mod = \"\",unit= nil)\n unit ||= \"day\"\n can_units = %w(day month year week)\n if mod.present? and mod.classify.class_exists? and (can_units.include? unit)\n mod = mod.classify.constantize if mod.class == String\n mod.all.group_by{|u| u.created_at.send(\"beginning_of_#{unit}\")}\n else\n []\n end\n end",
"def episodes_get\n log_debug\n\n # build syntax if we looking for a specific show\n show_wanted = ''\n \n if self.show\n show_wanted = \"and title = '#{self.show}'\"\n end\n \n sql_shows = \"select id,title,guid from metadata_items where metadata_type=2 and library_section_id in (select id from library_sections where section_type = 2) #{show_wanted} order by title\" \n \n sql_select(sql_shows).each do |row_shows|\n\n sql_seasons = \"select id,\\\"index\\\" from metadata_items where metadata_type=3 and parent_id=#{row_shows[0]} order by \\\"index\\\"\"\n sql_select(sql_seasons).each do |row_seasons|\n show = row_shows[1]\n season = row_seasons[1]\n guid = row_shows[2] \n \n sql_episodes = \"select \\\"index\\\",title, id from metadata_items where metadata_type=4 and parent_id=#{row_seasons[0]} order by \\\"index\\\"\"\n sql_select(sql_episodes).each do |row_episodes|\n episode = row_episodes[0]\n name = row_episodes[1]\n metadata_item_id = row_episodes[2]\n \n #puts \"metadata_item_id : #{metadata_item_id}\"\n episodes_track show, season, episode, name\n found_debug show, season, episode, name \n \n sql_items = \"select id from media_items where metadata_item_id = #{metadata_item_id}\"\n sql_select(sql_items).each do |row_items|\n media_items_id = row_items[0]\n # puts \"media_items_id : #{media_items_id}\"\n \n sql_parts = \"select file from media_parts where media_item_id = #{media_items_id}\"\n sql_select(sql_parts).each do |row_parts|\n file = row_parts[0]\n # puts \"file : #{file}\"\n shows_track show, guid, season, file\n \n end\n \n end\n\n \n end\n end\n end\n\n end",
"def get_dates_matche (date_matche,days_game)\n flag_continue=true\n while flag_continue do\n date_matche = date_matche + 1.days\n day_week=date_matche.wday\n if days_game.include?(day_week.to_s)\n return date_matche\n end \n end\n end",
"def group; end",
"def index\n @grouped_schedule_places = SchedulePlace.all\n .order(:weekday_id, :start_time).group_by{ |sp| sp.weekday.name }\n @weekdays = Weekday.all.map { |wd| [wd.name, wd.id] }\n end",
"def all_suite_times; end",
"def all_suite_times; end",
"def populate_groups_for_round i=@round\r\n temp_groups = []\r\n (1..@number_of_groups).each_entry do |x|\r\n temp_group = Group.new(:position => i, :day => x, :schedule_dataset => self)\r\n temp_groups.push(temp_group)\r\n end\r\n\r\n # Add seminarians who need to be assigned to a single day\r\n seminarians_left = seminarians_for_round(i)\r\n seminarians_left.shuffle.each do |sem|\r\n possible_grps = sem.possible_groups(temp_groups)\r\n sem.add_to_group(possible_grps.first) if possible_grps.count == 1 && !possible_grps.first.full?\r\n end\r\n\r\n # Add seminarians with too many duplicates to a group with least number of seminarians\r\n seminarians_left = seminarians_for_round(i)\r\n seminarians_left.shuffle.each do |sem|\r\n possible_grps = sem.possible_groups(temp_groups).sort_by{|g| g.seminarians.count}\r\n sem.add_to_group(possible_grps.first) if sem.duplicate_days >= @duplicate_days_allowed && !possible_grps.first.full?\r\n end\r\n\r\n # Add at least one seminarian to each group\r\n seminarians_left = seminarians_for_round(i)\r\n seminarians_left.shuffle.each do |sem|\r\n possible_grps = sem.possible_groups(temp_groups).shuffle\r\n sem.add_to_group(possible_grps.first) if possible_grps.count < @number_of_groups && possible_grps.first.seminarians.count == 0\r\n end\r\n\r\n seminarians_left = seminarians_for_round(i)\r\n \r\n while seminarians_left.any? do\r\n\r\n #Find the smallest groups\r\n smallest_number = temp_groups.sort_by{|g| g.seminarians.count}.first.seminarians.count\r\n small_groups = temp_groups.select{|tg| tg.seminarians.count == smallest_number}\r\n\r\n best_match = nil\r\n best_score = 9000\r\n\r\n small_groups.shuffle.each do |group|\r\n seminarians_left.shuffle.each do |sem|\r\n \r\n #Find the best match of seminarians and small groups\r\n if sem.score_for_group(group) < best_score\r\n best_match = [sem, group]\r\n best_score = sem.score_for_group(group)\r\n end\r\n end\r\n end\r\n \r\n best_match.first.add_to_group(best_match.second) if best_match\r\n seminarians_left = seminarians_for_round(i)\r\n end\r\n \r\n temp_groups.each{|g| @groups.push(g)}\r\n end",
"def get_group racer\n\t\tif racer && racer.birth_year && racer.gender\n\t\t\tquotient=(date.year-racer.birth_year)/10\n\t\t\tmin_age=quotient*10\n\t\t\tmax_age=((quotient+1)*10)-1\n\t\t\tgender=racer.gender\n\t\t\tname=min_age >= 60 ? \"masters #{gender}\" : \"#{min_age} to #{max_age} (#{gender})\"\n\t\t\tPlacing.demongoize(:name=>name)\n\t\tend\n\tend",
"def show_group\r\n show_group_by_id()\r\n end",
"def find_someday\n self.all(\n :completed_at => nil, \n :someday => true,\n :order => [:title])\n end",
"def calories_week(db, member_id)\n total_calories= []\n t = DateTime.now\n past_week = ((t-6)..t).map{ |date| date.strftime(\"%m-%d\") }\n past_week.each do |x|\n calories_date= db.execute(\"SELECT * FROM calories WHERE member_id='#{member_id}' AND day='#{x}' \")\n calories_date.each do |cals|\n total_calories << cals['amt_burned']\n end \n end \n total_calories.inject(:+)\nend",
"def wday() end",
"def grouped_happening_cases(this)\n\t\t\tsession_id_list = []\n\t\t\tthis.offering_sessions.each do |os|\n\t\t\t\tsession_id_list << os.id\n\t\t\tend\n\n\t\t\tsorted_happening_cases = HappeningCase.where(happening_type: \"OfferingSession\", happening_id: session_id_list).group_by(&:date_and_time)\n\t\tend",
"def batched_team_support_days(single_days)\n single_days.chunk_while do |before, after|\n after.developer == before.developer &&\n after.ops_eng == before.ops_eng &&\n after.ooh1_person == before.ooh1_person &&\n after.ooh2_person == before.ooh2_person &&\n after.day - before.day <= 3\n end\n end",
"def mds_needing_scoring\n Matchday.where(locked: true, scored: false).pluck(:week)\n end",
"def index\n @moods = current_user.moods.order(\"date DESC\")\n\n respond_to do |format|\n format.html do\n @moods_grouped_by_date = @moods.group_by { |m| m.date }\n end\n format.json { render json: @moods }\n end\n end",
"def events_seven_days()\n events = []\n today = Date.today\n for i in 0..6 do\n events += events_by_date(today + i)\n end\n return events\nend",
"def follow_up_patients_by_month\n date_truncate_string = date_truncate_sql('blood_pressures', 'recorded_at', period: 'month')\n\n @follow_up_patients_by_month ||=\n BloodPressure\n .select('facilities.id AS facility_id',\n date_truncate_string,\n 'count(blood_pressures.id) AS blood_pressures_count')\n .left_outer_joins(:user)\n .left_outer_joins(:patient)\n .joins(:facility)\n .where(facility: @facility)\n .where(deleted_at: nil)\n .group('master_users.id', date_truncate_string)\n .where(\"patients.recorded_at < #{date_truncate_string}\")\n .order('master_users.id')\n .distinct\n .count('patients.id')\n\n group_by_user_and_date(@follow_up_patients_by_month, :follow_up_patients_by_month)\n end",
"def index\n @form_chagas = FormChaga.all\n query = queryGrafico('form_chagas')\n #query = \"SELECT date_trunc('month', created_at) as label, COUNT(*) AS value FROM form_chagas where form_chagas.created_at>='2016-01-01 00:00:00' and form_chagas.created_at<='2016-12-12 24:00:00' GROUP BY 1 ORDER BY label ASC\"\n @reporte_mensual_chagas = Paciente.find_by_sql(query)\n gon.query = query\n gon.reporte_mensual_chagas = @reporte_mensual_chagas\n end",
"def notifications\n Group.find_by_sql(\"\n SELECT * FROM (\n SELECT * FROM(\n SELECT u.id, u.name, '0' sp_id, u.bio info, gu.updated_at, 'new_user' type\n FROM users u, group_users gu\n WHERE u.id = gu.user_id AND gu.group_user_state_id = 1 AND gu.group_id = \"+self.id.to_s+\"\n ORDER BY gu.updated_at DESC \n LIMIT 35) NUEVOS_USUARIOS\n UNION ALL\n SELECT * FROM(\n SELECT s.id, s.sci_name name, '0' sp_id, s.family info, sg.updated_at, 'new_species' type\n FROM species s, species_groups sg\n WHERE sg.species_id = s.id AND sg.species_group_state_id = 1 AND sg.group_id = \"+self.id.to_s+\"\n ORDER BY sg.updated_at DESC \n LIMIT 35) NUEVAS_ESPECIES\n UNION ALL\n SELECT * FROM(\n SELECT u.id, u.name, s.id sp_id, s.sci_name info, r.updated_at, 'review' type\n FROM users u, species s, reviews r, models m, group_users gu, species_groups sg\n WHERE u.id = r.user_id AND u.id = gu.user_id AND m.id = r.model_id AND s.id=m.species_id AND s.id = sg.species_id AND gu.group_user_state_id = 1 AND sg.species_group_state_id = 1 AND gu.group_id = \"+self.id.to_s+\" AND sg.group_id = \"+self.id.to_s+\"\n ORDER BY sg.updated_at DESC\n LIMIT 35) NUEVA_EDICION\n )\n ORDER BY updated_at DESC\n LIMIT 35\")\n end",
"def index\n @schedule_entries = ScheduleEntry.all\n current_date = Date.today\n monday = current_date.monday\n dates_this_week = [monday, monday.next, monday.next.next, monday.next.next.next, monday.next.next.next.next]\n @grouped_periods = Period.where(:date => dates_this_week).group_by {|period| period.num}.values\n end",
"def show\n @goal = Mg::Goal.find(params[:id])\n\n @results_per_day = []\n created_at = @goal.created_at\n running_date = Time.utc( created_at.year, created_at.month, created_at.day )\n \n while running_date < Time.zone.now\n @results_per_day.push({ :date => running_date.to_i * 1000, :val => @goal.mg_records.find( :all, :conditions => { :created_at => running_date..(running_date + 60 * 60 * 24) } ).count })\n running_date += 60 * 60 * 24\n end\n \n @results_by_gmt = {}\n \n @goal.mg_goal_meta_types.each do |gmt|\n @results_by_gmt[gmt.id] = []\n \n gmt.meta.all(:select => \"data, count(*) as count\", :group => \"data\").each do |meta|\n next if meta.data.nil?\n if gmt.meta_type == 'cs_meta' || gmt.meta_type == 'gs_meta' \n @results_by_gmt[gmt.id].push( { :name => meta.data, :val => meta.count, :title => meta.data } )\n #@results_by_gmt_titles[gmt.id].merge!({ i => meta.data })\n else\n @results_by_gmt[gmt.id].push( { :name => meta.data, :val => meta.count, :title => meta.data } )\n end\n \n end\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @goal }\n end\n end",
"def current_group\n end",
"def showtimes_json(day)\n showtimes_by_cinemas_json(CONST::WORD_DAY_HASH[day]).to_json\n end",
"def show\n @tournament_day = TournamentDay.find(params[:id], :include => :tournament)\n @series = Series.find_all_by_tournament_day_id(@tournament_day.id, :include => [{:tournament_day => :tournament}], :order => \"long_name\")\n @tournament_days = TournamentDay.all#, :conditions => [\"day >= ?\", Time.now]\n\n respond_to do |format|\n format.html # show.erb\n format.xml { render :xml => @tournament_day }\n end\n end",
"def show\n @group = Group.find_by(id: params[:id]) || not_found\n @entity = @group.entity\n not_found unless @group.status?\n redirect_to(action: 'index') && return unless @group.member?(current_user)\n @events = @group.events.future.confirmed.by_date\n @members = @group.members.by_name\n session[:current_group_id] = @group.id\n end",
"def show\n @grocery_groups = @grocery.groups\n end",
"def visits_by_day\n render json: Ahoy::Visit.this_month.group_by_day(:started_at).count\n end",
"def groups_where_member\n self.groups-self.groups_where_admin_and_wrapper\n end",
"def index\n @showtimes = Showtime.all.sort_by(&:start_time).group_by{ |showtime| showtime.start_time.to_date}.transform_values do |shows|\n shows.group_by{ |showtime| showtime.movie.title }\n end\n end",
"def index\n @things = current_user.things.where('the_date >= ?', Date.today ).order('the_date ASC')\n @thing_day = @things.group_by { |t| t.the_date }\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @things }\n end\n end",
"def index\n @groups = Group.where(current: false)\n @current_groups = Group.where(current: true)\n end",
"def present_group(metric, group)\n occurences = group.size\n case(metric)\n when :reek\n \"found #{occurences} code smells\"\n when :roodi\n \"found #{occurences} design problems\"\n when :churn\n \"detected high level of churn (changed #{group[0].times_changed} times)\"\n when :flog\n complexity = get_mean(group.column(\"score\"))\n \"#{\"average \" if occurences > 1}complexity is %.1f\" % complexity\n when :saikuro\n complexity = get_mean(group.column(\"complexity\"))\n \"#{\"average \" if occurences > 1}complexity is %.1f\" % complexity\n when :flay\n \"found #{occurences} code duplications\"\n when :rcov\n average_code_uncoverage = get_mean(group.column(\"percentage_uncovered\"))\n \"#{\"average \" if occurences > 1}uncovered code is %.1f%\" % average_code_uncoverage\n else\n raise AnalysisError, \"Unknown metric #{metric}\"\n end\n end",
"def digest_stickies_created\n all_stickies.where(project_id: all_digest_projects.select(:id), completed: false).where('created_at > ?', (Time.zone.now.monday? ? Time.zone.now - 3.day : Time.zone.now - 1.day))\n end",
"def show_events_on_date(date)\n return nil unless events_at?(date)\n\n events = @calendar_events[date]\n puts 'You have following events on this date:'\n print_events(events)\n events\n end",
"def set_seeds\n # check if raid is first of the raid week\n # Set Chronic time_class\n Chronic.time_class = ActiveSupport::TimeZone.new(Settings.blizzard.reset.zone)\n reset_time = Chronic.parse(\"last #{Settings.blizzard.reset.day} #{Settings.blizzard.reset.time}\")\n # Find raids since reset\n raids = Raid.between(after: reset_time)\n # If raid list *includes* this raid and\n # this is first raid since reset, proceed\n if raids.include?(self) && raids.first.id == self.id\n # Reset all :seeded flags for active Standing\n Standing.reset_seeded\n # Set :seeded for all attendees\n # Get all standing_events where player :Attended, grouped by standing\n standing_events.attended(raid: self).group_by(&:standing).each do |standing|\n standing[0].update(seeded: true)\n end\n end\n # Reset Chronic zone\n Chronic.time_class = Time.zone\n end",
"def index\n @days_ago = 14\n @recent_handers = Activity.all(:conditions => ['controller =? AND action IN (?) AND created_at > ?', \"involvements\", %w(create update upload), @days_ago.days.ago]).group_by(&:whodiddit)\n @deadbeats = Activity.all(:conditions => ['whodiddit NOT IN (?)', Activity.find_all_by_action(%w(upload create update)).map(&:whodiddit).uniq]).group_by(&:whodiddit)\n @recent_uploads = StudyUpload.all(:include => :study, :order => \"created_at DESC\", :conditions => ['created_at > ?', @days_ago.days.ago])\n end",
"def index\n @events = Event.where(\"group_id = ?\", params[:group_id])\n end",
"def test_17\n ActiveRecord::Base.logger.debug \"start season test_17 #{ Season.find_by_date(Date.new(2011,04,14)).name}\"\n ActiveRecord::Base.logger.debug \"end season test_17 #{ Season.find_by_date(Date.new(2011,04,16)).name}\"\n Charges.new(Date.new(2011,04,14),\n Date.new(2011,04,16),\n\t\t1, 1, 20)\n charges = Charge.find_all_by_reservation_id 20\n assert_equal 2, charges.size\n assert_equal 1, charges[0].season_id\n assert_equal 1.0, charges[0].period.to_f\n assert_equal 12.0, charges[0].rate.to_f\n assert_equal 12.0, charges[0].amount.to_f\n assert_equal Charge::DAY, charges[0].charge_units\n assert_equal 2, charges[1].season_id\n assert_equal 1.0, charges[1].period.to_f\n assert_equal 15.0, charges[1].rate.to_f\n assert_equal 15.0, charges[1].amount.to_f\n assert_equal Charge::DAY, charges[1].charge_units\n end",
"def possible_groups groups\r\n possible_grps = groups.select {|g| !self.days_assigned.include?(g.day)}\r\n\r\n if possible_grps.count == 0 && self.duplicate_days < self.schedule_dataset.duplicate_days_allowed\r\n return groups\r\n\r\n # Return the groups with days that the seminarian has not been assigned to\r\n else\r\n return possible_grps\r\n end\r\n end",
"def cwday\n end",
"def group\n @wbgts = Wbgt.find_measure_group(params[:wbgt_id], params[:machine_id])\n\n set_graph\n end",
"def show\n # byebug \n @group_members=@group.group_members\n # @group_members\n end",
"def targets_group? group\n index = Activity::MUSCLE_GROUP_VALUES.index(group)\n return false if index.nil?\n return false if muscle_groups[index] == \"0\"\n return true\n end",
"def open_groups\n Group.find_open self.id\n end",
"def light_groups\n {\n 0 => :cars_north_south,\n 1 => :pedestrians_north_south,\n 2 => :center_light,\n 3 => :cars_east_west,\n 4 => :pedestrians_east_west,\n 5 => :state_light\n }\nend",
"def all_monitors\n web + groups\n end",
"def all_events(start, finish, include_assignments = false, child = nil) # last param used in student & teacher\r\n tracks = school.current_term.tracks\r\n (universal_events(start, finish, tracks) + \r\n Event.where([\"invitable_type = 'Staff' AND invitable_id = ? AND date BETWEEN ? AND ?\", school_id, start, finish]) + \r\n Event.where([\"invitable_type = 'Teachers' AND creator_id = ? AND date BETWEEN ? AND ?\", id, start, finish])).sort_by{|event|event.date} \r\n #(audience_type == Group && groups.map(&:id).include?(audience_id)\r\n end",
"def last_7_day_kwh_usage_by_day\n usage_data = []\n Time.now.utc.to_date.downto(6.days.ago.utc.to_date).each do |date|\n usage_data << total_day_kwh_usage_on(date).round(2)\n end\n usage_data\n end",
"def date_groups(table, column) # rubocop:disable Metrics/MethodLength\n query = <<~SQL.squish\n SELECT date_trunc('year', #{column}) AS year, count(*) as events\n FROM #{table}\n WHERE #{column} IS NOT NULL\n GROUP BY year\n ORDER BY year ASC\n SQL\n\n ApplicationRecord.connection.execute(query)\n .map { |row| [row[\"year\"].year, row[\"events\"]] }\n .select { |row| (2004..Time.current.year).cover? row.first }\n .to_h\n end",
"def index\n sanchaypatras = current_user.sanchaypatras.not_expired\n sanchaypatras = sanchaypatras.where(\"reg_number ilike ?\",\"%#{params[:reg_number]}%\") if params[:reg_number].present?\n sanchaypatras = sanchaypatras.where(\"owner_name ilike ?\",\"%#{params[:owner_name]}%\") if params[:owner_name].present?\n @sanchaypatras_in_groups = sanchaypatras.order(:active_date).group_by(&:interval_month)\n end",
"def index\n if params[:machine_id]\n begin\n machine = Machine.friendly.find(params[:machine_id])\n rescue\n machine = Machine.find(params[:machine_id])\n end\n @musics = machine.musics\n if params[:season_id].present?\n begin\n season = Season.friendly.find(params[:season_id])\n rescue\n season = Season.find(params[:season_id])\n end\n @musics = @musics.where(season: season)\n end\n else\n @musics = Music.all\n end\n end",
"def meetings_on(day)\n ((@ending_meetings_by_days[day] || []) + (@starting_meetings_by_days[day] || [])).uniq.sort_by {|meeting| meeting.start_date}\n end",
"def print_instances_details(only_running=true)\n @groups.values.each_with_index do |instances, i|\n instances.each do |instance|\n if only_running and (not instance.ready?)\n next\n end\n puts sprintf \"%02d: %-20s %-20s %-20s %-20s %-25s %-20s (%s) (%s) (%s)\",\n i, (instance.tags[\"Name\"] || \"\").green,instance.private_dns_name ,instance.id.red, instance.flavor_id.cyan,\n instance.dns_name.blue, instance.availability_zone.magenta, (instance.tags[\"role\"] || \"\").yellow,\n (instance.tags[\"group\"] || \"\").yellow, (instance.tags[\"app\"] || \"\").green\n end\n end\n end",
"def battlegroups\r\n BnetApi::make_request('/wow/data/battlegroups/')\r\n end",
"def show\n @hack_meets = @hack_member.hack_meets.order(:hack_date)\n end",
"def memberships_to_notify(date)\n treatment_group_memberships\n .status_enrolled\n .joins(treatment_group: :reminder_templates)\n .where(\"date_trunc('day', expected_return_date) + make_interval(days := reminder_templates.remind_on_in_days) = ?\", date)\n end",
"def list_days\n puts \"This Week's Forecast:\"\n\n Scraper.scrape_cast \n\n days = Project1::Forecast.all\n days.map.with_index(1) do |day, i|\n puts \"#{i}. #{day.name}\"\n end\n end",
"def each_monday( n=1, offset=0, dur=1); each_wdays(self.Mon,n,offset,dur); end",
"def filter_trending_days(topic, trending_days)\n trending_days.select do |day|\n dbday_id = Day.find_by(date: day).id\n !Popularity.exists?(topic_id: topic.id, day_id:dbday_id)\n end\nend"
] | [
"0.6002566",
"0.58569956",
"0.56904715",
"0.5617393",
"0.5524284",
"0.54171973",
"0.54171973",
"0.54171973",
"0.5362645",
"0.5356421",
"0.5317589",
"0.52978045",
"0.5297365",
"0.5277178",
"0.52527046",
"0.5252113",
"0.5245826",
"0.5243614",
"0.52301645",
"0.5191251",
"0.5168941",
"0.5161405",
"0.51278996",
"0.51196665",
"0.5103306",
"0.5103306",
"0.50944084",
"0.50756216",
"0.5072072",
"0.5068722",
"0.50656253",
"0.50626457",
"0.5058285",
"0.50566274",
"0.50235033",
"0.50203013",
"0.5018446",
"0.5009134",
"0.50080216",
"0.5004128",
"0.4999228",
"0.4997936",
"0.498979",
"0.49876684",
"0.4986173",
"0.4986173",
"0.49725336",
"0.49615192",
"0.49540845",
"0.49520102",
"0.49474978",
"0.4932073",
"0.4918011",
"0.49155208",
"0.4915132",
"0.4912274",
"0.4906118",
"0.48997238",
"0.48990485",
"0.48972666",
"0.48970672",
"0.4891999",
"0.4891079",
"0.48866615",
"0.4884935",
"0.48784676",
"0.48775047",
"0.48689997",
"0.48651427",
"0.48553944",
"0.48536834",
"0.48531285",
"0.4851136",
"0.48435476",
"0.4842584",
"0.48386157",
"0.4837166",
"0.483683",
"0.48348042",
"0.4828645",
"0.48272964",
"0.4821583",
"0.48181748",
"0.48170096",
"0.4816836",
"0.48151344",
"0.48132885",
"0.48119503",
"0.48094285",
"0.4808723",
"0.48041293",
"0.48009652",
"0.47989172",
"0.47982702",
"0.4794614",
"0.47905043",
"0.47890916",
"0.47829035",
"0.4782472",
"0.47795734"
] | 0.75964785 | 0 |
1. I can return the list of all the days I worked out | def list_of_days_worked_out
array = []
workouts = Workout.all.find_all do |workout|
workout.user_id == self.id
end
dates = workouts.each do |workout|
array << workout.date
end
array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_work_days\n puts \"Getting work days...\"\n work_days = []\n biweek = get_biweek\n week_1 = @schedule[biweek[0]].compact.uniq\n week_2 = @schedule[biweek[1]].compact.uniq\n\n @schedule.each_with_index do |row, i|\n DAYS.each_with_index do |day, j|\n date = ( i < biweek[1] ? week_1[j] : week_2[j] )\n day_name = day[:day]\n name = row[day[:name]]\n hours = row[day[:hours]]\n if name && hours && name.downcase.include?(@person.downcase)\n work_days.push({\n :name => @person,\n :date => get_date(date, hours)\n })\n end\n end\n end\n puts \"Work days:\\n#{work_days}\"\n return work_days\nend",
"def day_meetings\n days = []\n @course.weekdays.each_char.each_with_index do |w, i|\n days.push(DAYS_AS_SYM[i]) if w.to_i == 1\n end\n days\n end",
"def events_seven_days()\n events = []\n today = Date.today\n for i in 0..6 do\n events += events_by_date(today + i)\n end\n return events\nend",
"def list_days\n puts \"This Week's Forecast:\"\n\n Scraper.scrape_cast \n\n days = Project1::Forecast.all\n days.map.with_index(1) do |day, i|\n puts \"#{i}. #{day.name}\"\n end\n end",
"def work_day_employees\n all_week_employees = self.current_columns.each_slice(2).to_a\n\n return all_week_employees[Date.today.wday]\n end",
"def trucks_open_today\n trucks = self.class.get_truck_data\n date = self.class.get_time\n\n trucks_today = []\n trucks.each do |truck|\n if date.strftime(\"%A\") == truck[\"dayofweekstr\"]\n trucks_today << truck[\"applicant\"]\n end \n end\n p trucks_today\n end",
"def days\n return self.day_shifts.keys\n end",
"def days_worked\n days = account.account_setting.working_days\n Hash[days.map { |k,v| [k, (v == \"1\")] }]\n end",
"def week\n first_day_of_week = @date.monday\n \n days_of_week = []\n 7.times do |time|\n days_of_week << day_and_types(first_day_of_week + time.days)\n end \n \n days_of_week\n end",
"def days_assigned\r\n days_assigned = []\r\n self.groups.each {|g| days_assigned.push(g.day)}\r\n return days_assigned\r\n end",
"def workdays(calendar = Spok.default_calendar)\n (@start_date..@end_date).to_a.delete_if{ |date| Workday.restday?(date, calendar: calendar) }\n end",
"def weekdays\n wdays = []\n wdays << 0 if sun\n wdays << 1 if mon\n wdays << 2 if tue\n wdays << 3 if wed\n wdays << 4 if thu\n wdays << 5 if fri\n wdays << 6 if sat\n\n wdays\n end",
"def get_not_worked_days start_date, end_date, employee_id\n not_worked_days = []\n if start_date != \"\" && end_date != \"\"\n start_date = DateTime.parse(start_date)\n end_date = DateTime.parse(end_date)\n for i in 0..get_difference_days(start_date, end_date) + 1\n current_date = start_date + i.days\n if !is_weekend?(current_date) && didnt_come_to_work?(employee_id, current_date)\n not_worked_days << current_date\n end\n end\n end\n return not_worked_days\n end",
"def getDatesToDisplay()\n\n\t\tnumDays = 10\n\t\tretDays = []\n\n\t\tfor i in 0..10\n\t\t\ta_date = (DateTime.now + i.days)\n\t\t\tretDays.push(a_date)\n\t\tend\n\n\t\treturn retDays\n\tend",
"def days\n attendances.order(date: :asc).map(&:date)\n end",
"def non_working_week_days\n @non_working_week_days ||= begin\n days = [] # Setting.non_working_week_days\n if days.is_a?(Array) && days.size < 7\n days.map(&:to_i)\n else\n []\n end\n end\n end",
"def day_in_week_str\n\t\tdays = []\n\t\ttoday = Time.now\n\t\tdays.push(formatted(today))\n\t\ttoday_week_day = today.wday\n\t\tanothers = (0..6).select {|e| e != today_week_day}\n\t\tanothers.map do |e|\n\t\t\tdays.push(formatted(Time.at(today.to_i - e*day_second)))\n\t\tend\n\n\t\tdays.sort\n\tend",
"def potential_working_days(start_date, end_date)\n days_worked = (start_date..end_date).select do |day|\n day = day.strftime(\"%A\").downcase.to_sym\n works_on?(day)\n end\n days_worked.count\n end",
"def _week_day_numbers\n week_day_start = self.week_day_start\n week_day_start.capitalize if week_day_start.is_a? String\n [0, 1, 2, 3, 4, 5, 6].partition {|on| on >= day_names.index(week_day_start)%7 }.flatten\n end",
"def available_days\n unavailable = []\n unavailable = collection_of_unavailable_days.split unless collection_of_unavailable_days.blank?\n (self.meeting.calc_tentative_days - unavailable).join(' ')\n end",
"def calculate_week_meetings\n @week_meeting_dates.map do |week_meetings|\n week_meeting_days = week_meetings.map { |date| date.strftime('%a') }\n \"(#{week_meeting_days.join(', ')})\"\n end\n end",
"def day_in_week_int \n\t\tdays = []\n\t\ttoday = Time.now\n\t\tdays.push(today.to_i)\n\t\ttoday_week_day = today.wday\n\t\tanothers = (0..6).select {|e| e != today_week_day}\n\t\tanothers.map do |e|\n\t\t\tdays.push(today.to_i - e*day_second)\n\t\tend\n\n\t\tdays.sort\n\tend",
"def displayAll (period)\n \t# We take only days that fall in week of Date.today.cweek\n \t@daysFromWeek = []\n \t@daysFromMonth = []\n \t#@daysFromYear = []\n \t@currentWeek = Date.today.cweek\n \t@currentMonth = Date.today.month\n \t@currentYear = Date.today.year\n \t# iterate over all the days and add days from the current week\n \t# save the time values from these\n \t@days.each { |day|\n \t\tif (period == 'Week' && day.day.cweek == @currentWeek)\n \t\t\t@daysFromWeek.push(day.time)\n \t\tend\n\n \t\tif (period == 'Month' && day.day.month == @currentMonth)\n \t\t\t#@time += \n \t\t\t@daysFromMonth.push(day.time)\n \t\tend\n \t\t# Year is going to be a little trickier\n \t\t# We need to go through all the days and split them \n \t\t# by month. all date.month == 1 will go into a[0]...\n \t\t#if period == 'Year' && day.day.year == @currentYear \n \t}\n\n \tif period == 'Week'\n \t\treturn @daysFromWeek\n \telsif period == 'Month'\n \t\treturn @daysFromMonth\n \tend\n\n end",
"def day_names\n self.class.day_names\n end",
"def get_days\n\t\tbool_array = []\n\n\t\tbool_array << self[:monday]\n\t\tbool_array << self[:tuesday]\n\t\tbool_array << self[:wednesday]\n\t\tbool_array << self[:thursday]\n\t\tbool_array << self[:friday]\n\t\tbool_array << self[:saturday]\n\t\tbool_array << self[:sunday]\n\n\t\treturn bool_array\n\tend",
"def day_times\n @day_times ||= available_times.map(&:day_time)\n @day_times\n end",
"def dates(n = 0, per_page = 10)\n @dates = []\n n.upto(n + per_page) do |n|\n if first_at.wday == wday\n date = first_at + (n * 7).days\n elsif first_at.wday > wday\n date = first_at + (7 - first_at.wday + wday).days + (n * 7).days\n elsif first_at.wday < wday\n date = first_at + (wday - first_at.wday).days + (n * 7).days\n end\n\n @dates << [date, WorkTime.find_by_start_date(date)]\n end\n return @dates\n end",
"def in_transit_days\n \tresult = []\n \tdelivery_duration.times do |num|\n active_day = num_to_day((day_to_num(self.order_day) + num) % 7)\n \t\tresult << active_day if active_day != self.order_day && active_day != self.delivery_day\n \tend\n \tresult\n end",
"def list_days\n\t\td = [\"Mondays,\", \"Tuesdays,\", \"Wednesdays,\", \"Thursdays,\", \"Fridays,\", \"Saturdays,\", \"Sundays,\"]\n\t\tx = []\n\n\t\tboolDays = get_days\n\n\t\tfor i in 0..d.length\n\t\t\tif boolDays[i] == true\n\t\t\t\tx << d[i]\n\t\t\tend\n\t\tend\n\t\tx.insert(x.length - 1, \"and\")\n\t\treturn (x*\" \").chop\n\tend",
"def exercise_on_a_day(date)\n #iterate through workouts and find workouts.user_id == self\n my_workouts = Workout.all.select do |workout|\n workout[\"user_id\"] == self[\"id\"]\n end\n # find where date == workout date\n workouts_for_date = my_workouts.find_all do |workouts|\n workouts[\"date\"] == date\n end.map {|workout_instance| workout_instance.exercise_id}\n \n exercise_array = []\n exercise_list = workouts_for_date.each do |exercise_id|\n Exercise.all.each do |exercise_instances|\n exercise_array << exercise_instances.name if (exercise_instances.id == exercise_id)\n end\n end\n \n if exercise_array == []\n return \"Sorry. Doesn't look like you worked out on #{date}.\".colorize(:light_cyan)\n else\n return exercise_array\n end\n end",
"def all_offdays\n offdays = []\n self.courts.includes(:day_offs).each do |c|\n offdays = offdays + c.day_offs\n end\n offdays = offdays + self.day_offs\n end",
"def weekdays\n result = veeamconfig('schedule', 'show', '--jobId', get_job_id).lines\n\n if result[0].strip == 'Every day'\n ['daily']\n else\n result[0].strip.split(': ')[1].split(', ')\n end\n end",
"def weekly_availability\n return [] if course.nil?\n\n availability = [\n { day: 'monday', count: 0, start_times: [] },\n { day: 'tuesday', count: 0, start_times: [] },\n { day: 'wednesday', count: 0, start_times: [] },\n { day: 'thursday', count: 0, start_times: [] },\n { day: 'friday', count: 0, start_times: [] },\n { day: 'saturday', count: 0, start_times: [] },\n { day: 'sunday', count: 0, start_times: [] }\n ]\n\n course.plannings.order('start_time ASC, end_time ASC').each do |planning|\n next if planning.week_day.nil? or Date::DAYNAMES[planning.week_day].nil?\n course_day = Date::DAYNAMES[planning.week_day].downcase\n day_availability = availability.detect { |d| d[:day] == course_day }\n\n day_availability[:count] += 1\n day_availability[:start_times] << I18n.l(planning.start_time, format: :short) if planning.start_time\n end\n\n availability\n end",
"def business_days\n @business_days ||= days.select(&:business_day?)\n end",
"def w_day; end",
"def days\n monday..sunday\n end",
"def get_list_for(day, hour, dayname, today)\n months = [_(:january), _(:february), _(:march), _(:april), _(:may), _(:june),\n _(:july), _(:august), _(:september), _(:october), _(:november), _(:december)]\n nobroad = \" #{_(:no_broadcast_on)}\"\n broad = \"#{_(:broadcast_on)}\"\n\n aday = DatesSchedule.get_day(@language, day)\n if aday.kind_of?(Array) and !aday.blank?\n d = aday[0].d\n m = aday[0].m - 1\n else\n d = 1\n m = 0\n end\n dm = \"#{d} #{months[m]}\"\n\n alist = Listing.get_day(@language, day)\n return \"<h3>#{nobroad} #{dayname}, #{dm}</h3>\" if alist.blank?\n list = \"<h3>#{broad} #{dayname}, #{dm}</h3>\"\n alist.each_with_index { |item, index|\n time = sprintf(\"<div class='time'>%02d:%02d - %s</div>\",\n item.start_time / 100,\n item.start_time % 100,\n calc_end_time(item.start_time, item.duration))\n title = item.title.gsub '[\\r\\n]', ''\n title.gsub! '<div>', ''\n title.gsub! '</div>', ''\n descr = item.descr.gsub '[\\r\\n]', ''\n descr.gsub!(/href=([^\"])(\\S+)/, 'href=\"\\1\\2\" ')\n descr.gsub!('target=_blank', 'class=\"target_blank\"')\n descr.gsub!('target=\"_blank\"', 'class=\"target_blank\"')\n descr.gsub!('&main', '&main')\n descr.gsub!('<br>', '<br/>')\n descr.gsub!(/<font\\s+color\\s*=\\s*[\"\\'](\\w+)[\"\\']>/, '<span style=\"color:\\1\">')\n descr.gsub!(/<font\\s+color\\s*=\\s*[\"\\'](#[0-9A-Fa-f]+)[\"\\']>/, '<span style=\"color:\\1\">')\n descr.gsub!('</font>', '</span>')\n list += \"<div class='item#{index % 2}'>#{time}<div class='title icon-plus'>#{title}</div><div style='display:none;' class='descr'>#{descr}</div></div>\"\n }\n\n list + '<div class=\"item2\"> </div>'\n end",
"def calendar_wdays(starting_day = 0)\n start_week = Date.today.beginning_of_week + (starting_day - 1).days # In rails week start in monday and monday.wday is 1\n (start_week...start_week+7.days).collect { |day| I18n.l(day, :format => '%A') }\n end",
"def all_winter_holiday_supplies(holiday_hash)\n\twinter_day = []\n holiday_hash.collect do |season, holiday|\n if season == :winter\n holiday.collect do |name, day|\n winter_day << day\n #day\n end\n #winter_day\n end\n #winter_day\n end\n winter_day.flatten\n end",
"def calculate_workdays\n iteration_start_date = Date.parse(@iteration.start_date)\n iteration_end_date = Date.parse(@iteration.end_date)\n total_iteration_days = iteration_end_date - iteration_start_date + 1\n # number of total possible workdays within entire iteration\n total_workdays = 0\n curr_day = iteration_start_date\n for i in 1..total_iteration_days\n total_workdays += 1 if $conn.workspace.is_workday?(curr_day.to_s)\n curr_day += 1\n end\n total_workdays\n end",
"def week_days(options={}, &block)\n start_date = self\n result = []\n (start_date-wday_offset).step 7 do |a_day|\n a_day.week_day_start = self.week_day_start\n if block_given?\n yield a_day\n else\n result.push(a_day)\n end\n end\n result\n end",
"def all_working_days_of_month\n ending_of_month.downto(beginning_of_month).select(&:working_day?)\n end",
"def week_days\n {\n \"1\" => 'mon',\n \"2\" => 'tue',\n \"3\" => 'wed',\n \"4\" => 'thu',\n \"5\" => 'fri',\n \"6\" => 'sat',\n \"7\" => 'sun'\n }\n end",
"def all_potential_meetings\n meetings = []\n day_meetings.each do |day|\n @timeline_week_count.times do |wk|\n meetings << (@beginning_of_first_week + wk.weeks).date_of_upcoming(day)\n end\n end\n meetings.sort\n end",
"def calculate_week_meeting_dates\n meetings = []\n @timeline_week_count.times do |wk|\n week_start = @beginning_of_first_week + wk.weeks\n # This excludes Sunday, putting the end of the week at Saturday.\n week_end = week_start.end_of_week(:sunday)\n week_mtgs = []\n @meeting_dates.each do |meeting|\n next if (meeting < @course.timeline_start) || (@course.timeline_end < meeting)\n week_mtgs << meeting if date_is_between(meeting, week_start, week_end)\n end\n meetings.push week_mtgs\n end\n meetings\n end",
"def get_days\n return 0b0 if @params[:type] != 'advanced'\n\n return get_weekday_bitmask(['weekday_sun', 'weekday_mon', 'weekday_tue', 'weekday_wed', 'weekday_thu', 'weekday_fri', 'weekday_sat']) if @params[:schedule] == 'weekly'\n\n return get_month_bitmask(@params[:dates_picked]) if @params[:schedule] == 'monthly' && @params[:days] == 'specific'\n\n return get_unspecific_days\n\n end",
"def getSundays(d1,d2)\n d1 += 1 while (d1.wday != 0) # add days till starting on sunday\n sundays = []\n d1.step(d2,7) do |date| # move forward seven days for every sunday\n sundays .push date\n end\n sundays\nend",
"def next_weeks_open_house_dates(open_house_dow)\n now = Time.now\n dates = []\n (0...7).each do |day_offset|\n days = day_offset*24*60*60\n date = now + days\n if open_house_dow.include?(date.wday)\n dates << now + days\n end\n end\n dates\n end",
"def days_in_week(*days)\n @test_time = @time if @test_time.nil?\n x_in_list_of_y(@test_time.wday, Configuration.parse_range(days,0...7).flatten)\n end",
"def get_start_and_end_dates(n)\n description = Nokogiri::HTML(@description_xpath[n].text).text\n if description.include?(\"IF YOU GO\")\n description = description.split(\"IF YOU GO\")[1]\n if description.include?(\"When\" && \"Tickets\")\n description = description.split(\"When\")[1].split(\"Tickets\")[0]\n datetimes = description.gsub(\";\", \",\").split(\",\")\n @additional_datetimes = datetimes[1..-1].join(\",\") if datetimes.size > 1\n get_event_datetimes(datetimes[0])\n else\n [nil, nil]\n end\n else\n [nil, nil]\n end\n end",
"def agenda\n ret = {}\n ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'].map do |day|\n ret[day] = courses.select do |course|\n course.days and course.days.include? day[0, 2]\n end\n ret[day].reverse!\n end\n return ret\n end",
"def get_days\n sparql = SPARQL.parse(\"SELECT DISTINCT ?time\n WHERE {\n ?match <#{RDF.type}> <http://www.bbc.co.uk/ontologies/sport/Match> .\n ?match <http://purl.org/NET/c4dm/event.owl#time> ?time .\n }\")\n results = QUERYABLE.query(sparql).map { |sol| Date.parse(sol.time.to_s) }.uniq\n end",
"def get_calendar\n\t# 日付情報を格納する配列を宣言\n\tcal_data = Array.new(0)\n\n\t(1..@wday.length - 1).each do |day|\n\t\t# 曜日がnilになったら月が終わりなのでbreak\n\t\tif @wday[day] == nil\n\t\t\tbreak\n\t\tend # if\n\n\t\t# 日付と曜日番号をひとつの配列にする\n\t\tday_data = [\"#{day}\", @wday[day]]\n\n\t\t# 日付情報に日付と曜日番号の配列を追加\n\t\tcal_data << day_data\n\tend # each\n\n\t# 日付情報を返却\n\treturn cal_data\nend",
"def days_of_week\n\n # create an array for processing\n days_array = [sunday, monday, tuesday, wednesday, thursday, friday, saturday]\n int_array = Array.new\n for day in days_array\n day ? int_array.push(1) : int_array.push(0)\n end\n\n # process with little recursive function\n r(int_array, 0)\n # fix first value, see note below\n int_array[0] == -1 ? int_array[0] = 1 : nil\n\n # final passes, change values into useable string\n int_array[0] == 1 ? int_array[0] = 'Su' : nil\n int_array[1] == 1 ? int_array[1] = 'M' : nil\n int_array[2] == 1 ? int_array[2] = 'Tu' : nil\n int_array[3] == 1 ? int_array[3] = 'W' : nil\n int_array[4] == 1 ? int_array[4] = 'Th' : nil\n int_array[5] == 1 ? int_array[5] = 'F' : nil\n int_array[6] == 1 ? int_array[6] = 'Sa' : nil\n\n int_array.delete(0)\n int_array.map{ |x| x == -1 ? '-' : x}.uniq.join\n\n end",
"def weekday(days)\nt = Date.today\narr = []\n days.times do\n arr << \"ok\" if t.saturday? || t.sunday?; t = t - 1\n end\n arr.count\nend",
"def available_day_ids\n available_days.map(&:id)\n end",
"def dates_requiring_data\n collected = Dir.glob(File.join(@config[:data_dir], \"*-*-*.{csv,espi}\")).map { |f| File.basename(f).split(\".\")[0] }\n all_days = []\n\n count_of_days = (Date.today - @config[:start_date]).to_i\n\n count_of_days.times do |i|\n all_days << (@config[:start_date] + i).strftime(\"%Y-%m-%d\")\n end\n\n (all_days - collected).map { |d| Date.parse(d) }\n end",
"def get_dates_matche (date_matche,days_game)\n flag_continue=true\n while flag_continue do\n date_matche = date_matche + 1.days\n day_week=date_matche.wday\n if days_game.include?(day_week.to_s)\n return date_matche\n end \n end\n end",
"def all_actual_meetings\n # Exceptions are positive (Tue/Thu class meeting on Wed)\n # or negative (Tue/Thu class doesn't meet on Tue)\n positive_exceptions = exceptions_as_dates - all_potential_meetings\n all_potential_meetings - exceptions_as_dates + positive_exceptions\n end",
"def to_s\n day_abbrs = day_hash\n i = 0\n #Array of consec_days arrays\n consec_day_groups = []\n #Array of consecutive days. This gets\n #reset when we find a day that is not\n #part of a consecutive set of days.\n consec_days = []\n\n @day_ids.each do |day_id|\n if i == 0\n #add the day abbr for this day if this is the first\n #element of @day_ids.\n consec_days << day_abbrs[day_id.to_s]\n\n elsif @day_ids[i-1] == (day_id - 1)\n #if this is not the first day in @day_ids, check\n #if the previous day in the array is the real life\n #previous day of the week. If so, add it to the\n #consec_days array\n consec_days << day_abbrs[day_id.to_s]\n else\n #otherwise start a new consec_days array and\n #add the current consec_days array to the\n #consec_day_groups array.\n consec_day_groups << consec_days\n\n consec_days = []\n consec_days << day_abbrs[day_id.to_s]\n end\n #Always add the consec_days array when this is the\n #last day of the @day_ids array\n if day_id == @day_ids.last\n consec_day_groups << consec_days\n end\n i += 1\n end\n\n day_strings = []\n consec_day_groups.each do |c|\n if c.length > 2\n day_strings << c.first.to_s + \"-\" + c.last.to_s\n else\n day_strings << c.join(\", \")\n end\n end\n return day_strings.join(\", \")\n end",
"def days_of_week_array\n dow = days_of_week_hash\n\n @days_of_week_array ||= [\n dow[:sunday],\n dow[:monday],\n dow[:tuesday],\n dow[:wednesday],\n dow[:thursday],\n dow[:friday],\n dow[:saturday]\n ]\n end",
"def todays_calories\n array = self.daily_logs.map do |log|\n if log.date == Date.today\n return log.calories \n # else \"No calories logged for today's date\"\n else \"0 Days left, please check your bet dash\"\n end\n end\n return array[0]\n end",
"def index\n @work_days = WorkDay.all\n end",
"def list_days(start_on=start_date,end_on=end_date,show_empty=false,show_ids=false)\n (parse_date_param(start_on)..parse_date_param(end_on)).to_a.map { |_date|\n format_events_for(_date,show_empty,show_ids)\n }.compact\n end",
"def multi_day_labels(num_days)\n labels = []\n num_days.times do |i|\n labels << (Date.today-i).to_time.strftime(\"%A\")\n end \n labels.reverse!\n labels << (Date.today+1).to_time.strftime(\"%A\")\n return labels\n end",
"def futureDays(weather_info)\n\tdays=[]\n\tweather_info[\"daily\"][\"data\"].each do |day|\n\t\tdays << day[\"time\"]\n\tend\n\tputs days\nend",
"def get_availability\n unbooked_days = []\n availability_blocks = self.availabilities.includes(:bookings)\n availability_blocks.each do |availability_block|\n booked_days = []\n availability_block.bookings.each do |booking|\n booked_days += (booking.start_date..booking.end_date).to_a\n end\n (availability_block.start_date..availability_block.end_date).each do |day|\n unbooked_days.push(day) unless booked_days.include?(day)\n end\n end\n unbooked_days\n end",
"def weekdays\n value.each_char.map { |c| WEEKDAYS.index(c) }\n end",
"def format_rations_with_days\n @daily_rations.map do |e|\n [ e.dish_id,\n e.dish.title,\n e.dish.price,\n e.quantity,\n e.daily_menu.day_number ]\n end\n end",
"def get_festivals() \n #Start from 3 days ago since can be in the middle of a festival\n threeDaysAgo = (Time.now - (3*24*60*60)).strftime('%Y-%m-%d')\n #Find relevant events\n events = Event.where(festival: 1).where('date >= ?', threeDaysAgo).order(:date)\n\n #Make hash of hashes that include all necessary info\n festivalDatesArr = {}\n events.each do |event|\n #Need to account for same name different locations\n name = \"#{event.title} #{event.location}\"\n if festivalDatesArr.has_key?(name)\n festivalDatesArr[name]['dates'].push(event.date) \n else\n festName = \"#{event.title} #{event.location}\"\n festivalDatesArr[festName] = {\n 'dates' => [event.date],\n 'id' => event.id,\n 'title' => event.title,\n 'location' => event.location,\n 'ages' => event.ages,\n 'link' => event.ticketLink,\n 'address' => event.address\n }\n end\n end\n return festivalDatesArr\n end",
"def dayOfWeek\n days = 0;\n tempYear = MIN_YEAR\n while tempYear < @year\n days += SimpleDate.daysInYear(tempYear).to_i\n tempYear+=1\n end\n\n days = days + ordinalDate\n #puts \"days #{days}\"\n days = days % 7\n\n end",
"def chart_days\n daily_requests = self.daily_requests.limit(10)\n days = daily_requests.map(&:created_at)\n days.map { |d| d.strftime(\"%b %e\") }\n end",
"def index\n @day_of_weeks = DayOfWeek.all\n end",
"def weekdays\n if @range\n first = WEEKDAYS.find {|key,val| key.include? @range.first }.last.first\n last = WEEKDAYS.find {|key,val| key.include? @range.last }.last.last\n return (first..last).to_a\n else\n output = []\n @tokens.each do |token|\n WEEKDAYS.each_pair do |labels,wdays|\n output.concat(wdays) and break if labels.include?(token)\n end\n end\n output\n end\n end",
"def days \n object.days\n end",
"def wday() end",
"def days(from_date = first_day.date, to_date = last_day.date)\n from_date = Date.new(2017, 1, 1)\n to_date = Date.new(2017, 12, 31)\n\n @days ||= workdays.select { |day| day.hours > 0 && (from_date..to_date).include?(day.date) }\n end",
"def day(date)\n \n days = self.days(14)\n \n day = Object\n \n days.each do |dayEach|\n break day = dayEach if dayEach.dia == date.strftime(\"%d-%m-%Y\") \n end\n \n day\n \n end",
"def specific_days_in_semester\n date_start = USDateParse(self.start_date)#USDateParse(self.start_date)\n date_end = USDateParse(self.end_date)#USDateParse(self.end_date)\n curr_date = date_start\n date_hash = Hash.new(0)\n while curr_date <= date_end do\n if (! self.individual_dates_with_no_classes.include?(curr_date))\n date_hash[curr_date.cwday] += 1\n end\n curr_date += 1\n end\n return date_hash\n end",
"def group_by_day\n\n\tend",
"def grid\n Date::DAYNAMES.map do |name|\n daily_hours = send(name.downcase)\n HOURS.map do |hour|\n daily_hours.include? hour\n end\n end\n end",
"def doctors\n # binding.pry\n self.appointments.collect {|appointment| appointment.date}\n end",
"def last_7_day_kwh_usage_by_day\n usage_data = []\n Time.now.utc.to_date.downto(6.days.ago.utc.to_date).each do |date|\n usage_data << total_day_kwh_usage_on(date).round(2)\n end\n usage_data\n end",
"def workdays_in_range\n end_time ? (start_time.to_date..end_time.to_date).select { |d| (1..5).cover?(d.wday) }.size - offset : 1\n end",
"def days_late\n\t\tdays = []\n\t\t(1..5).each do |ago|\n\t\t\tr = runs.where(date: Date.today - ago).first\n\t\t\tlate = r.days_late == 0 ? 'On time' : r.days_late if r\n\t\t\tlate ||= 'NO LOG'\n\t\t\tdays << late\n\t\tend\n\t\tdays\n\tend",
"def dates\n\t\t@times = { \n\t\t\t:haiti=>{\n\t\t\t\t:one_week_before=>\tTime.new(2010,01,5),\n\t\t\t\t:event\t\t\t=>\tTime.new(2010,01,12),\n\t\t\t\t:one_week_after\t=>\tTime.new(2010,01,19),\n\t\t\t\t:dw_end\t\t\t=>\tTime.new(2010,02,12)\n\t\t\t},\n\n\t\t\t:philippines=>{ \n\t\t\t\t:one_week_before=>\tTime.new(2013,11,1),\n\t\t\t\t:event\t\t\t=>\tTime.new(2013,11,8),\n\t\t\t\t:one_week_after\t=>\tTime.new(2013,11,15),\n\t\t\t\t:dw_end\t\t\t=>\tTime.new(2013,12,8)\n\t\t\t},\n\t\t\t:phil=>{ \n\t\t\t\t:one_week_before=>\tTime.new(2013,11,1),\n\t\t\t\t:event\t\t\t=>\tTime.new(2013,11,8),\n\t\t\t\t:one_week_after\t=>\tTime.new(2013,11,15),\n\t\t\t\t:dw_end\t\t\t=>\tTime.new(2013,12,8)\n\t\t\t}\n\t\t}\n\tend",
"def weekdays\n lines[1]\n end",
"def list_fit_wit_workout(e)\n \"#{e.name} on #{e.date_accomplished}\"\n end",
"def day_array(add_pick)\n\t\tret = (0..6).map {|num| [Date::DAYNAMES[num], num]}\n\t\tret.unshift([\"<< Pick >>\",nil]) if add_pick\n\t\tret\n\tend",
"def days_as_string\n day_string = ''\n day_map = %w[Sun Mon Tue Wed Thu Fri Sat]\n days.each { |d| day_string << day_map[d] + ', ' }\n day_string[0..(day_string.length - 3)]\n end",
"def worktype_adhoc(begda,endda)\n teams=Team.find(:all)\n curdate = begda\n ad_hoc = []\n until curdate > endda do\n teams.each do |team|\n team_ad_hoc = team.ad_hoc_work(curdate)\n \n ad_hoc << { :month => Date::ABBR_MONTHNAMES[curdate.month], \n :team_id => team.id,\n :adhoc_tasks => team_ad_hoc[:tasks],\n :adhoc_perc => team_ad_hoc[:percentage],\n } \n \n end\n\n curdate = curdate >> 1\n end\n return ad_hoc\n end",
"def get(days,start_cep,end_cep)\n self.class.get(\"/api/v1/quote/available_scheduling_dates/#{days}/#{start_cep}/#{end_cep}\")\n end",
"def days_of_rent\n (1..(Rules.compute_rental_duration(@rental_data))).to_a\n end",
"def select_days\n days_menu = []\n days_selected = []\n select_days_menu(days_menu)\n select_days_selection(days_selected, days_menu)\n return days_selected\n end",
"def holidayChecker(dates, bank_holidays)\n dates = parseDates(dates) #parse dates array\n bank_holidays = parseDates(bank_holidays) #parse bank holidays array\n corrected_schedule = []\n dates.each do |date|\n while date.wday == 6 || date.wday == 7 || bank_holidays.include?(date) #while the date is either a bank holiday OR a Saturday OR a Sunday...\n date += 1\n end\n corrected_schedule.push(date)\n end\n puts corrected_schedule\nend",
"def working_days_from_date(date)\r\n date = date + 1.day if date.cwday == 6\r\n day_of_the_week = date.cwday == 7 ? 0 : date.cwday\r\n calendar_days, business_days = self, self\r\n result_date = day_of_the_week + business_days\r\n if (result_date >= 6)\r\n business_days -= (6 - day_of_the_week)\r\n calendar_days += 2\r\n weeks = business_days / 5\r\n calendar_days += (weeks * 2)\r\n end\r\n date + calendar_days.days\r\n end",
"def get_dates(arr) \ndayDifference = Date.today - 7.days\narr.select do |d| \nif d.created_at.to_date > dayDifference \n d \n end\nend \nend",
"def create_calendar_dates(interval, ed_org_id)\n calendar_dates = []\n begin_date = interval.get_begin_date\n end_date = interval.get_end_date\n holidays = interval.get_holidays\n (begin_date..end_date).step(1) do |date|\n if DataUtility.rand_float_to_int(@prng, @scenarioYAML['HACK_PERCENTAGE_CALENDAR_DATES'] || 1) > 0\n if holidays.include?(date)\n calendar_dates << {\"date\" => date, \"event\" => :HOLIDAY, \"ed_org_id\" => ed_org_id}\n else\n calendar_dates << {\"date\" => date, \"event\" => :INSTRUCTIONAL_DAY, \"ed_org_id\" => ed_org_id} if date.wday != 0 and date.wday != 6\n end\n end\n end\n calendar_dates\n end",
"def due_date_task_list\n @due_date_task_list\n end",
"def events_on_day(day_num)\n events = []\n event.each { |e| events << e if e.days.include? day_num }\n events.sort_by(&:start_time)\n end"
] | [
"0.7537419",
"0.74122226",
"0.69411093",
"0.69009703",
"0.6840075",
"0.67987645",
"0.6758112",
"0.67461383",
"0.67197204",
"0.66970515",
"0.6687425",
"0.6684145",
"0.6677571",
"0.6666544",
"0.6649977",
"0.66175944",
"0.66120136",
"0.6600144",
"0.6588766",
"0.657634",
"0.65615726",
"0.6478672",
"0.64737034",
"0.6447533",
"0.6422448",
"0.64134276",
"0.641008",
"0.6397893",
"0.6396083",
"0.639155",
"0.63867027",
"0.6357975",
"0.6324667",
"0.63015133",
"0.6300073",
"0.6293192",
"0.62771446",
"0.6265221",
"0.6263681",
"0.6261773",
"0.62600404",
"0.6245716",
"0.6227299",
"0.6224891",
"0.62199426",
"0.6210848",
"0.62085706",
"0.62060136",
"0.62027574",
"0.61994225",
"0.6196238",
"0.61799717",
"0.6168865",
"0.616485",
"0.6158722",
"0.6150158",
"0.6141044",
"0.6139791",
"0.6137845",
"0.6126388",
"0.6126082",
"0.61200124",
"0.61083686",
"0.61016583",
"0.6088693",
"0.6081189",
"0.60555893",
"0.6055168",
"0.60490996",
"0.6047399",
"0.60360724",
"0.603076",
"0.6030057",
"0.6026331",
"0.60226786",
"0.60076374",
"0.5994963",
"0.5994132",
"0.5991744",
"0.59893453",
"0.5988654",
"0.59880835",
"0.59796256",
"0.59721935",
"0.59659404",
"0.5964443",
"0.59516495",
"0.5949213",
"0.59489495",
"0.5944763",
"0.5944681",
"0.594154",
"0.5939482",
"0.59298664",
"0.5929839",
"0.59293514",
"0.59287673",
"0.5924041",
"0.5923286",
"0.592228"
] | 0.72278166 | 2 |
5. I can log my weight at the end of the week | def log_my_weight(weight)
self.current_weight = weight
self.save
puts "Current weight #{weight}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weight_on_date(date)\n get_call(\"/1/user/#{@user_id}/body/log/weight/date/#{format_date(date)}.json\")\n end",
"def add_demand(date, kwh)\n return 0 unless level(date) != :off_peak\n\n if kwh > 20\n p [kwh, date, level(date)]\n end\n\n super\n end",
"def log_weight(weight, date, time = nil, options = {})\n params = key_value_date_time_params('weight', weight, date, time)\n post_json(path_user_version('/body/log/weight', options), params)\n end",
"def wday() end",
"def w_day; end",
"def add_demand(date, kwh)\n return 0 unless level(date) != :off_peak\n super\n end",
"def thirty \n now = Date.today\n end_date = Date.today + 30\n dates = (now...end_date).to_a\n create_log(dates) \n end",
"def daily\n logger.info \" daily\"\n end",
"def mweek; (5 - wday + day) / 7 end",
"def current_week_kwh_usage\n total_week_kwh_usage_until(Time.now.utc.to_date).round(2)\n end",
"def changerate\n\t\tuser = current_user\n\t\tbodylogs = user.bodylogs.where(:created_at => 1.week.ago..Date.tomorrow) #one week of kcal records\n\t\tif bodylogs.count('kcal') != 7 # make sure there are 7 kcal entries for this week.\n\t\t\treturn \"Not enough consistent log entries to calculate\"\n\t\telse\n\t\t\tprofile = user.profile\n\t\t\tar = Array.new\n\t\t\tbodylogs.each do |b|\n\t\t\t\tm = harrisbenedict(profile.gender, profile.height, profile.age, b.weight, profile.activity)\n\t\t\t\tar.push(b.kcal - m[:maintenance]) #m[:maintenance] = maintenance calories.\n\t\t\tend\n\t\t\tsum = ar.sum\n\t\t\tchange = (sum / 7000) #7000 kcal = 1kg of fat\n\t\t\treturn change\n\t\tend\n\tend",
"def fortnights ; self * 2.weeks ; end",
"def weight_loss(db, member_id, time_frame)\n total_pounds= []\n t = DateTime.now\n past_week = ((t-6)..t).map{ |date| date.strftime(\"%m-%d\") }\n this_month = Time.now.strftime(\"%m\") \n if time_frame == \"week\"\n past_week.each do |x|\n updated_weight = db.execute(\"SELECT * FROM weight WHERE member_id='#{member_id}' AND day='#{x}' \")\n updated_weight.each do |pounds|\n total_pounds << pounds['current_weight']\n end \n end\n else \n updated_weight = db.execute(\"SELECT * FROM weight WHERE member_id='#{member_id}' AND month='#{this_month}' \")\n updated_weight.each do |pounds|\n total_pounds << pounds['current_weight']\n end \n end \n weight_loss= total_pounds.max - total_pounds.min \nend",
"def calculate_calories_burned\n type = activity.activity_type\n user_weight = user.recent_most_weight.value\n user_weight = user_weight < 1 || user_weight.nil? ? 0 : user_weight\n # Our global intensity multipler\n intensity = 1 + (activity.intensity / 10)\n\n case type\n\n when 0 # Weight lifting\n self.calories = 0 and return true if work == 0\n # Calculate the joules expended\n joules = (self.work / 1000) * 9.81 * 0.75\n # Calories per rep\n per_rep = (joules * 0.000239006) * 5 # Times 5 here because 5 * 20 = 100; Muscles are roughly 20% efficient\n # Multiplier for heart rate elevation and work intensity. Default is 1.5\n # if we don't know their weight\n multiplier = user_weight == 0 ? 1.5 : 3.5 * (self.work / user_weight)\n # The full formula\n calories_burned = per_rep * reps * multiplier * intensity\n self.calories = calories_burned.round(2)\n\n when 1 # Timed things\n # Altering our intensity to work in the formula at\n # http://ask.metafilter.com/48652/Walking-formula\n intensity = intensity / 100\n intensity = intensity < 0.015 ? 0.015 : intensity\n # Convert user_weight to pounds from grams\n user_weight = user_weight * 0.00220462\n # Work here will be time in seconds\n self.calories = (intensity * user_weight * (work / 60)).round(2)\n\n when 2 # Distance\n # Credit: NET calories burned per miles as listed at\n # https://www.checkyourmath.com/convert/length/miles_mm.php\n #\n # Find our intensity. Basic running is .65, walking is .3, sprinting is\n # all the way at .8\n intensity = intensity - 1\n intensity = intensity < 0.2 ? 0.2 : intensity\n intensity = intensity > 0.8 ? 0.8 : intensity\n # Convert their weight to pounds\n user_weight = user_weight * 0.00220462\n # Convert the unit of work from mm to miles\n work_in_miles = self.work * 0.00000062\n # And finally\n self.calories = (intensity * user_weight * work_in_miles).round(2)\n\n when 3 # Repetitions\n # A VERY simple and dirty calculation here. Basically, any of these reps\n # are going to be bodyweight, ranging from ridiculously easy for even the\n # most out of shape people (like a simple crunch), to something difficult\n # for even professional athletes (dragon flags). So we'll have a baseline\n # of 1 calorie, and range up to 6 per repetition depending on the exercise's\n # intensity\n intensity = (activity.intensity / 2).round\n intensity = intensity < 1 ? 1 : intensity\n self.calories = intensity * self.reps\n else\n\n self.calories = 0\n end\n end",
"def battery_weight; end",
"def current_day_kwh_usage\n total_day_kwh_usage_on(Time.now.utc.to_date).round(2)\n end",
"def week; end",
"def document_progress(new_weight, old_weight)\n if self.goal == \"Lose Weight\"\n self.weight_histories.create(weight_recording: (old_weight - new_weight))\n elsif self.goal == \"Gain Weight\"\n self.weight_histories.create(weight_recording: (new_weight - old_weight))\n end\n end",
"def time_estimate(profile)\n\t\tuser = current_user\n\t\tif profile.weighttarget == nil || changerate == nil\n\t\t\treturn \"You need a target weight and at least 7 consistent log entries.\"\n\t\tend\n\t\tlastlog = user.bodylogs.last\n\t\tif lastlog.weight\n\t\t\tcurrent_weight = lastlog.weight\n\t\t\tdiff = current_weight - profile.weighttarget\n\n\t\t\trate = actualChangeRate()\n\t\t\tif rate.to_f != 0\n\t\t\t\tif rate > 0 && diff > 0\n\t\t\t\t\treturn \"You've been moving away from your target weight goal for the past week\"\n\t\t\t\telsif rate < 0 && diff < 0\n\t\t\t\t\treturn \"You've been moving away from your target weight goal for the past week\"\n\t\t\t\telse\n\t\t\t\t\treturn ((diff / rate).abs).round(1)\n\t\t\t\tend\n\t\t\telse\n\t\t\t\treturn \"-\"\n\t\t\tend\n\t\telse\n\t\t\treturn \"No current weight logged\"\n\t\tend\n\tend",
"def threshold_for_offline\n 8.days\n end",
"def water_level\n end",
"def water_level\n end",
"def sunday_weekly_batch\n JdeFetch.checking_buffer\n JdeFetch.checking_item_cost\n end",
"def food_per_week\n cups_of_food = 20\n cups_of_food -= @age * 2\n cups_of_food > 0 ? cups_of_food : 1\n end",
"def cweek\n end",
"def smoked_this_week\n Smoke.by_user(id).this_week(Date.today).sum(:counted) || 0\n end",
"def thirty_day_weight_graph\n series = (Date.today - 1.month)..(Date.today)\n series.map do |date|\n weight = if date == Date.today\n active_body_weight_record(Time.now)&.weight\n else\n active_body_weight_record(date)&.weight\n end\n next unless weight\n [date, weight]\n end.compact\n end",
"def daily_thievery\r\n\t\t@inventory += (@thieves)*3\r\n\tend",
"def weight; end",
"def weight_at(time)\n weight_entries = self.tracker_entries.joins(:tracker).where(\"trackers.name = ?\", \"weight\")\n closest_in_past = weight_entries.where(\"logged_on < ?\", time.utc).order(:logged_on).last\n \n if closest_in_past\n closest_in_past.quantity\n end\n end",
"def log_and_hire(amount)\n Logger.message(\"Hiring more workers so we have #{ amount } in total.\")\n workers(amount)\n end",
"def current_bmi_alert\n weight = self.current_weight\n height = self.current_height\n alert = nil\n unless weight == 0 || height == 0\n current_bmi = (weight/(height*height)*10000).round(1);\n if current_bmi <= 18.5 && current_bmi > 17.0\n alert = 'Low BMI: Eligible for counseling'\n elsif current_bmi <= 17.0\n alert = 'Low BMI: Eligible for therapeutic feeding'\n end\n end\n\n alert\n end",
"def weeks() 7 * days end",
"def log_water(opts)\n unless opts[:amount] && opts[:date]\n raise Fitgem::InvalidArgumentError, \"Must include both an :amount and :date to log water\"\n end\n\n opts[:date] = format_date(opts[:date])\n post(\"/user/#{@user_id}/foods/log/water.json\",opts)\n end",
"def current_weekly_average\n week_number = Time.now.yday / 7\n @cycling[2] = @cycling[0] / week_number\n @entertainment[2] = @entertainment[0] / week_number\n @programming[2] = @programming[0] / week_number\n @reading[2] = @reading[0] / week_number\n @yoga[2] = @yoga[0] / week_number\n end",
"def week\n stamp = params[:stamp].to_i\n interval = (params[:interval] || 10).to_i\n plus_weeks = (params[:plus_weeks] || 0).to_i\n context = (params[:context] || 0).to_i == 1 ? true : false\n time = Time.at(stamp).utc\n\n # Calculate monday from given date\n wday = time.wday\n # Adjust for sunday when we want to start on a monday\n wday = 7 if wday == 0\n\n date = time - (wday.days - 1.days)\n\n date = date + plus_weeks.weeks\n\n # Number of days in week range if we add context, we add the surrounding weeks as well\n days = context ? (7 * 3) - 1 : 6\n\n # If context we'll start at the monday before\n if context\n date -= 7.days\n end\n\n\n\n week_data = []\n week_dates = []\n\n buckets = 0.step((60 * 24) - 1, interval).to_a\n\n (0..days).each do |day|\n interval_data = Hash.new { |h, k| h[k] = [] }\n\n data = GlucoseSensorData.by_day(date.to_date, :field => :timestamp)\n\n data.each do |datum|\n minutes = datum.timestamp.min + (datum.timestamp.hour * 60)\n # At first seems like a no op but this actually buckets minutes into intervals\n bucket = (minutes / interval) * interval\n\n interval_data[bucket] << datum\n end\n\n week_context = nil\n\n if context\n week_number = day / 7\n if week_number == 0\n week_context = \"before\"\n elsif week_number == 1\n week_context = \"current\"\n else\n week_context = \"after\"\n end\n else\n week_context = \"current\"\n end\n\n buckets.each do |bucket|\n datum = {}\n\n datums = interval_data[bucket]\n # Averages glucose values if there are more than one datum for that bucket\n if datums.length > 0\n datum[:glucose] = datums.inject(0.0) { |sum, d| sum + d.glucose } / datums.size\n #datum[:timestamp] = datums[0].timestamp.to_i\n end\n datum[:timestamp] = (date + bucket.minutes).to_i\n datum[:week_context] = week_context\n\n\n datum[:time] = bucket\n datum[:day] = date.strftime(\"%A\").downcase\n datum[:date] = date.to_i\n week_data << datum\n end\n\n week_dates.push({ :week_context => week_context, :day => date.strftime(\"%A\").downcase, :date => date.to_i })\n date += 1.days\n end\n\n render :json => { :data => week_data, :interval => interval, :week_dates => week_dates }\n end",
"def total_day_kwh_usage_on(date)\n raise \"Invalid argument: Please use a date value that is not in the future\" if (date > Time.now.utc.to_date)\n\n cumulative_hourly_kwh_usage = 0.0\n (0..23).each do |i|\n cumulative_hourly_kwh_usage += self.total_hour_kwh_usage_on(date, i)\n #puts cumulative_hourly_kwh_usage.to_s\n end\n cumulative_hourly_kwh_usage\n end",
"def weekly(user)\n @user = User.find(user)\n @points_away = Level.find(@user.level).points - @user.points\n mail(to: \"#{@user.name} <#{@user.email}>\", subject: \"Its Your Weekly Reminder to be Awesome\")\n end",
"def evaulate_schedule\n 5\n end",
"def dumptotal\n # expire > 15minute dumps\n @dumptrack.reject! { |r| (r[3] + 900) < Time.now }\n total = 0\n @dumptrack.each do |t|\n if t[2] == \"bid\"\n total += t[0].to_i\n elsif t[2] == \"ask\"\n total -= t[0].to_i\n else\n debug(\"failed to match #{t[2]} trade type for total.\")\n end\n end\n # get 5 minute\n alert_msg = \"Sum of whale action; In the last 15 minutes:\"\n add_message(\"*** 15 minute whale action is over the 375 btc threshold! #{total} BTC (alert sleep timer set 1000s)\") if total.abs >= 375\n if total > 0\n return alert_msg + \" + #{total.abs} BTC (bought)\"\n elsif total < 0\n return alert_msg + \"- #{total.abs} BTC (sold)\"\n else\n return \"Last 15 minutes: nothing happening..\"\n end\n end",
"def weekly_points\n weekly_crime_points + weekly_suspension_points\n end",
"def cooking_time(eggs)\n (eggs.to_f / 8).ceil * 5\nend",
"def logs_last_week(user)\n @user = user\n mail(to: @user.email, subject: 'TimeTrckr.com: Your Logs from Last Week')\n end",
"def high_five; end",
"def work(interval = 5.0)\n end",
"def quality_driven_software_export\n @from = Time.zone.now - 1.week\n @to = Time.zone.now\n end",
"def last_7_day_kwh_usage_by_day\n usage_data = []\n Time.now.utc.to_date.downto(6.days.ago.utc.to_date).each do |date|\n usage_data << total_day_kwh_usage_on(date).round(2)\n end\n usage_data\n end",
"def average\n average = @log.values.inject { |sum, el| sum + el }.to_f / log.values.size\n puts @log.values.last < average ? \"Today you had less than your average amount! Keep up the good work!\" : \"You smoked more than average today, stressful day?\"\n end",
"def best_day\n\n end",
"def set_metrics\n @user = current_user\n recent = @user.recent_most_weight\n @weightentry = recent.nil? ? @user.weightentries.build(day: current_day) : recent\n render \"metrics\"\n end",
"def calculate_overall_power_for\n t = Time.zone.now\n\n until_today = self.energy_data.where(:year=>t.year, :month=> (1..(t.month)), :day=>(1..t.day-1)).sum(\"power\") # total in Wh\n today = self.energy_data.where(:year=>t.year, :month=>t.month, :day=>t.day, :hour=>(1..t.hour)).sum(\"power\") # total in Wh\n until_today + today\n end",
"def rate; end",
"def rate; end",
"def enter_weight(db, day, current_weight, member_id)\n month = Time.now.strftime(\"%m\") \n db.execute(\"INSERT INTO weight (day, month, current_weight, member_id) VALUES (?, ?, ?, ?)\", [day, month, current_weight, member_id])\nend",
"def days_old_weight\n difference = Date.today - self.created_at.to_date\n HesPosts.days_old_weight.keys.sort{|x,y| y <=> x}.each do |day| \n return HesPosts.days_old_weight[day] if difference >= day\n end\n return 1\n end",
"def time_management\n @personal_best = current_user.reports.map(&:time_management).max.round(2) rescue 0\n @personal_best = \"#{@personal_best}% Questions Attended\"\n learning_curve 'time_management'\n data_presenter 'time_management'\n end",
"def speed_of_spread #in months\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end",
"def speed_of_spread #in months\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end",
"def notify_usage( user )\n most_recent = Usage.first :conditions => { :site => user.site }, :order => 'period_from DESC'\n # 24hr can be nil during free download periods\n if most_recent && most_recent.download_24hr && most_recent.download_24hr >= user.warning_threshold\n logger.info(\" notifying: #{most_recent.download_24hr}/#{user.warning_threshold}\")\n Notifier.deliver_usage_message( user, most_recent ) \n end\nend",
"def weekly_sell\n @weekly_sell ||= settle_items.last_week.sum('quantity')\n end",
"def speed_of_spread() #in months\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end",
"def speed_of_spread() #in months\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end",
"def lead_time\n 4\n end",
"def calculate_week_power_for\n dates, totals = consolidate_week\n\n weekPowerCount = 0\n\n totals.each do |index, total|\n weekPowerCount+=total\n end\n\n weekPowerCount\n end",
"def cooking_time\n end",
"def currentWeight() weighins.last.weight end",
"def weekly\n user = User.first\n TipMailer.weekly(user)\n end",
"def usage_interval\n\n end",
"def weekly_pay(rate, hours = 40)\n hours * rate\nend",
"def weekly_smallV_report(count, budget, total_consumed, kol_count, real_kol_count)\n puts \"Prepare for weekly email\"\n @count = count\n @budget = budget\n @total_consumed = total_consumed\n @kol_count = kol_count\n @real_kol_count = real_kol_count\n mail(:to => 'app_report@robin8.com', :subject => \"【Robin8】Small-V weekly report\",:from => \"Robin8 <system@robin8.com>\")\n puts \"Weekly email sent\"\n end",
"def nth_wday; (day - 1) / 7 end",
"def check_weight(current_weight_kg)\n \n # currentWeightKG calculated thanks to weight sensors\n if (current_weight_kg > @max_weight_kg)\n\n # Display 10 warnings\n for _ in 1..10 do\n puts \"\\nALERT Maximum weight capacity reached on Elevator #{@id}\"\n end\n\n # Freeze elevator until weight goes back to normal\n if (@movement != \"idle\")\n @movement = \"idle\"\n end\n \n @door.open_door()\n end\n end",
"def weight_lost\n weight_fluctuate = current_weight - start_weight\n if current_weight < start_weight\n return \"Down #{weight_fluctuate}. We are making progress!\"\n else\n return \"Up #{weight_fluctuate}. We are making gains!\"\n end\n end",
"def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0 #this can be made into a class attribute allowing a getter\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n #Print method can be removed allowing information to be printed in the driver code\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end",
"def fuel_per_hour\n 10\n end",
"def boil_off_gallons_per_hour\n 1.0\n end",
"def interesting_date\n marked_as_fast_growing_at\n end",
"def weighIntrade()\n\n end",
"def logToday(foodName)\n\t\tdate = Date.today\n\t\tfoodName.upcase!\n\t\tlogSpecificDate(foodName, date)\n\tend",
"def calculate_calories(bodyweight)\n\ttotal_calories = bodyweight * 13\n\treturn total_calories\nend",
"def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end",
"def tenders_ultimate(start, num, day)\n\nend",
"def accumulated_power_used\n power_total = 0.0\n\n begin\n (1..3).each do |ipdp|\n (1..4).each do |eg|\n power_reading = @xml.xpath(\"//XMLdata//info8_IPDP#{ipdp}_eg#{eg}\")[0].content.to_f\n #$stderr.puts \"Power Reading Phase #{ipdp} Socket #{eg} Energy #{power_reading}KJ\"\n power_total += power_reading\n end\n end\n return power_total/3600.0\n \n rescue #If something is wrong with the data\n return 0.0\n end\n end",
"def daily_morning\n logger.info \" daily_morning\"\n run('Newsletter', :send!)\n end",
"def lead_time\n 1\n end",
"def fortnights\n\t\treturn self * 2.weeks\n\tend",
"def fortnights\n\t\treturn self * 2.weeks\n\tend",
"def current_bmi_alert(patient_weight, patient_height)\n weight = patient_weight\n height = patient_height\n alert = nil\n unless weight == 0 || height == 0\n current_bmi = (weight/(height*height)*10000).round(1);\n if current_bmi <= 18.5 && current_bmi > 17.0\n alert = 'Low BMI: Eligible for counseling'\n elsif current_bmi <= 17.0\n alert = 'Low BMI: Eligible for therapeutic feeding'\n end\n end\n\n alert\n end",
"def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n # if @population_density >= 200\r\n # speed += 0.5\r\n # elsif @population_density >= 150\r\n # speed += 1\r\n # elsif @population_density >= 100\r\n # speed += 1.5\r\n # elsif @population_density >= 50\r\n # speed += 2\r\n # else\r\n # speed += 2.5\r\n # end\r\n\r\n puts \" and will spread across the state in #{@speed} months.\\n\\n\"\r\n\r\n end",
"def get_metrics_latest\n get_metrics_days_back(45)\n end",
"def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n end",
"def current_power_usage\n begin\n power_being_used = 0.0\n\n (1..3).each do |ipdp|\n (1..4).each do |ap|\n power_reading = @xml.xpath(\"//XMLdata//info8_IPDP#{ipdp}_ap#{ap}\")[0].content.to_f\n power_being_used += power_reading #in Watts\n end\n end\n \n return power_being_used/1000.0 #in KW\n\n rescue #If something is wrong with the data\n return 0.0\n end\n end",
"def weeks ; self * 7.days ; end",
"def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n#we can remove this and have it print within virus_effects so that this method does one thing\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end",
"def after_logged_trail_msg\n if current_user.is_trail_in_period?\n \"Your trial period expires in #{get_total_remaining_days(current_user.exp_date)} days, do you want to pay now?\"\n else\n \"\"\n end\n end",
"def check_weights\n until ((@personal_credit_weight + @industry_weight + @biz_age_weight) == 1.0)\n puts \"Your weights do not add up to 100%. please correct this.\"\n new_weights\n end\n end",
"def call\n @swings = [{swing_start_date: Date.new(1993,1,8), swing_start_value: 426.88, change_percent: nil}]\n @trend_direction = :up\n @swing_start_value = 426.88 # 1/8/93 bottom\n @swing_start_date = Date.new(1993,1,8) # 1/8/93 bottom\n @mark = price_history.first[:high]\n set_threshold(price_history.first)\n\n price_history.each do |ph|\n binding.pry if ph[:timestamp].to_date == Date.new(2009,3,3) || $stop\n if @trend_direction == :up\n record_swing(ph) if ph[:low] < @threshold_value\n elsif @trend_direction == :down\n record_swing(ph) if ph[:high] > @threshold_value\n end\n\n set_threshold(ph)\n end\n\n swings\n end",
"def total_weight_loss(db, member_id) \n total_pounds= []\n today = Time.now.strftime(\"%m-%d\") \n weight = db.execute(\"SELECT * FROM members WHERE id='#{member_id}'\") \n updated_weight = db.execute(\"SELECT * FROM weight WHERE member_id='#{member_id}'\")\n updated_weight.each do |pounds|\n total_pounds << pounds['current_weight']\n end \n weight_loss = weight[0]['starting_weight'] - total_pounds.min \nend",
"def average_weather\n message = \"Média para os proximos dias: \"\n 5.times do |t|\n date = Date.today + 1 + t\n message += forecast.average_temperature(date).to_s\n message += temp_type\n message += \" em \"\n message += date.strftime(\"%d/%m\").to_s\n message += \"#{t == 4 ? '.' : ',' } \"\n end\n message\n end",
"def total_week_kwh_usage_until(date)\n raise \"Invalid argument: Please use a date value that is not in the future\" if (date > Time.now.utc.to_date)\n\n cumulative_daily_kwh_usage = 0.0\n (0..date.wday).each do |i|\n cumulative_daily_kwh_usage += self.total_day_kwh_usage_on(date - i.day)\n end\n cumulative_daily_kwh_usage\n end"
] | [
"0.6330222",
"0.6330165",
"0.6274216",
"0.6186279",
"0.61630857",
"0.61469686",
"0.61299884",
"0.6126017",
"0.6092013",
"0.6082499",
"0.60398006",
"0.6024036",
"0.601397",
"0.601093",
"0.59977376",
"0.59683645",
"0.596083",
"0.5955692",
"0.59257203",
"0.5868628",
"0.58673453",
"0.58673453",
"0.5862671",
"0.58268595",
"0.5822633",
"0.58125514",
"0.57861966",
"0.5773297",
"0.5741347",
"0.572532",
"0.57182026",
"0.57039183",
"0.57034653",
"0.5676835",
"0.567366",
"0.56515855",
"0.5647178",
"0.5635683",
"0.56172603",
"0.56172466",
"0.56023747",
"0.5593606",
"0.55912054",
"0.558486",
"0.55745924",
"0.55647904",
"0.55585635",
"0.55569094",
"0.55323815",
"0.5531543",
"0.5526513",
"0.5519437",
"0.5519437",
"0.55100995",
"0.55050176",
"0.55008346",
"0.54985136",
"0.5497869",
"0.5485638",
"0.54820484",
"0.548143",
"0.548143",
"0.5473486",
"0.5473132",
"0.5468771",
"0.54628",
"0.5452782",
"0.54514855",
"0.5449537",
"0.544728",
"0.5442534",
"0.54424995",
"0.54391766",
"0.54300076",
"0.54293776",
"0.5428319",
"0.5423638",
"0.5422459",
"0.54222417",
"0.54141337",
"0.5410443",
"0.5407348",
"0.54064256",
"0.54026294",
"0.54020405",
"0.54013926",
"0.54013926",
"0.5396639",
"0.5396056",
"0.5395651",
"0.5392297",
"0.5387729",
"0.53863436",
"0.5385699",
"0.538545",
"0.53852826",
"0.5383807",
"0.5383575",
"0.5381215",
"0.53790146"
] | 0.6470833 | 0 |
6. I can also find out how much I lost compared to my starting weight | def weight_lost
weight_fluctuate = current_weight - start_weight
if current_weight < start_weight
return "Down #{weight_fluctuate}. We are making progress!"
else
return "Up #{weight_fluctuate}. We are making gains!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remaining_pints\n ((current_weight-14.25)/0.45).to_i > 0 ? ((current_weight-14.25)/0.45).to_i : 0\n end",
"def weight_until_goal\n if weigh_ins.count > 0 && goal_weight > 0\n weigh_ins.first.current_weight - goal_weight\n elsif goal_weight > 0\n start_weight - goal_weight\n end\n end",
"def calc_total_weight\n 0\n end",
"def weight; end",
"def weight\n 0\n end",
"def weight_in_stones\n\t\t((@weight * 2.20462) / 14).to_i\n\tend",
"def weight\n 2 # ounces\n end",
"def currentWeight() weighins.last.weight end",
"def covered_strength; end",
"def cost_of_stay\n num_of_nights * 200.00\n end",
"def total_cost_for_stay\n number_of_nights? * 200\n end",
"def weight\n if @weight\n @weight\n else\n @confines.length\n end\n end",
"def weight\n if @weight\n @weight\n else\n @confines.length\n end\n end",
"def battery_weight; end",
"def calculate_steps_removing_water\n\t\tsteps_required_to_fill = (@big_vessel - @objective) / @small_vessel.to_f\n\t\tsteps_as_integer = (@big_vessel - @objective) / @small_vessel\n\n\t\treturn steps_as_integer *2 , steps_required_to_fill *2\n\tend",
"def bmi\n ( weight.to_f / ( (height.to_f)**2 ) ) * 703.0\n end",
"def profit(win, lost)\n count = (session[win] || 0).to_i\n count1 = (session[lost] || 0).to_i\n count - count1\nend",
"def goal\n 28\n end",
"def my_jump_strength\n 2.3*th\n end",
"def check_weights\n until ((@personal_credit_weight + @industry_weight + @biz_age_weight) == 1.0)\n puts \"Your weights do not add up to 100%. please correct this.\"\n new_weights\n end\n end",
"def heuristic_score\n 0\n end",
"def weight\n num_motions.zero? ? 0.5 : total_score.fdiv(max_score)\n end",
"def ballsbowled\n 6 * overs.floor(0) + (overs - overs.floor(0)) * 10\n end",
"def eth_gain\n return ((eth_value - eth_initial) / eth_value) * 100\n end",
"def calculate_winnings\n result = 0\n self.bookings.each do |booking|\n if booking.match.status == \"FINISHED\"\n if booking.won\n result += booking.stake * booking.odd.odds\n else\n booking.stake ? result -= booking.stake : result\n end\n end\n end\n return result.round(2)\n end",
"def gain_relative_to_current\n -1+(post_heal / pre_heal)\n end",
"def bmi_calc height, weight\n return (weight / height**2).to_i\nend",
"def calc_weight(mod, acc)\n fuel = calc_fuel(mod)\n fuel <= 0 ? acc : calc_weight(fuel, acc + fuel)\nend",
"def measure() @measure ||= (nb_weight == 0.0 ? 0.0 : sum_weight / nb_weight) end",
"def weight\n decay_conversation # fade the conversation since the last time we spoke\n incoming_weight + outgoing_weight\n end",
"def how_high\n energy * energy\nend",
"def boost\n 1.0 #self.rating / 2.0\n end",
"def masterwork_prob_bonus; 0; end",
"def weight\n @weight || @confines.length\n end",
"def threshold_spy\n puts \"Ergebnis:\"\n puts (@spy_level_defender - @spy_level_attacker)*0.05+0.5 \n return (@spy_level_defender - @spy_level_attacker)*0.05+0.5 \n end",
"def test_total_weight\n assert_equal(0 , @wp00.total_weight)\n assert_equal(384, @wp01.total_weight)\n assert_equal(576, @wp02.total_weight)\n end",
"def num_weights(); 0;end",
"def rateBoringness\n distanceToUnseen = boringnesses[:unseen] || LargeFiniteNumber\n distanceToFood = boringnesses[:food] || LargeFiniteNumber\n distanceToEnemy = boringnesses[:enemyHill] || LargeFiniteNumber\n # Apply a sub-linear function to each distance so that\n # farther away distances have less influence than close.\n # Food is more important than unexplored spaces.\n # Enemy nests are even more important(?).\n # Using a continuous function (rather than e.g. if distanceToFood < 6)\n # makes it easier to write a function that can fairly compare any\n # two locations we're considering moving to, even when the two\n # locations fall on different sides of that threshold.\n result = Math.sqrt(distanceToUnseen * ExploreWeight) +\n Math.sqrt(distanceToFood * FoodWeight) +\n Math.sqrt(distanceToEnemy * HillWeight)\n #log \"#{@col},#{@row} boringness: #{distanceToUnseen}, #{distanceToFood}, #{distanceToEnemy} ==> #{result}\"\n return result\n end",
"def calculate_calories(bodyweight)\n\ttotal_calories = bodyweight * 13\n\treturn total_calories\nend",
"def overall_WLR\n overall_losses = 0\n overall_wins = 0\n @player_champs_list.each do |champ|\n overall_losses += champ.total_losses\n overall_wins += champ.total_wins\n end\n overall_losses > 0 ? (overall_wins.to_f / overall_losses).round(2) : overall_wins.to_f\n end",
"def calc_ready_whales_below\n @ready_low_whales = []\n @ready_low_whales_weight = 0.0\n @low_whales.each do |whale|\n if whale.price.to_f > (@ticker_buy.to_f - 10)\n @ready_low_whales << whale\n @ready_low_whales_weight += (whale.price.to_f * whale.volume.to_f)\n end\n end\n @ready_low_whales.size\n end",
"def weight\n return @weight\n end",
"def query_all_weight\n d = 0 \n eqs = query_all_wearings\n p \"=>wearing=#{eqs.inspect}\"\n eqs.each {|k,v|\n d+= v.weight if v\n }\n return d\n end",
"def calculated_wounds\n wound_th = brawn\n wound_th += race.wound_threshold if race && race.wound_threshold\n # Then increase based on selected talents.\n talent_alterations.each do |_talent_id, stat|\n stat.each do |type, value|\n wound_th += value if type == :wound\n end\n end\n wound_th\n end",
"def calc_ready_whales_above\n @ready_high_whales = []\n @ready_high_whales_weight = 0.0\n @high_whales.each do |whale|\n if whale.price.to_f < (@ticker_buy.to_f + 10)\n @ready_high_whales << whale\n @ready_high_whales_weight += (whale.price.to_f * whale.volume.to_f)\n end\n end\n @ready_high_whales.size\n end",
"def reduce_weight \n @weight -= WEIGHT_INCREMENT\n # increment could be confusing and imply an increase rather than a decrease \n # but it is being reduced by increments of 10 so it makes sense??? \n # It's the best of the names that came to mind.\n end",
"def score\n w = 0.3\n time = diff_time()\n sum_goods = goods()\n sum_bads = bads()\n total = sum_goods + sum_bads\n (w * sum_goods * (sum_goods/total.to_f)**3 * (total/time)).floor\n end",
"def fitness\n if dog_count == 0 || cat_count == 0 || mouse_count == 0\n return 0;\n end\n count_error = (100 - total_count).abs\n amount_error = (100 - total_cost).abs\n if count_error > 50 || amount_error > 50\n return 0\n else\n return 100 - (count_error + amount_error) \n end\n end",
"def cost\n\t\treturn @extra_cost + @real_shake.cost\n\tend",
"def max_score\n problem.weight\n end",
"def weight\n @mass * @hopper.size\n end",
"def wound_threshold\n wound_th = self.brawn\n if self.race && self.race.wound_threshold\n wound_th += self.race.wound_threshold\n end\n # Then increase based on selected talents.\n self.talent_alterations.each do |talent_id, stat|\n stat.each do |type, value|\n if type == :wound\n wound_th += value\n end\n end\n end\n wound_th\n end",
"def total_weight\r\n\t\t@items.inject(0.0) { |sum, i| sum + i.total_unit_weight * i.quantity }\r\n\tend",
"def weighted_score\n return nil if self.points.nil?\n self.points * self.weighting / self.maximum_points\n end",
"def fuel_needed(mass)\n return (mass / 3) - 2\nend",
"def wiggle_max\n 0.5\n end",
"def total_weight_loss(db, member_id) \n total_pounds= []\n today = Time.now.strftime(\"%m-%d\") \n weight = db.execute(\"SELECT * FROM members WHERE id='#{member_id}'\") \n updated_weight = db.execute(\"SELECT * FROM weight WHERE member_id='#{member_id}'\")\n updated_weight.each do |pounds|\n total_pounds << pounds['current_weight']\n end \n weight_loss = weight[0]['starting_weight'] - total_pounds.min \nend",
"def gain(new_total_cost,original_total_cost = @original_total_cost)\n ((original_total_cost - new_total_cost) / original_total_cost.to_f) * 100\nend",
"def check_weight(current_weight_kg)\n \n # currentWeightKG calculated thanks to weight sensors\n if (current_weight_kg > @max_weight_kg)\n\n # Display 10 warnings\n for _ in 1..10 do\n puts \"\\nALERT Maximum weight capacity reached on Elevator #{@id}\"\n end\n\n # Freeze elevator until weight goes back to normal\n if (@movement != \"idle\")\n @movement = \"idle\"\n end\n \n @door.open_door()\n end\n end",
"def savings_portion_needed\n adjusted_target_income - (self.social_security + self.pensions + self.other_income)\n end",
"def strain_threshold\n strain_th = self.willpower\n if self.race && self.race.strain_threshold\n strain_th += self.race.strain_threshold\n end\n # Then increase based on selected talents.\n self.talent_alterations.each do |talent_id, stat|\n stat.each do |type, value|\n if type == :strain\n strain_th += value['count']\n end\n end\n end\n strain_th\n end",
"def choose_weighted(winning_rounds)\n puts \"\\nComputer choosing weighted - get ready to statistically lose!\"\n self.move = winning_rounds.sample[:move]\n round[:move] = move\n end",
"def fitness\n 0 - length_penalty - spelling_penalty\n end",
"def predicted_deaths\n multiplier = 0\n if @population_density >= 200\n multiplier = 0.4\n elsif @population_density >= 150\n multiplier = 0.3\n elsif @population_density >= 100\n multiplier = 0.2\n elsif @population_density >= 50\n multiplier = 0.1\n else\n multiplier = 0.05\n end\n number_of_deaths = (@population * multiplier).floor\n # end\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n end",
"def battler_hue\n return 0\n end",
"def score\n 3*@tally + 5*@strength + 2*@wealth + @food + 30*@monsters_killed\n end",
"def prom_weight\n if pet_histories.length > 0\n promw= pet_histories.sum(:weight)\n promw/pet_histories.length\n else\n \"0\"\n end\n end",
"def fuel_up()\n\t\tgallons_needed = 10.0 - @fuel\n\t\tputs \"You must pay $#{3.5 * gallons_needed}\"\n\t\t@fuel = 10.0\n\tend",
"def win_hp\n maxhp * features_sum(:hp_on_win)\n end",
"def current_bmi_alert\n weight = self.current_weight\n height = self.current_height\n alert = nil\n unless weight == 0 || height == 0\n current_bmi = (weight/(height*height)*10000).round(1);\n if current_bmi <= 18.5 && current_bmi > 17.0\n alert = 'Low BMI: Eligible for counseling'\n elsif current_bmi <= 17.0\n alert = 'Low BMI: Eligible for therapeutic feeding'\n end\n end\n\n alert\n end",
"def perfect_material_efficiency\n (0.02 * self.blueprint.waste_factor * quantity).ceil\n end",
"def how_high(energy)\n energy * energy\nend",
"def goods_produced\n (0.2 * base_production + trade_goods_bonus).round(6)\n end",
"def rest\n @total_damage = @total_damage - 0.1 * strength\n end",
"def cost\r\n 0\r\n end",
"def predicted_deaths\r\n # predicted deaths is solely based on population density \r\n\r\n # multiplier when population density is less than 50\r\n multiplier = 0.05\r\n\r\n # sets new population density variable to have a mximum of 200\r\n max_pop = 200\r\n population_density_temp = [@population_density, max_pop].min\r\n \r\n multiplier = 0.1 * (population_density_temp / 50).floor if population_density_temp >= 50\r\n\r\n number_of_deaths = (@population * multiplier).floor\r\n\r\n\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end",
"def calculate_bmi weight, height\n (weight.to_f / (height.to_f * height.to_f)) * 703\nend",
"def threshold_spy\n return (user_science_level(defender, spy_id) - user_science_level(attacker, spy_id))*0.05+0.5 \n end",
"def compute_weighted_overall_score\n (Player::Feedback::FIT_WEIGHT * avg_fit_score +\n Player::Feedback::PUNC_WEIGHT * avg_punctuality_score +\n Player::Feedback::SKILL_WEIGHT * avg_skill_score +\n Player::Feedback::PERS_WEIGHT * avg_personality_score)\n end",
"def predicted_deaths\n# predicted deaths is solely based on population density\nif @population_density >= 200\n multiplier = 0.4\nelsif @population_density >= 150\n multiplier = 0.3\nelsif @population_density >= 100\n multiplier = 0.2\nelsif @population_density >= 50\n multiplier = 0.1\nelse\n multiplier = 0.05\nend\n number_of_deaths = (@population * multiplier).floor\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\nend",
"def wallet_minimum\n (bet_count / 5) + 10\n end",
"def cap_redeem(num_bottles)\n\tnum_bottles/4\nend",
"def weight\n (kyc_level == 'any' ? 0 : 10) + (group == 'any' ? 0 : 1)\n end",
"def overall_KDR\n overall_deaths = 0\n overall_kills = 0\n @player_champs_list.each do |champ|\n overall_deaths += champ.total_deaths\n overall_kills += champ.total_kills\n end\n overall_deaths > 0 ? (overall_kills.to_f / overall_deaths).round(2) : overall_kills.to_f\n end",
"def needed_amount_less_savings\n recommended_min_portfolio - portfolio_after_growth\n end",
"def ksratio\n (@shots > 0) ? @kills.to_f / @shots : 0\n end",
"def wealth\n @gold + inventory_worth\n end",
"def attack_bonus(lv)\n (110 * 3 * lv.to_f + 250) / 100 + 5\n end",
"def baserunning_total\n self.rating_15 + \n self.rating_16 +\n self.rating_17 +\n self.rating_18\n end",
"def hp_on_kill\n (maxhp * features_sum(:hp_on_kill)).to_i\n end",
"def percent_passes; end",
"def percent_passes; end",
"def trend\n won_games_in_last_48_hours = self.won_games.\n where('updated_at > ?', DateTime.now - 48.hours).\n count\n lost_games_in_last_48_hours = self.games.\n where('updated_at > ?', DateTime.now - 48.hours).count -\n won_games_in_last_48_hours\n\n if won_games_in_last_48_hours > lost_games_in_last_48_hours\n return :up\n elsif lost_games_in_last_48_hours > won_games_in_last_48_hours\n return :down\n else\n return :same\n end\n end",
"def penalty_total\n self.added_penalties.each{|added_penalty| self.calculate_penalties if added_penalty.count_generated_at < MyDate::today}\n if self.added_penalties == []\n return\n elsif self.added_penalties[0].sum == 0\n return\n else\n self.added_penalties[0].sum\n end\n end",
"def calculate(height, weight)\n bmi = (weight / height) / height.to_f;\nend",
"def hitting_total\n self.rating_19 +\n self.rating_20 +\n self.rating_21 +\n self.rating_22 +\n self.rating_23 +\n self.rating_24 +\n self.rating_25 +\n self.rating_26 +\n self.rating_27\n end",
"def remaining_iterations\n (remaining_points.to_f / estimated_velocity.to_f).ceil\n end",
"def obp \n\t\t# prevent divide by zero\n\t\tif (self[:at_bats] != 0)\t\t\n\t\t\t((self[:hits] + self[:walks] + self[:hit_by_pitch])/(self[:at_bats] + self[:walks] + self[:hit_by_pitch] + self[:sacrifice_flies].to_f)).round(3)\n\t\telse\n\t\t\t0\n\t\tend\n\tend",
"def test_provided_weight_example\n assert_equal 60, @system.corrected_tower.weight\n end",
"def suitable_halfs\n required_amount\n end"
] | [
"0.72903585",
"0.71990526",
"0.7162943",
"0.71080804",
"0.7094358",
"0.706027",
"0.69335914",
"0.6790681",
"0.6746478",
"0.6721428",
"0.66577303",
"0.65615785",
"0.65615785",
"0.6550891",
"0.65034646",
"0.6503012",
"0.64950174",
"0.6450043",
"0.6445826",
"0.64377886",
"0.64299643",
"0.6382789",
"0.63599545",
"0.6357718",
"0.6349624",
"0.6346339",
"0.63354796",
"0.6333467",
"0.6327797",
"0.6324291",
"0.6318641",
"0.63091147",
"0.6301866",
"0.6299823",
"0.6294054",
"0.6292153",
"0.6264226",
"0.6261954",
"0.6261802",
"0.62613803",
"0.6255818",
"0.62283176",
"0.62187934",
"0.62173766",
"0.62134594",
"0.6203414",
"0.6194418",
"0.6189702",
"0.6188251",
"0.61566764",
"0.61550504",
"0.6154969",
"0.6153234",
"0.6148046",
"0.61332184",
"0.6129624",
"0.6121344",
"0.61171997",
"0.61065215",
"0.6104864",
"0.61017835",
"0.60989416",
"0.6094023",
"0.609248",
"0.6092211",
"0.6088787",
"0.6082959",
"0.6082097",
"0.6080909",
"0.6068974",
"0.60676634",
"0.6066187",
"0.60506666",
"0.60470206",
"0.60413426",
"0.60399705",
"0.60374177",
"0.60362387",
"0.6035535",
"0.60233",
"0.60223925",
"0.6021924",
"0.6020899",
"0.60179013",
"0.6001379",
"0.6001203",
"0.6000628",
"0.5992201",
"0.59753054",
"0.59743714",
"0.59727526",
"0.59727526",
"0.5958931",
"0.59588766",
"0.5948816",
"0.5945287",
"0.593995",
"0.5939473",
"0.5928918",
"0.5927322"
] | 0.7574595 | 0 |
8. A user can create a new exercise to add to the database | def create_new_exercise(exercise, muscle_group)
Exercise.create(name: exercise, muscle_group: muscle_group)
puts "Thank you for sharing!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_exercise()\n\n #Gets all the information from the user\n message(\"Please enter a name for this new exercise: \")\n name = gets.chomp\n message(\"Please enter a description for \" + name)\n description = gets.chomp\n message(\"Please enter a duration (in seconds) for \" + name)\n duration = gets.chomp\n\n #Creates the exercise object and places it in last_built temporarily\n @last_built = Exercise.new(name,description,duration)\n\n #Outputs the details of the object\n message(\"Please confirm that this information is correct:\")\n puts \"Name: \" + name\n puts \"Description: \" + description\n puts \"Duration (sec): \" + duration\n\n #Confirmation dialog\n continue = confirm(\"Would you like to add this exercise to the database? (Y/N)\")\n if continue == true\n #Places the built object into the database\n $database.add_new(\"exercise\", @last_built)\n return\n elsif continue == false\n #Discards the built object\n return\n end\n end",
"def add_exercise(db)\n puts \"What is the name of the exercise you want to add?\"\n exercise = gets.chomp\n if is_existing_exercise(db, exercise)\n puts \"#{exercise} is already in the database.\"\n else\n db.execute(\"INSERT INTO exercises (name) VALUES (?)\", [name])\n puts \"#{exercise} was added to the database.\"\n end\nend",
"def create\n @user = current_user\n @exercise = Exercise.new(exercise_params)\n @exercise = Exercise.where(name: @exercise.name).first_or_create(exercise_params)\n unless @user.exercises.where(name: @exercise.name).exists?\n @exercise.save\n @user.exercises << @exercise\n end\n respond_to do |format|\n if @user.save\n format.html { redirect_to user_exercises_path, notice: 'Exercise was successfully created.' }\n format.json { render :show, status: :created, location: @exercise }\n else\n format.html { render :new }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @exercise = current_user.exercises.new(exercise_params)\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, notice: 'Uebung was successfully created.' }\n format.json { render action: 'show', status: :created, location: @exercise }\n else\n format.html { render action: 'new' }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @exercise = Exercise.new(exercise_params)\n @exercise.author = current_user\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, notice: \"Exercise was successfully created.\" }\n format.json { render :show, status: :created, location: @exercise }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @exercise = Exercise.new(params[:exercise])\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, :notice => 'exercise was successfully created.' }\n format.json { render :json => @exercise, :status => :created, :location => @exercise }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @exercise.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @exercise = Exercise.new(params[:exercise])\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, notice: 'Exercise was successfully created.' }\n format.json { render json: @exercise, status: :created, location: @exercise }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @title = 'Add Exercise'\n @exercise = Exercise.new\n @exercise.exercise_category = ExerciseCategory.new\n end",
"def create\n @exercise = Exercise.new(params[:exercise])\n\n respond_to do |format|\n if @exercise.save\n flash[:class] = \"alert alert-success\"\n format.html { redirect_to @exercise, :notice => 'exercise was successfully created.' }\n format.json { render :json => @exercise, :status => :created, :location => @exercise }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @exercise.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @exercise = Exercise.new(params[:exercise])\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, notice: 'Exercise was successfully created.' }\n format.json { render json: @exercise, status: :created, location: @exercise }\n else\n flash.now[:error] = @exercise.errors.full_messages\n format.html { render action: \"new\"}\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @exercise = current_user.exercises.build(exercise_params)\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to exercise_weight_logs_path(@exercise)}\n format.json { render :show, status: :created, location: @exercise }\n else\n format.html { render :new }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @exercise = Exercise.new(exercise_params)\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, notice: 'Exercise was successfully created.' }\n format.json { render action: 'show', status: :created, location: @exercise }\n else\n format.html { render action: 'new' }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @exercise = Exercise.new(params[:exercise])\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to(@exercise, :notice => 'Exercise was successfully created.') }\n format.xml { render :xml => @exercise, :status => :created, :location => @exercise }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @exercise.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n # create new exercise\n if params[:create_exercise_category]\n cu_id = current_user.id\n category = ExerciseCategory.find_or_new_by_category(cu_id, params[:create_category])\n params[:exercise][:exercise_category_attributes][:category] = category.category\n @exercise = Exercise.new params[:exercise]\n @exercise.exercise_category = category\n set_up_categories\n else\n @exercise = Exercise.new params[:exercise]\n # attempt to save exercise\n if @exercise.save\n # associate exercise with user\n current_user.exercises << @exercise\n # display the exercise\n redirect_to :action => 'show', :id => @exercise.id\n return\n else\n flash.now[:error] = 'There was a problem saving your exercise'\n flash.now[:errors] = @exercise.errors\n end\n end\n @title = 'New Exercise'\n render :action => 'new'\n end",
"def create_user(db, name, weight, exercise, progression)\n db.execute(\"INSERT INTO user (name, weight, exercise, progression) VALUES (?, ?, ?, ?)\", [name, weight, exercise, progression])\nend",
"def create\n @exercise = @workout.exercises.new(exercise_params)\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, notice: I18n.t('exercises.created') }\n format.json { render :show, status: :created, location: @exercise }\n else\n format.html { render :new }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @exercise = Exercise.new(params[:exercise].update(:company_id => current_company.id))\n #TODO agregar cuentas a un ejercicio nuevo. Seleccionar las cuentas del último ejercicio\n #@exercise.accounts = \n \n flash[:notice] = t('flash.actions.create.notice', :resource_name => Exercise.model_name.human) if @exercise.save\n respond_with(@exercise, :location => exercises_path)\n end",
"def addExistingExercise\n @workout_day = WorkoutDay.find(params[:id])\n exerciseId = params[:exercise][:id]\n\n exercise = Exercise.find(exerciseId)\n\n if !exercise.nil?\n @workout_day.exercises << exercise\n end\n\n @workout_day.save\n\n respond_to do |format|\n format.html { redirect_to @workout_day, notice: 'Exercise successfully added' }\n format.json { render json: @workout_day, status: :created, location: @workout_day }\n end\n end",
"def create_database\n db = SQLite3::Database.new(\"workout.db\")\n \n create_users_table = <<-SQL\n CREATE TABLE IF NOT EXISTS users(\n id INTEGER PRIMARY KEY,\n username VARCHAR(255),\n age INT\n )\n SQL\n\n create_join_table = <<-SQL\n CREATE TABLE IF NOT EXISTS exercises_users(\n id INTEGER PRIMARY KEY,\n reps INT,\n weight INT,\n exercise_id INT,\n user_id INT,\n FOREIGN KEY (user_id) REFERENCES users(id),\n FOREIGN KEY (exercise_id) REFERENCES exercises(id)\n )\n SQL\n\n create_exercises_table = <<-SQL\n CREATE TABLE IF NOT EXISTS exercises(\n id INTEGER PRIMARY KEY,\n name VARCHAR(255) \n )\n SQL\n db.execute(create_join_table)\n db.execute(create_users_table)\n db.execute(create_exercises_table)\n db\nend",
"def exercise_params\n params.require(:exercise).permit(:body, :last_import, :category_id)\n end",
"def test_add_answer\n create_template(\"Test Template\")\n template_id = find_last_template_id\n create_template_question(\"Question 1\", template_id)\n create_test(template_id)\n\n question_id = find_last_question_id\n test_id = find_last_test_id\n\n @db.add_answer(question_id, test_id, \"Answer 1\")\n answer = find_answer(question_id, test_id)[:answer]\n\n assert_equal(answer, \"Answer 1\")\n delete_template(template_id)\n end",
"def exercise_params\n params.require(:exercise).permit(:name, :description, :time, :workout_id)\n end",
"def create\n @my_exercise = MyExercise.new(params[:my_exercise])\n\n respond_to do |format|\n if @my_exercise.save\n flash[:notice] = 'MyExercise was successfully created.'\n format.html { redirect_to(@my_exercise) }\n format.xml { render :xml => @my_exercise, :status => :created, :location => @my_exercise }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @my_exercise.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_entry\n system(\"clear\")\n puts \"Gaal-Williams Code Camp\"\n puts \"-\"*100\n puts \"Session for user: #{$current_student.username}\"\n puts \"=\"*100\n sleep(0.5)\n puts \"Creating Journal for Lecture: #{Lecture.find($current_lecture_id).name}\"\n puts \"-\"*100\n JournalEntry.create(lecture_id: $current_lecture_id, student_id: $current_student_id, what_did_i_learn: $prompt.ask(\"What did you learn?\", required: true), what_was_unclear: $prompt.ask(\"What was not clear?\", required: true), confidence_level: $prompt.select('How confident are you in the material?', [1, 2, 3, 4, 5], required: true), feelings_on_topic: $prompt.ask(\"How did you feel about the lecture content?\", required: true), feelings_general: $prompt.ask(\"How do you personally feel today?\", required: true), mood: $prompt.select(\"Rate your mood (5-best, 1-worst\", [1, 2, 3, 4, 5], required: true))\n\n $current_journal_id = JournalEntry.last.id\n display_journal_entry($current_journal_id)\nend",
"def add_question\n @event.respond('Enter a new question: ')\n ques = @event.user.await!(timeout: 60)\n return open_channel if ques.nil?\n\n ques = ques.content\n @event.respond('Enter the answer: ')\n ans = @event.user.await!(timeout: 60)\n return open_channel if ans.nil?\n\n ans = ans.content.gsub(/\\W/, '').downcase # Clean up the answer by removing caps and non [a-z] [0-9] chars\n @event.respond('Commit to database? (y/n): ')\n prompt = @event.user.await!(timeout: 60)\n unless prompt.nil? || prompt.content != 'y'\n begin\n @@trivia_db.prepare('INSERT INTO trivia(question, answer, addedby) VALUES(?, ?, ?)').execute(ques, ans, @event.user.id)\n rescue SQLite3::Exception\n @event.respond('Unable to write to database!')\n else\n @event.respond('Changes saved')\n end\n end\n open_channel\n end",
"def exercise_params\n params.require(:exercise).permit(:date, :exercise, :weight, :reps, :max, :bulk, :tone, :user_id)\n end",
"def create\n @exercise_instruction = ExerciseInstruction.new(params[:exercise_instruction])\n @exercise_instruction.user_id = current_user.id\n\n respond_to do |format|\n if @exercise_instruction.save\n format.html { redirect_to @exercise_instruction.exercise, notice: 'Note was successfully created.' }\n format.json { render json: @exercise_instruction, status: :created, location: @exercise_instruction }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exercise_instruction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def exercise_params\n params.require(:exercise).permit(:name)\n end",
"def create\n @api_v1_exercise = Api::V1::Exercise.new(api_v1_exercise_params)\n\n respond_to do |format|\n if @api_v1_exercise.save\n format.html { redirect_to @api_v1_exercise, notice: 'Exercise was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_exercise }\n else\n format.html { render :new }\n format.json { render json: @api_v1_exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @exercise = Exercise.all.map{ |c| [c.name, c.id]}\n @training = Training.new(training_params)\n\n respond_to do |format|\n if @training.save\n format.html { redirect_to @training, notice: 'Training was successfully created.' }\n format.json { render :show, status: :created, location: @training }\n else\n format.html { render :new }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_exercise(new_exercise, new_repeats, new_break)\n @exercises.push(new_exercise)\n @repititions.push(new_repeats)\n @break_time.push(new_break)\n end",
"def exercise_params\n params.require(:exercise).permit(:name, :question, :feedback,\n :experience, :id, :is_public, :priority, :question_type,\n :exercise_version, :exercise_version_id, :commit,\n :mcq_allow_multiple, :mcq_is_scrambled, :languages, :styles,\n :tag_ids)\n end",
"def create\n @do_exercise = DoExercise.new(params[:do_exercise])\n\n respond_to do |format|\n if @do_exercise.save\n format.html { redirect_to @do_exercise, notice: 'Do exercise was successfully created.' }\n format.json { render json: @do_exercise, status: :created, location: @do_exercise }\n else\n format.html { render action: \"new\" }\n format.json { render json: @do_exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def exercise_params\n params.require(:exercise).permit(:workout_id, :title, :sets, :reps)\n end",
"def add_input (db, user_input)\r\n db.execute(\"INSERT INTO strength (date, exercise, weight, reps, minutes, difficult) VALUES (?, ?, ?, ?, ?, ?)\", [user_input])\r\nend",
"def create\n @lecture = Lecture.new(lecture_params)\n #if @lecture.password == \"\"\n @lecture.password = nil\n #end\n \n respond_to do |format|\n if @lecture.save\n top = Topic.new\n top.name = @lecture.name\n top.lecture = @lecture\n top.save\n \n exp = Explanation.new\n exp.author = true\n exp.user = current_user\n exp.topic = top\n exp.save\n \n format.html { redirect_to @lecture }\n format.json { render action: 'show', status: :created, location: @lecture }\n else\n format.html { render action: 'new' }\n format.json { render json: @lecture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_exercise\n @exercise = current_user.exercises.find_by(id: params[:id])\n end",
"def create_main_course(db, name, main_course_descr)\n db.execute(\"INSERT INTO main_course (name, main_course_descr) VALUES (?, ?)\", [name, main_course_descr])\nend",
"def add_to_database\n Partner.add({\"assignment_id\" => \"#{self.assignment_id}\", \"name_worked\" => \"#{self.name_worked}\"})\n end",
"def create\n @performed_exercise = PerformedExercise.new(performed_exercise_params)\n\n respond_to do |format|\n if @performed_exercise.save\n format.html { redirect_to @performed_exercise, notice: 'Performed exercise was successfully created.' }\n format.json { render :show, status: :created, location: @performed_exercise }\n else\n format.html { render :new }\n format.json { render json: @performed_exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def exercise_params\n params.require(:exercise).permit(:name, :muscles)\n end",
"def create\n exercise = Exercise.create(exercise_params)\n if exercise\n render json: exercise\n else\n render json: {error: 'Workout was not created.'}\n end\n end",
"def create\n @exercise = Exercise.new(params[:exercise])\n @exercise.lecture_id = params[:lecture_id]\n @exercise.clclass_id = params[:clclass_id]\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to [@clclass,@exercise], notice: 'Exercise was successfully created.' }\n format.json { render json: @exercise, status: :created, location: @exercise }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_question\n question_hash = Adapter.quiz_api(difficulty) #use adapter method, with difficulty passes into the url as a variable, to gnerate a new list of questions.\n new_question = Question.new #make a new question instance\n new_question.save #save now so we can store the question's id in the answer by calling self.id\n new_question.content = question_hash['question'] #adding all necessary column data to this question object/row\n new_question.create_answers(question_hash)\n new_question.quiz_id = self.id\n new_question.save #send the newly created question to the database\n end",
"def exercise_params\n params.require(:exercise).permit(:name, :kata_details)\n end",
"def create\n @exercise_task = ExerciseTask.new(exercise_task_params)\n \n respond_to do |format|\n if @exercise_task.save\n format.html { redirect_to @exercise_task, notice: 'Exercise task was successfully created.' }\n format.json { render :show, status: :created, location: @exercise_task }\n else\n format.html { render :new }\n format.json { render json: @exercise_task.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @programme_exercise = ProgrammeExercise.new(programme_exercise_params)\n\n respond_to do |format|\n if @programme_exercise.save\n format.html { redirect_to @programme_exercise, notice: 'Programme exercise was successfully created.' }\n format.json { render action: 'show', status: :created, location: @programme_exercise }\n else\n format.html { render action: 'new' }\n format.json { render json: @programme_exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_exercise\n @exercise = Exercise.find(params[:id])\n end",
"def set_exercise\n @exercise = Exercise.find(params[:id])\n end",
"def add_tutorial(day, time, location, tutor, abbrev)\n tutor_role = unit_roles.where(\"user_id=:user_id\", user_id: tutor.id).first\n if tutor_role.nil? || tutor_role.role == Role.student\n return nil\n end\n\n Tutorial.find_or_create_by( { unit_id: id, abbreviation: abbrev } ) do |tutorial|\n tutorial.meeting_day = day\n tutorial.meeting_time = time\n tutorial.meeting_location = location\n tutorial.unit_role_id = tutor_role.id\n end\n end",
"def create_recipe(db,name,description,length,difficulty)\n # your code here\nend",
"def update_exercise(db, user_id)\n # Prompts user for an exercise until a valid response is received\n puts \"What exercise would you like to update?\"\n exercise = gets.chomp\n until is_existing_exercise(db, exercise) do\n puts \"Invalid exercise. Please retry.\"\n exercise = gets.chomp\n end\n exercise_id = db.execute(\"SELECT id FROM exercises WHERE name=?\", exercise)\n exercise_id = exercise_id[0][0]\n\n # If not data exists for this user with this exercise, creates a new row\n if db.execute(\"SELECT * FROM exercises_users WHERE user_id=? AND exercise_id=?\", [user_id, exercise_id]).empty?\n db.execute(\"INSERT INTO exercises_users (reps, weight, exercise_id, user_id) VALUES (0, 0, ?, ?)\", [exercise_id, user_id])\n end\n \n puts \"How many reps did you do?\"\n reps = gets.chomp\n puts \"How much weight did you use?\"\n weight = gets.chomp\n db.execute(\"UPDATE exercises_users SET reps=?, weight=? WHERE exercise_id=? AND user_id=?\", [reps, weight, exercise_id, user_id])\nend",
"def add_teacher(first, last, campus, veracross, email)\n puts(\"Adding #{first} #{last} #{campus} #{veracross} #{email}\")\n Student.create(\n first_name: first,\n last_name: last,\n campus: campus,\n veracross_id: veracross,\n email: email,\n teacher: true\n )\nend",
"def set_exercise\n @exercise = Exercise.find(params[:id])\n end",
"def set_exercise\n @exercise = Exercise.find(params[:id])\n end",
"def set_exercise\n @exercise = Exercise.find(params[:id])\n end",
"def set_exercise\n @exercise = Exercise.find(params[:id])\n end",
"def set_exercise\n @exercise = Exercise.find(params[:id])\n end",
"def set_exercise\n @exercise = Exercise.find(params[:id])\n end",
"def set_exercise\n @exercise = Exercise.find(params[:id])\n end",
"def log_new_workout(exercise, date)\n exercise_check = Exercise.search_exercise_by_name(exercise)\n exercise_instance = Exercise.all.find{|exercises| exercises.name == exercise}\n if exercise_check == \"Sorry. We don't have any workouts called #{exercise}. Please return to the main menu to create this new exercise and share with the rest of our FitMePan crew.\"\n return exercise_check\n else\n Workout.create(user_id: self.id, exercise_id: exercise_instance.id, date: date)\n end\n puts \"Thanks for logging your workout!\"\n end",
"def add_exercise(name)\n #want to check for duplicates, will attempt later\n #exercises = db.execute(\"SELECT name FROM Exercise\")\n #exercises.each do |ex|\n #if name != ex[0]\n $db.execute(\"INSERT OR IGNORE INTO Exercise (name) VALUES (?)\", [name])\nend",
"def test_add_1_recipe\n\t\tputs \"TEST 4\"\n\t\tassert( @db.empty?, \"DB should be empty\" )\n\t\t@db.addRecipe(\"Cookies\", [\"Flour\", \"BakingSoda\"] )\n\t\tassert( @db.empty?, \"DB should still be empty after adding recipe with non existing foods\" )\n\t\t@db.addFood(\"Flour\", \"84\" )\n\t\t@db.addFood(\"BakingSoda\", \"123\" )\n\t\tassert( @db.size == 2, \"there should be 2 foods,ready for recipe\" )\n\t\t@db.addRecipe(\"Cookies\", [\"Flour\", \"BakingSoda\"] )\n\t\tassert( @db.size == 3, \"With recipe, size should == 3\" )\n\t\tassert( @db.is_Recipe?(\"Cookies\") , \"Cookies should be a recipe\" )\n\tend",
"def exercise_params\n params.require(:exercise).permit(:name, :trainingsart, :anzset, :anzwdh, :beschreibung, :muskelgruppe, :published)\n end",
"def create\n @patient_exercise = PatientExercise.new(params[:patient_exercise])\n\n respond_to do |format|\n if @patient_exercise.save\n format.html { redirect_to @patient_exercise, notice: 'Patient exercise was successfully created.' }\n format.json { render json: @patient_exercise, status: :created, location: @patient_exercise }\n else\n format.html { render action: \"new\" }\n format.json { render json: @patient_exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @exercise_set = ExerciseSet.new(params[:exercise_set])\n\n respond_to do |format|\n if @exercise_set.save\n format.html { redirect_to @exercise_set, notice: 'Exercise set was successfully created.' }\n format.json { render json: @exercise_set, status: :created, location: @exercise_set }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exercise_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_test(test_name)\n\tdb.execute(\"CREATE TABLE IF NOT EXISTS #{test_name} (id INTEGER PRIMARY KEY,\n student_first VARCHAR(255),\n student_last VARCHAR(255),\n grade INT\n );\")\nend",
"def create\n @exercise_name = ExerciseName.new(exercise_name_params)\n\n respond_to do |format|\n if @exercise_name.save\n format.html { redirect_to @exercise_name, notice: 'Exercise name was successfully created.' }\n format.json { render :show, status: :created, location: @exercise_name }\n else\n format.html { render :new }\n format.json { render json: @exercise_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t food_params = params.require(:food).permit(:name, :exercise, :calories, :time)\n\t\t food = Food.create(food_params)\n\t\t current_user.foods << food\n\t\t if food.save\n\t\t \tredirect_to \"/users/#{current_user.id}\"\n\t\t end\n\tend",
"def create\n return\n teacher = Teacher.find_by_name(params[:teacher])\n user = User.new(:username => params[:username])\n\n teacher.users << user\n \n user.record_exam(params)\n\n respond_to do |format|\n format.html { render :status => 200, :text => 'done' }\n end\n end",
"def exercise_params\n params.require(:exercise).permit(:name, :notes,:base_weight)\n end",
"def create \n @tutorial = Tutorial.new(tutorial_param)\n if @tutorial.save\n redirect_to :action => 'index' \n else\n redirect_to :action => 'new', :msg => 'some feilds have not been filled out fully'\n end\n end",
"def create\n @exercise_program = ExerciseProgram.new(exercise_program_params)\n @exercise_program.user_id = current_user.id #current_user.try(:id)\n\n respond_to do |format|\n if @exercise_program.save\n format.html { redirect_to @exercise_program, notice: 'Exercise program was successfully created.' }\n format.json { render :show, status: :created, location: @exercise_program }\n else\n format.html { render :new }\n format.json { render json: @exercise_program.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_recipe(db,name,description,length,difficulty)\n q = \"INSERT INTO recipes (name,description,length,difficulty) VALUES ('#{name}','#{description}',#{length},#{difficulty});\"\n return db.execute(q)\nend",
"def create_new_hero(db, name, age, specialty, turing_award)\r\n db.execute(\"INSERT INTO tech_heroes(name, age, specialty, turing_award) VALUES (?, ?, ?, ?)\", [name, age, specialty, turing_award])\r\nend",
"def create_employee(database, first_name, last_name, wage, title, last_four_ssn, business_id)\n database.execute(\"INSERT INTO employees (first_name, last_name, wage, title, last_four_ssn, business_id) VALUES (?, ?, ?, ?, ?, ?)\", [first_name, last_name, wage, title, last_four_ssn, business_id])\nend",
"def create\n\t\t@problem = Problem.find_by_id(session[:problem_id])\n\t\t@test_case = TestCase.new\n\t\tif lecturer_signed_in?\n\t\t\t@test_case = TestCase.new(post_params)\n\t\t\t@test_case.owner_id = current_lecturer.id\n\t\t\t@test_case.owner_type = \"lecturer\"\n\t\t\t@test_case.problem_id = session[:problem_id]\n\t\telsif teaching_assistant_signed_in?\n\t\t\t@test_case = TestCase.new(post_params)\n\t\t\t@test_case.owner_id = current_teaching_assistant.id\n\t\t\t@test_case.owner_type = \"teaching assistant\"\n\t\t\t@test_case.problem_id = session[:problem_id]\n\t\tend\n\t\tif @test_case.save\n\t\t\t@problem.test_cases << @test_case\n\t\t\tif session[:flag] == \"1\"\n\t\t\t\tredirect_to :controller => 'test_cases', :action => 'index',\n\t\t\t\t\t:problem_id => session[:problem_id], :track_id => session[:track_id], :flag => \"1\"\n\t\t\telsif session[:flag] == \"0\"\n\t\t\t\tredirect_to :controller => 'model_answers', :action => 'new',\n\t\t\t\t\t:problem_id => session[:problem_id], :track_id => session[:track_id], :flag => \"0\"\n\t\t\tend\n\t\telse\n\t\t\trender :action=>'new', :problem_id => @test_case.problem_id, :flag => session[:flag]\n\t\tend\n\tend",
"def test_add_participant()\n\t\tparticipant = Participant.new\n assert participant.valid?\n\t\t#TODO Should an empty Participant be allowed?\n\t\t# assert !participant.valid?\n\t\t#TODO Define required fields in test and add those validations to the model so test passes.\n user = users(:student1)\n participant.user= user\n participant.assignment= assignments(:assignment1)\n\t\tassert participant.valid?\n assert \"student1\", participant.name\n assert \"student1_fullname\", participant.fullname\n assert \"assignment 1\", participant.assignment.name\n\tend",
"def add_new_school(db, name)\n db.execute(\"INSERT INTO school (name) VALUES (?)\", [name])\nend",
"def create_students (db, name, essay_1, essay_2, midterm_1, midterm_2)\n\tdb.execute(\"INSERT INTO students (name, essay_1, essay_2, midterm_1, midterm_2) VALUES (?, ?, ?, ?, ?)\", [name, essay_1, essay_2, midterm_1, midterm_2])\nend",
"def create\n @daily_exercise = DailyExercise.new(params[:daily_exercise])\n\n respond_to do |format|\n if @daily_exercise.save\n format.html { redirect_to @daily_exercise, notice: 'Daily exercise was successfully created.' }\n format.json { render json: @daily_exercise, status: :created, location: @daily_exercise }\n else\n format.html { render action: \"new\" }\n format.json { render json: @daily_exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @exerciseoverview = Exerciseoverview.new(exerciseoverview_params)\n\n respond_to do |format|\n if @exerciseoverview.save\n format.html { redirect_to @exerciseoverview, notice: 'Exerciseoverview was successfully created.' }\n format.json { render action: 'show', status: :created, location: @exerciseoverview }\n else\n format.html { render action: 'new' }\n format.json { render json: @exerciseoverview.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @workout = Workout.new(workout_params)\n if user_signed_in?\n @workout.owner = current_user\n @workout.users << current_user\n else\n @workout.owner = temp_user\n session[:workout_id] = @workout.id\n end \n @workout.save\n ex_params = exercise_params[:exercise].map do |e|\n e[:dur] = e[:dur][:minutes].to_i*60 + e[:dur][:seconds].to_i\n e[:workout_id] = @workout.id\n e\n end\n @exercises = @workout.exercises.create(ex_params)\n\n respond_to do |format|\n if @workout.save\n format.html { redirect_to @workout, notice: \"Workout was successfully created\" }\n format.json { render json: {workoutId: @workout.id}, status: 200 }\n else\n format.html { render :new }\n format.json { render json: @workout.errors, status: 500 }\n end\n end\n end",
"def add_task(db, task, date_needed, notes)\n db.execute(\"INSERT INTO list (task, date_needed, notes) VALUES (?, ?, ?)\", [task, date_needed, notes])\nend",
"def create_user(db, first_name, last_name, age, body_weight, gender)\n\tdb.execute(\"INSERT INTO athlete (first_name, last_name, age, body_weight, gender, gym_trips) VALUES (?,?,?,?,?,?)\", [first_name, last_name, age, body_weight, gender, 0 ])\nend",
"def test_add_1food\n\t\tputs \"TEST 2\"\n\t\tassert( @db.empty?, \"DB should be empty\" )\n\t\t@db.addFood(\"Potato\", \"123\")\n\t\tassert( @db.size == 1, \"Size of DB != 1\")\n\t\tassert( !@db.empty?, \"DB should not be empty\")\n\tend",
"def create_workout()\n\n #Gets name information from user\n message(\"Please enter a name for this new workout routine: \")\n name = gets.chomp\n\n #Checks to see if the exercise database is empty - stopping if it is\n if $database.exercise_list.empty?\n message(\"There are no Exercises in the database - Aborting... Please create some Exercises and try again.\")\n return\n end\n\n #Creates a workout object and stores it in last_built\n @last_built = Workout_Routine.new(name)\n\n #Add any number of exercise objects from the database to the workout\n repeat = true\n while repeat == true\n\n #Gets Exercise information\n message(\"Please type the name of an Exercise to add it to the workout:\")\n $database.print_all(\"exercise\")\n exercise = gets.chomp\n exercise_object = $database.search(\"exercise\", exercise, \"object\")\n\n message(\"Please enter the number of times \" + exercise + \" should be repeated:\")\n number = gets.chomp\n\n message(\"Please enter the rest time (sec) between repeats of \" + exercise + \":\")\n time = gets.chomp\n\n #Adds the exercise object to the workout\n @last_built.add_exercise(exercise_object, number, time)\n\n repeat = confirm(\"Would you like to add another Exercise? (Y/N)\")\n end\n\n #Lists the details of the exercises added\n message(\"Please confirm that this information is correct:\")\n @last_built.list_details\n\n #Confirmation Dialog\n continue = confirm(\"Would you like to add this workout routine to the database? (Y/N)\")\n if continue == true\n #Adds the workout object to the database\n $database.add_new(\"workout\", @last_built)\n return\n #Discard the workout\n elsif continue == false\n return\n end\n\n end",
"def attend!(exerciseclass)\n \tself.class_bookings.create!(exercise_class_id: exerciseclass.id)\n \tend",
"def view_info(db, user_id)\n puts \"Which exercise would you like to view?\"\n exercise = gets.chomp\n until is_existing_exercise(db, exercise) do\n puts \"Invalid exercise. Please retry.\"\n exercise = gets.chomp\n end\n\n results = db.execute(\"SELECT * FROM exercises_users WHERE user_id=? AND exercise_id=?\", [user_id, exercise_id])\n puts \"You last did #{results[0][1]} reps of #{exercise} at #{results[0][2]} pounds\"\nend",
"def exercise_program_params\n params.require(:exercise_program).permit(:name, :description, :user_id)\n end",
"def create_menu(db, app_id, main_courses_id, desserts_id)\n db.execute(\"INSERT INTO menu (app_id, main_courses_id, desserts_id) VALUES (?, ?, ?)\", [app_id, main_courses_id, desserts_id])\nend",
"def add_grade(database, student_id, subject_id, grade)\r\n\tdatabase.execute(\"INSERT INTO grades (grade, student_id, subject_id) VALUES (?, ?, ?)\", [grade, student_id, subject_id])\r\nend",
"def add_test_to_account\n \n quiz_user = QuizUser.new\n quiz_user.quiz_id = params[:quiz_id]\n quiz_user.user_id = current_user.id\n quiz_user.save!\n \n redirect_to homes_index_path, notice: \"Test added to your account.\"\n \n end",
"def create\n\t\t@problem = AssignmentProblem.find_by_id(new_test_case_params[:assignment_problem_id])\n\t\t@test_case = TestCase.new(new_test_case_params)\n\t\t@test_case.input = new_test_case_params[:input]\n\t\t@test_case.output = new_test_case_params[:output]\n\t\t@test_case.assignment_problem_id = new_test_case_params[:assignment_problem_id]\n\t\tif lecturer_signed_in?\n\t\t\t@test_case.owner_id = current_lecturer.id\n\t\t\t@test_case.owner_type = \"lecturer\"\n\t\t\t@test_case.assignment_problem_id = session[:assignment_problem_id]\n\t\telsif teaching_assistant_signed_in?\n\t\t\t@test_case.owner_id = current_teaching_assistant.id\n\t\t\t@test_case.owner_type = \"teaching assistant\"\n\t\t\t@test_case.assignment_problem_id = session[:assignment_problem_id]\n\t\tend\n\t\tif @test_case.save\n\t\t\tflash[:notice] = \"Your test case is now added\"\n\t\t\tredirect_to :controller => 'assignment_problems', :action => 'new',\n\t\t\t:id => session[:problem_assignment_id]\n\t\telse\n\t\t\trender :action=>'new', :assignment_id => @test_case.assignment_problem_id\n\t\tend\n\tend",
"def create_dessert(db, dessert_name, dessert_description)\n db.execute(\"INSERT INTO dessert (dessert_name, dessert_description) VALUES (?, ?)\", [dessert_name, dessert_description])\nend",
"def get_exercise_for_test_or_redirect(test_type, host_id)\n host = Host.find_by_id(host_id) rescue nil\n redirect_to_show_host and return if host.nil?\n exercise = Exercise.new(\n :host => host, \n :exercise_type => test_type, \n :aut_version => params[:exercise][:aut_version], \n :aut_note => params[:exercise][:aut_note],\n :num_concurrent_connections => (params[:exercise][:num_concurrent_connections].strip || Exercise::DEFAULT_NUM_CONCURRENT_CONNECTIONS),\n :num_hits_per_page => (params[:exercise][:num_hits_per_page] .strip || Exercise::DEFAULT_NUM_HITS_PER_PAGE)\n )\n unless exercise && exercise.valid? && exercise.save\n flash[:error] = \"unable to create Exercise: #{exercise.errors.full_messages.join(\", \").to_s}\"\n redirect_to_show_host\n return\n end\n exercise\n end",
"def edit\n @exercise = current_user.exercises.find_by_id(params[:id])\n unless @exercise\n flash[:error] = \"You can't edit exercises that don't belong to you\"\n redirect_to :action => 'index'\n end\n @title = 'Edit Exercise'\n end",
"def command_newFood(name, calories)\n bool = @database.add_basicFood(name, calories)\n if bool == false\n puts \"Food already in database\"\n end\n @dbChanged = true\n end",
"def question_add\n\t\t$DATABASE.execute('INSERT INTO jeopardy (cat_id, question, answer,points) VALUES (?,?,?,?)', [category, question, answer, points])\n\tend",
"def test_add_user\r\n user = User.new\r\n user.name = \"testStudent1\"\r\n user.fullname = \"test_Student_1\"\r\n user.clear_password = \"testStudent1\"\r\n user.clear_password_confirmation = \"testStudent1\"\r\n user.email = \"testStudent1@foo.edu\"\r\n user.role_id = \"1\"\r\n user.save! # an exception is thrown if the user is invalid\r\n end"
] | [
"0.74751145",
"0.7390913",
"0.7354178",
"0.7330593",
"0.70201266",
"0.69600165",
"0.69432503",
"0.68735874",
"0.68717223",
"0.6845112",
"0.6839777",
"0.6768515",
"0.6760509",
"0.6731401",
"0.6701907",
"0.66982186",
"0.66973287",
"0.6657908",
"0.6627169",
"0.6590854",
"0.6585129",
"0.6558484",
"0.6529642",
"0.6455462",
"0.6455349",
"0.6453792",
"0.6450037",
"0.6439315",
"0.64331764",
"0.64329916",
"0.63990825",
"0.63921136",
"0.6377688",
"0.63655293",
"0.6358655",
"0.6352417",
"0.6344027",
"0.6337768",
"0.6321951",
"0.6296208",
"0.629354",
"0.6285065",
"0.6276001",
"0.6273746",
"0.6267087",
"0.6266849",
"0.62637246",
"0.6237322",
"0.6237322",
"0.6228921",
"0.6223534",
"0.62216747",
"0.62176543",
"0.6202764",
"0.6202764",
"0.6202764",
"0.6202764",
"0.6202764",
"0.6202764",
"0.6202764",
"0.61735356",
"0.6167313",
"0.6159287",
"0.6156906",
"0.61464745",
"0.61413866",
"0.6131935",
"0.61248064",
"0.6118234",
"0.6113875",
"0.6097017",
"0.6089885",
"0.6081592",
"0.6069152",
"0.6049931",
"0.6049151",
"0.60456014",
"0.60451937",
"0.60430676",
"0.6030371",
"0.60296965",
"0.6000247",
"0.5999494",
"0.5996835",
"0.59805685",
"0.5972978",
"0.5970289",
"0.5957783",
"0.594794",
"0.59437525",
"0.59357333",
"0.59351844",
"0.5932894",
"0.592193",
"0.5920842",
"0.5920519",
"0.5912459",
"0.5909438",
"0.5903954",
"0.5903169"
] | 0.7617992 | 0 |
7. a user can log a new workout | def log_new_workout(exercise, date)
exercise_check = Exercise.search_exercise_by_name(exercise)
exercise_instance = Exercise.all.find{|exercises| exercises.name == exercise}
if exercise_check == "Sorry. We don't have any workouts called #{exercise}. Please return to the main menu to create this new exercise and share with the rest of our FitMePan crew."
return exercise_check
else
Workout.create(user_id: self.id, exercise_id: exercise_instance.id, date: date)
end
puts "Thanks for logging your workout!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkin\n if self.current_user == nil\n redirect_to \"/account/login\"\n end\n @workout = Workout.new\n @workout.workout_date = Time.now.to_date #.strftime(\"%x\")\n end",
"def create\n @workout = Workout.new(workout_params)\n @workout.user = current_user!\n if @workout.save\n redirect_to workout_path(@workout),\n notice: t('.success')\n else\n render :new\n end\n end",
"def new\n @user = current_user\n @workout = Workout.new\n end",
"def check_work_user\n owner = Work.friendly.find(params[:id]).user\n unless owner == current_user || current_user.is_admin?\n store_location\n flash[:error] = 'You are not authorized to perform this action.'\n redirect_to login_path\n end\n end",
"def save\n @workout = Workout.new(params[:workout])\n #@workout.user_profile_id = self.current_user.id\n if @workout.save\n redirect_to \"/myworkouts/#{@workout.id}\"\n else\n render :action => 'checkin' #{@workout.id}\"\n end\n end",
"def create\n @workout = current_user.workouts.build(workout_params)\n if @workout.save\n flash[:notice] = \"Workout was successfully created\"\n redirect_to root_path\n else\n render 'new'\n end\n end",
"def set_workout_logging\n @workout_logging = WorkoutLogging.find(params[:id])\n end",
"def create\n @workout = current_user.workouts.new(workout_params)\n\n if @workout.save\n redirect_to @workout\n else\n render :new\n end\n end",
"def create\n @user_workout = UserWorkout.new(user_workout_params)\n @user_workout.user_id = current_user.id\n\n respond_to do |format|\n if @user_workout.save\n current_user.userworkouts << @user_workout\n format.html { redirect_to @user_workout, notice: 'User workout was successfully created.' }\n format.json { render action: 'show', status: :created, location: @user_workout }\n else\n format.html { render action: 'new' }\n format.json { render json: @user_workout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @workout = current_user.workouts.build\n end",
"def addworkout(journal)\n\tputs \"What is the user_name that you want to add a workout for? (Type 'List' to print users)\"\n\tuser_name = gets.chomp.downcase\n\tif user_name == \"list\"\n\t\tputs \"Users that have a Daily Workout Journal:\"\n\t\tlist_users(journal)\n\t\tputs \"\\n\"\n\t\tputs \"Enter the name of the User you want\"\n\t\tuser_name = gets.chomp\n\tend\n\tuser_number = search_user(journal, user_name.capitalize).to_i\n\tputs \"What is the date of workout?(Format: 'M/D/Y')\"\n\tworkout_date = gets.chomp\n\tputs \"How many hours did you workout?(Format: '3')\"\n\tworkout_hours = gets.to_i\n\tputs \"What muscle_group did you workout? (Arms, Legs, Chest, Back, Cardio, Abs)\"\n\tworkout_muscle = gets.chomp.downcase\n\tuntil workout_muscle == \"arms\" || workout_muscle == \"legs\" || workout_muscle == \"chest\" || workout_muscle == \"back\" || workout_muscle == \"cardio\" || workout_muscle == \"abs\" \n\t\tputs \"Please choose between (Arms, Legs, Chest, Back, Cardio, Abs)\"\n\t\tworkout_muscle = gets.chomp.downcase\n\tend\t\n\tjournal.execute(\"INSERT INTO daily_workouts (date, hours, muscle_group, user_id) VALUES (?, ?, ?, ?)\", [workout_date, workout_hours, workout_muscle, user_number])\nend",
"def set_user_workout\n @user_workout = UserWorkout.find(params[:id])\n end",
"def set_user_workout\n @user_workout = UserWorkout.find(params[:id])\n end",
"def new\n #user wants to log in \n end",
"def new\n #user wants to log in \n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please enter your worker ID to continue.\"\n redirect_to start_url\n end\n end",
"def new\n # If someone is already logged in, skip this step\n login(current_user) and return if logged_in?\n end",
"def set_workout\n @workout = current_user.workouts.find(params[:id])\n end",
"def set_workout\n @workout = current_user.workouts.find(params[:id])\n end",
"def log_workout(db, name, duration, calories, type)\n db.execute(\"INSERT INTO workout_log (name, workout_duration, calories_burned, workout_type) VALUES (?,?,?,?)\",[name, duration, calories, type])\nend",
"def create\n @workout_logging = WorkoutLogging.new(workout_logging_params)\n\n respond_to do |format|\n if @workout_logging.save\n format.html { redirect_to @workout_logging, notice: 'Workout logging was successfully created.' }\n format.json { render :show, status: :created, location: @workout_logging }\n else\n format.html { render :new }\n format.json { render json: @workout_logging.errors, status: :unprocessable_entity }\n end\n end\n end",
"def workout_program(user)\n return workout_summary(user) if user.started?\n start_workout(user)\n end",
"def login_instructions\n end",
"def create\n @workout = Workout.new(workout_params)\n if user_signed_in?\n @workout.owner = current_user\n @workout.users << current_user\n else\n @workout.owner = temp_user\n session[:workout_id] = @workout.id\n end \n @workout.save\n ex_params = exercise_params[:exercise].map do |e|\n e[:dur] = e[:dur][:minutes].to_i*60 + e[:dur][:seconds].to_i\n e[:workout_id] = @workout.id\n e\n end\n @exercises = @workout.exercises.create(ex_params)\n\n respond_to do |format|\n if @workout.save\n format.html { redirect_to @workout, notice: \"Workout was successfully created\" }\n format.json { render json: {workoutId: @workout.id}, status: 200 }\n else\n format.html { render :new }\n format.json { render json: @workout.errors, status: 500 }\n end\n end\n end",
"def log_in\n end",
"def new\n #@workout = Workout.new\n @workout = current_user.workouts.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @workout }\n end\n end",
"def create\n # debugger\n # TODO: Clean up this params mess and make sure workouts#update allows multiple lift edit\n # TODO: Editing workouts should allow you to update workouts\n # TODO: Switch times to local time\n # set_workout_date(params)\n # remove_workout_time(params)\n # set_lift_ids(params)\n\n # user selects lift\n # JavaScript then uses lift name and gets lift ID\n # from JSON\n # send lift ID over to controller\n # http://railscasts.com/episodes/258-token-fields-revised?\n @workout = current_user.workouts.build(params[:workout])\n\n respond_to do |format|\n if @workout.save\n flash[:success] = \"Workout created\"\n format.html { redirect_to workouts_path, notice: \"Workout was successfully created.\" }\n format.json { render json: @workout, status: :created, location: @workout }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @workout_record = WorkoutRecord.new params[:workout_record]\n @workout_record.time = params[:time]\n if @workout_record.save\n current_user.workout_records << @workout_record\n current_user.events << @workout_record.event\n current_user.personal_records << PersonalRecord.get_record_for(current_user.id,@workout_record.workout_id)\n redirect_to :action => 'show', :id => @workout_record.id\n else\n flash[:error] = 'There was a problem saving your workout record'\n flash[:errors] = @workout_record.errors\n redirect_to :action => 'new'\n end\n end",
"def admin_create_work_user_ivars(allow_nil_user=true)\n if @curr_user.admin?\n work_user_id = (params[:work_user] || session[:work_user_id] || 0).to_i\n @work_user = if work_user_id > 0\n User.find(work_user_id)\n elsif allow_nil_user\n nil\n else\n User.find(:first, :order => 'name asc')\n end\n session[:work_user_id] = @work_user ? @work_user.id : nil\n else\n @work_user = session[:work_user_id] = nil\n end\n end",
"def set_work_history\n \n @work_history = WorkHistory.find(params[:id])\n authorize @work_history\n end",
"def create\n @workout = Workout.new(workout_params)\n @workout.user = current_user\n\n respond_to do |format|\n if @workout.save\n format.html { redirect_to @workout, notice: \"Workout was successfully created.\" }\n format.json { render :show, status: :created, location: @workout }\n \n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def logged_in\r\n end",
"def est02_attempt_create_group_logged_out_TC_24400\n\t\t#no login\n\t\t$browser.cookies.clear\n\t\t$browser.goto($patch_groups)\n\t\tsleep 2\n\t\t$group_start_new.click\n\t\tsleep 2\n\t\t\n\t\tbegin\n\t\tassert $browser.text.include?(\"Or sign in with your Patch account\")\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"GSS6_T2: FAILED! User not taken to login page.\"\n\t\tend\n\tend",
"def loggin_opc(puser, pcontroller, paction, pcomment)\n #para que no haga logging de clicks de navegacion\n if pcontroller == 'home'\n\t\treturn\n else\n\t logmodel = Logeclubapi.new\n\t logmodel.login = puser.login\n\t logmodel.username = puser.name\n\t logmodel.log_option = pcontroller\n\t logmodel.log_action = paction[0..9]\n\t logmodel.log_comment = pcomment\n\t logmodel.origin = 'W' #origen web\n\t #logmodel.save\n end\n end",
"def verify_access\n unless current_user.id == @worker.user_id\n flash[:warning] = \"You do not have authority to access that.\"\n redirect_to user_path(current_user.id)\n end\n end",
"def print(journal)\n\tputs \"What is the user_name that you want to add a workout for? (Type 'List' to print users\"\n\tuser_name = gets.chomp.downcase\n\tif user_name == \"list\"\n\t\tputs \"Users that have a Daily Workout Journal:\"\n\t\tlist_users(journal)\n\t\tputs \"\\n\"\n\t\tputs \"Enter the name of the User you want\"\n\t\tuser_name = gets.chomp\n\tend\n\tuser_number = search_user(journal, user_name.capitalize).to_i\n\tworkouts = journal.execute(\"SELECT * FROM daily_workouts WHERE daily_workouts.user_id = #{user_number}\")\n\tjournal_user = journal.execute(\"SELECT users.name FROM users WHERE users.id = #{user_number}\")\n\tputs journal_user[0][\"name\"]+\":\"\n\tworkouts.each do |workouts|\n\t\tputs \"On #{workouts['date']}, you worked on #{workouts['muscle_group']} for #{workouts['hours']} hours\"\n\tend\nend",
"def create\n\n @work = Work.new(work_params)\n @user = User.find(session[:user_id]) \n \n respond_to do |format|\n if @work.save\n @user.works << @work\n format.html { redirect_to @work, notice: 'La actividad se registro con exito.' }\n format.json { render :show, status: :created, location: @work }\n else\n format.html { render :new }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def private_goal(user)\n create_goal(\"Learn to paint\", \"true\")\n create_goal(\"Play the piano\")\n click_link 'Sign Out'\n other_user(user)\n click_link 'Wilbur'\n end",
"def index\n unless current_user and current_user.admin? \n redirect_to \"/\", :alert => \"Access Denied.\"\n end\n @workouts = Workout.all\n end",
"def add_to_log\n user_name = self.user.name || self.user.email.split('@')[0]\n Log.create!(loggingtype: 2,user_id_1: self.user.id ,user_id_2: nil,admin_id: nil,story_id: self.story.id ,interest_id: nil,message: (user_name+\" commented on \\\"\" + self.story.title + \"\\\" with \\\"\" + self.content + \"\\\"\").to_s )\n Admin.push_notifications \"/admins/index\" ,\"\"\n end",
"def show\n redirect_to homeworks_path unless @homework.user_id == current_user.id\n end",
"def create\n @workout = current_user.workouts.new(workout_params)\n\n respond_to do |format|\n if @workout.save\n format.html { redirect_to root_path(date: I18n.l(@workout.date)), notice: t('flash_message.notice.successfully_created', model: Workout.model_name.human) }\n format.json { render action: 'show', status: :created, location: @workout }\n else\n format.html { render action: 'new' }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n if not (@current_user.admin? || @current_user.produce? || @current_user.worker?)\n redirect_to @current_user\n else\n @work = Work.new\n\n @users = User.find(:all)\n @projects = Project.find(:all)\n @job_types = JobType.find(:all)\n @places = Place.find(:all)\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @work }\n end\n end\n end",
"def index\n @workouts = current_user.workouts\n end",
"def logging_in\n end",
"def save_login_state\n if session[:user_id]\n redirect_to requests_path\n return false\n else\n return true\n end\n end",
"def login; end",
"def needs_login?() false end",
"def authenticate_admin_hr_pm\n unless current_user && (get_loging_permission ==1 || get_loging_permission ==2 || get_loging_permission ==3)\n redirect_to sign_in_path\n return \n end\n end",
"def logging_in\n \t\t\n \tend",
"def test_ID_25862_new_post_in_group_you_manage()\n login $user_1_email, $master_password\n read_all_updates\n logout_common\n login $user_1_email, $master_password\n inline_posting_to_any_blog(\"atest\")\n logout_common\n login $user_1_email, $master_password\n verify_updates\n end",
"def login_as_archivist( create_new = false )\n if !$test_repo\n ($test_repo, $test_repo_uri) = create_test_repo(\"repo_#{SecureRandom.hex}\", \"description\")\n end\n\n if !$archivist_user or create_new\n ($archivist_user, $archivist_pass) = create_user\n add_user_to_archivists($archivist_user, $test_repo_uri)\n end\n\n\n login($archivist_user, $archivist_pass)\n\n select_repo($test_repo)\nend",
"def new\n @work_time = WorkTime.new\n\n # checks if no one is logged in or an admin is logged in\n if current_user.nil? || admin_mode?\n # if so, method renders new.html.erb view present in app/views/work_times\n render \"work_times/new\"\n else\n # else, method redirects the employee back to the home page\n redirect_to home_path, notice: \"Can't do that! Log out to make a new work time!\"\n end\n end",
"def set_our_work\n @work = OutWork.find_by(id: params[:id])\n rescue Exception => e\n render_default_error e, 401\n end",
"def create_user_information # for new users. runs last according to rails.\n self.dj_name = name\n self.roles = Role.where(:title => 'noob')\n self.active = true\n set_password\n end",
"def create\n if not (@current_user.worker? || @current_user.admin? || @current_user.produce? )\n redirect_to @current_user\n else\n @work = Work.new(params[:work])\n @users = User.find(:all)\n @projects = Project.find(:all)\n @job_types = JobType.find(:all)\n @places = Place.find(:all)\n respond_to do |format|\n if @work.save\n flash[:notice] = 'Work was successfully created.'\n format.html { redirect_to(@work) }\n format.xml { render :xml => @work, :status => :created, :location => @work }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @work.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def sign_up\n if @worksession.free == false\n respond_to do |format|\n format.html {\n flash[:notice] = 'Worksession is unavailable. Please choose another'\n redirect_to available_path\n }\n end\n else\n if !params[:notes].nil?\n @worksession.notes = params[:notes]\n end\n booking = Booking.create(user_id: @user.id, worksession_id: @worksession.id, notes: params[:notes])\n\n if Rails.env.production?\n url = URI.parse('http://worksessions-notifier.pierobotics.org/api/v0/signup/')\n else\n url = URI.parse('http://worksessions-notifier-staging.pierobotics.org/api/v0/signup/')\n end\n Net::HTTP.post_form(url, {\n 'notes' => booking.notes,\n 'date' => @worksession.date.strftime(\"%m/%d/%Y\"),\n 'start_time' => @worksession.begin_at.strftime(\"%I:%M %P\"),\n 'end_time' => @worksession.end_at.strftime(\"%I:%M %P\"),\n 'school' => @user.team_name,\n })\n\n # @worksession.users << @user\n if (@worksession.date.wday.between?(0, 1) and @worksession.users.size >= 8) or (@worksession.date.wday.between?(5, 6) and @worksession.users.size >= 4)\n @worksession.free = false\n @worksession.save\n end\n redirect_to available_path\n end\n\n end",
"def new_user\n \n end",
"def set_work\n @work = Work.find(params[:id])\n \tauthorize @work\n end",
"def add\n # for volunteer to sign up for a project\n # if volunteer signs up, a message or notification gets sent to the administrator\n end",
"def set_change_log_whodidit\n ::ChangeLog.whodidit = user_for_change_log\n end",
"def another_teacher_to_section \n User.create_new_section(params[:new_teacher_to_add], params[:section], session[:selected_project_id])\n user = User.find(params[:new_teacher_to_add])\n\n redirect_to users_teachers_path, notice: \"#{user.first_name} #{user.last_name} was added to section #{params[:section]}.\"\n end",
"def new\n\n\n ### reset these just in case, but only do it if a new goal has not already been saved\n if !params[:submitted_new_goal]\n session[:goal_added_through_template_from_program_id] = nil\n session[:template_user_parent_goal_id] = nil\n session[:goal_template_text] = nil\n session[:category] = nil\n session[:accepting_invitation_id] = nil\n end\n\n\n\n ### If they are restricted to 1 active goal, redirect away\n restrict = false\n \n if current_user\n logger.info(\"sgj:fumfin:current_user.email = \" + current_user.email)\n #logger.info(\"sgj:fumfin:!current_user.is_habitforge_supporting_member.to_s = \" + !current_user.is_habitforge_supporting_member)\n if session[:site_name]\n logger.info(\"sgj:fumfin:session[:site_name] = \" + session[:site_name].to_s)\n end\n if session[:sponsor]\n logger.info(\"sgj:fumfin:session[:sponsor] = \" + session[:sponsor].to_s)\n end\n logger.info(\"sgj:fumfin:current_user.number_of_active_habits = \" + current_user.number_of_active_habits.to_s)\n end ### end if current_user\n\n\n #### We are now allowing unlimited habits\n # if (session[:site_name] == nil or session[:site_name] == \"\" or session[:sponsor] == \"\") or (session[:site_name] == \"habitforge\" or session[:sponsor] == \"habitforge\") and !current_user.is_habitforge_supporting_member\n # logger.info(\"sgj:fumfin:got in 1\")\n\n # if current_user.number_of_active_habits > 0\n # # restrict = true\n # end\n \n # end\n\n if restrict == true\n redirect_to(\"https://habitforge.com/widget/upgrade\")\n # if params[:goal_template_text]\n # redirect_to(\"/goals?too_many_active_habits=1&goal_template_text=#{params[:goal_template_text]}\")\n # else\n # redirect_to(\"/goals?too_many_active_habits=1\")\n # end\n else\n\n\n @goal = Goal.new\n\n\n @goal.tracker_set_checkpoint_to_yes_if_any_answer = false # the db default is true, but false is better\n @goal.tracker_set_checkpoint_to_yes_only_if_answer_acceptable = false # the db default is true, but false is safer for now\n\n @goal.reminder_time = DateTime.new(2009,1,1,0,0,0)\n\n @goal.category = \"Exercise\" ## a reasonable default\n\n @goal.reminder_send_hour = 7 #### 8am\n #@goal.reminder_send_hour = -1 #### no reminder when set to -1\n\n\n @goal.usersendhour = 20 ### 8pm\n\n @goal.daym = 1\n @goal.dayt = 1\n @goal.dayw = 1\n @goal.dayr = 1\n @goal.dayf = 1\n @goal.days = 1\n @goal.dayn = 1\n\n\n @goal.more_reminders_enabled = false\n @goal.more_reminders_start = 8\n @goal.more_reminders_end = 22\n @goal.more_reminders_every_n_hours = 4\n @goal.more_reminders_last_sent = 0\n\n\n @goal.publish = 1\n if current_user.premium_only_default_private_goal\n @goal.publish = 0\n end\n\n if params[:goal_template_text]\n session[:goal_template_text] = params[:goal_template_text]\n\n ### only restrict features initially\n ### and only redirect to sales page\n ### if they're not currently a premium member\n if !current_user.is_habitforge_supporting_member\n session[:sfm_virgin] = true\n if params[:existing_user]\n session[:existing_user] = true\n end\n end\n\n end\n\n if session[:goal_template_text]\n @goal.title = session[:goal_template_text]\n @goal.response_question = @goal.title\n end\n\n if params[:template_user_parent_goal_id]\n session[:template_user_parent_goal_id] = params[:template_user_parent_goal_id]\n end\n if session[:template_user_parent_goal_id]\n @goal.template_user_parent_goal_id = session[:template_user_parent_goal_id].to_i\n end\n\n if params[:goal_added_through_template_from_program_id]\n session[:goal_added_through_template_from_program_id] = params[:goal_added_through_template_from_program_id].to_i\n end\n if session[:goal_added_through_template_from_program_id]\n @goal.goal_added_through_template_from_program_id = session[:goal_added_through_template_from_program_id].to_i\n end\n\n\n\n if params[:category]\n session[:category] = params[:category]\n end\n if session[:category]\n @goal.category = session[:category]\n end\n\n if current_user.goal_temp != nil and current_user.goal_temp != \"\"\n @goal.response_question = current_user.goal_temp\n end\n\n\n #### if we are basing our goal on a template, then copy those values\n if session[:template_user_parent_goal_id]\n template_user_parent_goal = Goal.find(session[:template_user_parent_goal_id].to_i)\n if template_user_parent_goal\n @goal.template_user_parent_goal_id = template_user_parent_goal.id\n @goal.title = template_user_parent_goal.title\n @goal.response_question = template_user_parent_goal.response_question\n @goal.category = template_user_parent_goal.category\n @goal.reminder_time = template_user_parent_goal.reminder_time\n @goal.daym = template_user_parent_goal.daym\n @goal.dayt = template_user_parent_goal.dayt\n @goal.dayw = template_user_parent_goal.dayw\n @goal.dayr = template_user_parent_goal.dayr\n @goal.dayf = template_user_parent_goal.dayf\n @goal.days = template_user_parent_goal.days\n @goal.dayn = template_user_parent_goal.dayn\n @goal.goal_days_per_week = template_user_parent_goal.goal_days_per_week\n @goal.remind_me = template_user_parent_goal.remind_me\n @goal.reminder_send_hour = template_user_parent_goal.reminder_send_hour\n @goal.check_in_same_day = template_user_parent_goal.check_in_same_day\n @goal.usersendhour = template_user_parent_goal.usersendhour\n\n\n if template_user_parent_goal.tracker != nil\n @goal.tracker = template_user_parent_goal.tracker\n end\n if template_user_parent_goal.tracker_question != nil\n @goal.tracker_question = template_user_parent_goal.tracker_question\n end\n if template_user_parent_goal.tracker_statement != nil\n @goal.tracker_statement = template_user_parent_goal.tracker_statement\n end\n if template_user_parent_goal.tracker_units != nil\n @goal.tracker_units = template_user_parent_goal.tracker_units\n end\n if template_user_parent_goal.tracker_digits_after_decimal != nil\n @goal.tracker_digits_after_decimal = template_user_parent_goal.tracker_digits_after_decimal\n end\n if template_user_parent_goal.tracker_standard_deviation_from_last_measurement != nil\n @goal.tracker_standard_deviation_from_last_measurement = template_user_parent_goal.tracker_standard_deviation_from_last_measurement\n end\n if template_user_parent_goal.tracker_type_starts_at_zero_daily != nil\n @goal.tracker_type_starts_at_zero_daily = template_user_parent_goal.tracker_type_starts_at_zero_daily\n end\n if template_user_parent_goal.tracker_target_higher_value_is_better != nil\n @goal.tracker_target_higher_value_is_better = template_user_parent_goal.tracker_target_higher_value_is_better\n end\n if template_user_parent_goal.tracker_set_checkpoint_to_yes_if_any_answer != nil\n @goal.tracker_set_checkpoint_to_yes_if_any_answer = template_user_parent_goal.tracker_set_checkpoint_to_yes_if_any_answer\n end\n if template_user_parent_goal.tracker_set_checkpoint_to_yes_only_if_answer_acceptable != nil\n @goal.tracker_set_checkpoint_to_yes_only_if_answer_acceptable = template_user_parent_goal.tracker_set_checkpoint_to_yes_only_if_answer_acceptable\n end\n if template_user_parent_goal.tracker_target_threshold_bad1 != nil\n @goal.tracker_target_threshold_bad1 = template_user_parent_goal.tracker_target_threshold_bad1\n end\n if template_user_parent_goal.tracker_target_threshold_bad2 != nil\n @goal.tracker_target_threshold_bad2 = template_user_parent_goal.tracker_target_threshold_bad2\n end\n if template_user_parent_goal.tracker_target_threshold_bad3 != nil\n @goal.tracker_target_threshold_bad3 = template_user_parent_goal.tracker_target_threshold_bad3\n end\n if template_user_parent_goal.tracker_target_threshold_good1 != nil\n @goal.tracker_target_threshold_good1 = template_user_parent_goal.tracker_target_threshold_good1\n end\n if template_user_parent_goal.tracker_target_threshold_good2 != nil\n @goal.tracker_target_threshold_good2 = template_user_parent_goal.tracker_target_threshold_good2\n end\n if template_user_parent_goal.tracker_target_threshold_good3 != nil\n @goal.tracker_target_threshold_good3 = template_user_parent_goal.tracker_target_threshold_good3\n end\n if template_user_parent_goal.tracker_measurement_worst_yet != nil\n @goal.tracker_measurement_worst_yet = template_user_parent_goal.tracker_measurement_worst_yet\n end\n if template_user_parent_goal.tracker_measurement_best_yet != nil\n @goal.tracker_measurement_best_yet = template_user_parent_goal.tracker_measurement_best_yet\n end\n if template_user_parent_goal.tracker_measurement_last_taken_on_date != nil\n @goal.tracker_measurement_last_taken_on_date = template_user_parent_goal.tracker_measurement_last_taken_on_date\n end\n if template_user_parent_goal.tracker_measurement_last_taken_on_hour != nil\n @goal.tracker_measurement_last_taken_on_hour = template_user_parent_goal.tracker_measurement_last_taken_on_hour\n end\n if template_user_parent_goal.tracker_measurement_last_taken_value != nil\n @goal.tracker_measurement_last_taken_value = template_user_parent_goal.tracker_measurement_last_taken_value\n end\n if template_user_parent_goal.tracker_measurement_last_taken_timestamp != nil\n @goal.tracker_measurement_last_taken_timestamp = template_user_parent_goal.tracker_measurement_last_taken_timestamp\n end\n if template_user_parent_goal.tracker_prompt_after_n_days_without_entry != nil\n @goal.tracker_prompt_after_n_days_without_entry = template_user_parent_goal.tracker_prompt_after_n_days_without_entry\n end\n if template_user_parent_goal.tracker_prompt_for_an_initial_value != nil\n @goal.tracker_prompt_for_an_initial_value = template_user_parent_goal.tracker_prompt_for_an_initial_value\n end\n if template_user_parent_goal.tracker_track_difference_between_initial_and_latest != nil\n @goal.tracker_track_difference_between_initial_and_latest = template_user_parent_goal.tracker_track_difference_between_initial_and_latest\n end\n if template_user_parent_goal.tracker_difference_between_initial_and_latest != nil\n @goal.tracker_difference_between_initial_and_latest = template_user_parent_goal.tracker_difference_between_initial_and_latest\n end\n\n\n\n if session[:goal_added_through_template_from_program_id]\n goal_added_through_template_from_program = Program.find(session[:goal_added_through_template_from_program_id].to_i)\n if goal_added_through_template_from_program\n @goal.goal_added_through_template_from_program_id = goal_added_through_template_from_program.id\n end\n end\n\n\n ### do not save here, because if you do, all of the stuff in \"def create\" won't get applied\n #@goal.save\n end\n end\n\n\n\n ####################################################\n ####################################################\n ###### IF WE ARE RESPONDING TO AN INVITATION\n if params[:invitation_id]\n @invite = Invite.find(params[:invitation_id].to_i)\n if @invite\n @invite_from_user = User.find(@invite.from_user_id)\n end\n if @invite and @invite.purpose_join_team_id and @invite_from_user\n @team = Team.find(@invite.purpose_join_team_id)\n\n ### what kind of team?\n if @team.goal_template_parent_id\n ### template based team\n if @goal.template_user_parent_goal_id and (@goal.template_user_parent_goal_id == @team.goal_template_parent_id)\n @invite_team_type_goal = true\n end\n else\n ### category-based team\n if @team.category_name\n @invite_team_type_category = true\n @goal.category = @team.category_name\n end\n end\n end\n end\n ###### END IF WE ARE RESPONDING TO AN INVITATION\n ####################################################\n ####################################################\n\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @goal }\n end\n end\n end",
"def logging_in\n # For example:\n guest_projects = guest_user.projects.all\n guest_projects.each do |project|\n project.user_id = current_user.id\n project.save!\n end\n end",
"def role\n if current_user.has_role?(:guest)\n redirect_to \"/workouts\"\n elsif current_user.has_role?(:instructor)\n redirect_to \"/workouts\"\n end\n end",
"def run\n tml\n welcome_user\n login_or_create_user\n present_menu_options\nend",
"def atest_ID_25862_new_post_in_group_you_manage()\n login_as_user1\n read_all_updates\n groupName = create_any_new_group(\"Open Group\", \"Family\")\n logout_common\n login_as_user2\n post_to_any_group(\"Family\",groupName)\n logout_common\n login_as_user1\n verify_updates\n end",
"def set_workout\n\t\t@workout = Workout.friendly.find(params[:id])\n\tend",
"def user_workout_params\n params.require(:user_workout).permit(:user_id, :workout_id)\n end",
"def index\n set_worksessions\n if params[:user_id].nil?\n @user = nil\n else\n @user = User.find(params[:user_id])\n end\n\n end",
"def user_is_old? user\n return user.logins_number > 1\n end",
"def add_favorite_workout\n Workout.favorite_workouts << @workout if params[:workout_id].present?\n redirect_to root_path\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def create\n @shift = Shift.new(shift_params)\n @shift.shiftweek = current_user.shiftweeks.last\n\n\n respond_to do |format|\n if @shift.save\n current_user.update(on_shift: true)\n format.html { redirect_to '/', notice: 'Shift was successfully created.' }\n format.json { render :show, status: :created, location: @shift }\n else\n format.html { redirect_to '/' }\n format.json { render json: @shift.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mark_misssing_members(login)\n\nend",
"def workout_params\n params.require(:workout).permit(:name, :comments_state, :user_id)\n end",
"def create\n @worksession = parse_worksessions\n respond_to do |format|\n if !@worksession.nil? and @worksession.save\n format.html { redirect_to user_worksessions_path(current_user.id), notice: 'Worksession was successfully created.' }\n format.json { render :show, status: :created, location: @worksession }\n else\n @worksession = Worksession.new\n format.html { render :new }\n format.json { render json: @worksession.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n logger.debug \"**** WORK NEW ****\"\n @work = Work.new\n @work.login_updated_by = @login\n @popup_title = 'Superwork'\n \n #Reset the in memory array of composers - only do this for new when its not redirected after a failed edit\n session[:composers] = []\n @composers = session[:composers]\n \n prepare_new\n end",
"def displayLoginPage()\n\t# User Name: \n\t# Password:\n\t# Forgot Password?\tNew User?\n\treturn\nend",
"def create\n if teacher_signed_in?\n create_for_teacher\n end\n\n respond_to do |format|\n if @practical_work.save\n format.html { redirect_to teacher_practical_works_url, notice: 'Laboratory work was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def log_on_user(user,session,cookies)\n raise NotImplementedError\n end",
"def link_to_new_user(name)\n link_to_function name, js_add_new_user(UsersWorkspace.new)\n end",
"def add_new_user_to_project(name_new_user, user_id, browser)\n\n browser.find_element(id: \"tab-members\").click\n browser.find_element(id: \"principal_search\").send_key(name_new_user)\n sleep 2\n browser.find_element(css: \"#principals>label>input[value='#{user_id}']\").click\n browser.find_element(css: \"#new_membership>fieldset>p>label>input[value='5']\").click\n browser.find_element(css: \"#new_membership>fieldset>p>label>input[value='4']\").click\n browser.find_element(id: \"member-add-submit\").click\n sleep 2\n #Check od add user to the project\n fail 'Did not meet expected result' unless check_add_user(name_new_user, browser)\n puts \"ADd new User = OK\"\n\n end",
"def log(notes)\n @uh_log ||= UserHistory.new\n @uh_log.log(self, notes)\n end",
"def login\n end",
"def login_choice\n end",
"def logged_in_golfer\n unless logged_in?\n store_location\n flash[:danger] = \"You must be logged in to view or modify content. Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_golfer\n unless logged_in?\n store_location\n flash[:danger] = \"You must be logged in to view or modify content. Please log in.\"\n redirect_to login_url\n end\n end",
"def user_workout_params\n params.require(:user_workout).permit(:title, :type, :user_id)\n end",
"def login\n\tend",
"def new\n # Execute if the user hasn't exceeded their ticket allowance\n unless current_user.help_requests.where(open: true).count < 1\n # Redirect to their ticket list\n redirect_to(\"/tickets\")\n # Abort processing this method\n return\n end\n # Get user\n @user = current_user\n # Create a blank ticket associated with the currently logged in user.\n @ticket = current_user.help_requests.build\n end",
"def logged_in_employer\n\t unless logged_employer_in?\n\t flash[:danger] = \"Proszę się zalogować.\"\n\t redirect_to url_for(controller: 'employers', action: 'create')\n\t end\n\tend"
] | [
"0.6320663",
"0.62286055",
"0.62044215",
"0.6171314",
"0.6063468",
"0.60554296",
"0.60316205",
"0.59912103",
"0.59694797",
"0.5917017",
"0.59159213",
"0.59057707",
"0.59057707",
"0.587342",
"0.587342",
"0.5847069",
"0.583834",
"0.5815662",
"0.5815662",
"0.580446",
"0.57572347",
"0.5756006",
"0.57547253",
"0.5730988",
"0.57106376",
"0.5694837",
"0.56835055",
"0.56820446",
"0.5657947",
"0.5599297",
"0.5594718",
"0.55918586",
"0.5571336",
"0.55706805",
"0.5567349",
"0.5544768",
"0.5540353",
"0.55369544",
"0.55340976",
"0.5533798",
"0.5531405",
"0.5526912",
"0.55095273",
"0.5478967",
"0.5478176",
"0.5454612",
"0.5441016",
"0.5420466",
"0.54194146",
"0.5408025",
"0.5391827",
"0.5391259",
"0.53840435",
"0.53754365",
"0.53745663",
"0.5367882",
"0.5367158",
"0.5356646",
"0.5344234",
"0.5344091",
"0.5341292",
"0.53358316",
"0.5318299",
"0.5291871",
"0.5280226",
"0.527571",
"0.5264981",
"0.52542204",
"0.524901",
"0.5245544",
"0.52409273",
"0.52397925",
"0.523751",
"0.523751",
"0.523751",
"0.523751",
"0.523751",
"0.523751",
"0.523751",
"0.523751",
"0.523751",
"0.5231564",
"0.5231009",
"0.52277964",
"0.5225743",
"0.5218188",
"0.52160656",
"0.52125365",
"0.5207382",
"0.5206969",
"0.52030945",
"0.52025706",
"0.5202193",
"0.52006346",
"0.51927507",
"0.51927507",
"0.5192724",
"0.5187162",
"0.517794",
"0.51762074"
] | 0.7286219 | 0 |
GET /internships/1 GET /internships/1.json | def show
@internship = Internship.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @internship }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @intern = Intern.find(params[:id])\n @internships = Internship.where(intern_id: @intern.id)\n respond_to do |format|\n format.html #show.html.erb\n format.json { render json: @intern }\n end\n end",
"def index\n @internships = Internship.all\n @current_user = User.find(current_user.id)\n respond_with(@internships)\n end",
"def show\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n format.html \n format.json { render :json => @internship }\n end\n end",
"def show\n @internships_user = InternshipsUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @internships_user }\n end\n end",
"def internships\n respond_to do |format|\n format.html # internships.html.erb\n format.xml { render :xml => nil }\n end\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 new\n @internship = Internship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @internship }\n end\n end",
"def new\n @internship = Internship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @internship }\n end\n end",
"def show\n @clientship = current_user.clientships.find(params[:id]) \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clientship }\n end\n end",
"def show\n @internship = Internship.find(params[:id])\n @diaries = Diary.where(:internship_id => @internship.id).paginate(:page => params[:page]).order('id DESC')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @internship }\n end\n end",
"def create\n @user = current_user\n @internship = @user.internships.build(params[:internship])\n #@internship = Internship.new(params[:internship])\n\n respond_to do |format|\n if @internship.save\n format.html { redirect_to @internship, notice: 'Internship was successfully created.' }\n format.json { render json: @internship, status: :created, location: @internship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @internship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @internships_user = InternshipsUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @internships_user }\n end\n end",
"def index\n @internship = Internship.new\n @internships = Internship.newer(params).page(params[:page]).per(10)\n \n respond_to do |format|\n format.js\n format.html # index.html.erb\n format.json { render :json => @internships }\n end\n end",
"def new\n if User.find(current_user.id).internship_authorization\n @internship = Internship.new\n respond_with(@internship)\n else\n flash[:notice] = \"You cannot create an internship\"\n redirect_to internships_url\n end\n end",
"def create\n @internship = Internship.new(params[:internship])\n\n respond_to do |format|\n if @internship.save\n format.html { redirect_to @internship, notice: 'Internship was successfully created.' }\n format.json { render json: @internship, status: :created, location: @internship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @internship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to(internships_url) }\n format.json { head :ok }\n end\n end",
"def show\n \t@internship_position = InternshipPosition.find(params[:id])\n\n \trespond_to do |format|\n \t\tformat.html # show.html.erb\n \t\tformat.json { render json: @internship_position }\n \tend\n end",
"def new\n @intern = Intern.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @intern }\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end",
"def index\n @ships = Ship.all\n end",
"def index\n @ships = Ship.all\n end",
"def set_internship\n @internship = Internship.find params[:id]\n authorize @internship\n end",
"def index\n @internships = Internship.all\n\n # Very inefficient when users table has thousands of rows.\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @internships }\n format.json {\n\n if params[:filters] != nil\n @internships = Internship.joins(:locations, :fields, :languages, :academic_focuses).select(\"internships.id\").group(\"internships.id\")\n \n @internships = @internships.where(\"internships.for_credit = ?\", true) if params[:for_credit] == 'true'\n @internships = @internships.where(\"internships.for_credit = ?\", false) if params[:for_credit] == 'false'\n \n @internships = @internships.where(\"internships.is_part_time = ?\", true) if params[:part_time] == 'true'\n @internships = @internships.where(\"internships.is_part_time = ?\", false) if params[:part_time] == 'false'\n\n @internships = @internships.where(\"internships.is_full_time = ?\", true) if params[:full_time] == 'true'\n @internships = @internships.where(\"internships.is_full_time = ?\", false) if params[:full_time] == 'false'\n\n @internships = @internships.where(\"internships.requires_us_citizenship = ?\", true) if params[:us_citizenship] == 'true'\n @internships = @internships.where(\"internships.requires_us_citizenship = ?\", false) if params[:us_citizenship] == 'false'\n\n @internships = @internships.where(\"internships.is_paid = ?\", true) if params[:paid] == 'true'\n @internships = @internships.where(\"internships.is_paid = ?\", false) if params[:paid] == 'false'\n\n @internships = @internships.where(\"languages.id IN (?)\", params[:languages].split(',') << Language.find_by_name('unspecified')) if params[:languages] != 'null'\n @internships = @internships.where(\"fields.id IN (?)\", params[:fields].split(',') << Field.find_by_name('unspecified')) if params[:fields] != 'null'\n @internships = @internships.where(\"fields.industry_id IN (?)\", params[:industries].split(',') << Industry.find_by_name('unspecified')) if params[:industries] != 'null'\n @internships = @internships.where(\"internships.provider_id IN (?)\", params[:providers].split(',') << Provider.find_by_name('unspecified')) if params[:providers] != 'null'\n @internships = @internships.where(\"locations.id IN (?)\", params[:locations].split(',')) if params[:locations] != 'null'\n @internships = @internships.where(\"academic_focuses.id IN (?)\", params[:academic_focuses].split(',') << AcademicFocus.find_by_name('unspecified')) if params[:academic_focuses] != 'null'\n end\n \n #Format Response\n internships = Hash.new\n @internships.each do |internship|\n internship = Internship.find(internship.id)\n internship.locations.each do |location|\n internships[location.country.un_code] = Array.new if internships[location.country.un_code] == nil\n internships[location.country.un_code] << {\n 'id' => internship.id,\n 'name' => internship.name,\n 'provider_name' => internship.provider.name,\n 'city' => location.city, \n 'state' => location.state.name, \n 'country' => location.country.name, \n }\n end \n end\n \n #send response\n render :json => internships\n \n }\n end\n end",
"def index\n @friendships = @user.friendships\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end",
"def index\n @kinships = Kinship.all\n end",
"def show\n puts @fleet.id\n @ship_hash = @fleet.get_ships\n end",
"def index\n @communities = Community.all\n render json: {items: @communities}\n end",
"def show\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @internship }\n format.json {\n internship = {\n 'id' => @internship.id, \n 'name' => @internship.name, \n 'is_paid' => @internship.is_paid,\n 'is_full_time' => @internship.is_full_time, \n 'is_part_time' => @internship.is_part_time, \n 'stipend' => @internship.stipend,\n 'description' => @internship.description,\n 'qualifications' => @internship.qualifications,\n 'qualifications_academic' => @internship.qualifications_academic,\n 'for_credit' => @internship.for_credit,\n 'requires_us_citizenship' => @internship.requires_us_citizenship,\n 'application_process' => @internship.application_process,\n 'deadline' => @internship.deadline,\n 'academic_contact_name' => false,\n 'provider_contact_name' => false,\n 'provider_name' => @internship.provider.name,\n 'locations' => Array.new,\n 'academic_focuses' => Array.new,\n 'fields' => Array.new,\n 'languages' => Array.new,\n 'financial_assistance_options' => Array.new,\n 'semesters' => Array.new\n }\n #These 2 fields are one or the other, so they are set here on thier own so we avoid calling 'name' on an nil object\n internship['academic_contact_name'] = @internship.academic_contact.name if @internship.academic_contact != nil\n internship['provider_contact_name'] = @internship.provider_contact.name if @internship.provider_contact != nil\n \n @internship.locations.each do |location|\n internship['locations'] << {\n 'city' => location.city, \n 'state' => location.state.name, \n 'country' => location.country.name\n }\n end\n @internship.academic_focuses.each do |academic_focus|\n internship['academic_focuses'] << {\n 'name' => academic_focus.name, \n 'type' => academic_focus.academic_focus_type.name\n }\n end\n @internship.fields.each do |field|\n internship['fields'] << {\n 'name' => field.name,\n 'industry' => field.industry.name\n }\n end\n @internship.languages.each do |language|\n internship['languages'] << {\n 'name' => language.name\n }\n end\n @internship.financial_assistance_options.each do |financial_assistance_option|\n internship['financial_assistance_options'] << {\n 'name' => financial_assistance_option.name,\n 'type' => financial_assistance_option.financial_assistance_option_type.name,\n 'how_much' => financial_assistance_option.how_much,\n 'qualifications' => financial_assistance_option.qualifications,\n 'source' => financial_assistance_option.source,\n 'website' => financial_assistance_option.website \n }\n end\n @internship.semesters.each do |semester|\n internship['semesters'] << {\n 'name' => semester.name\n }\n end\n\n render :json => internship \n }\n end\n end",
"def update\n @internship = Internship.find(params[:id])\n\n if @internship.update_attributes(params[:internship])\n flash[:notice] = 'Internship was successfully updated.'\n end\n respond_with(@internship)\n end",
"def index\n @internship_committees = InternshipCommittee.all\n end",
"def index\n @championships = Championship.all\n\n render json: @championships\n end",
"def show\n @spaceship = Spaceship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @spaceship }\n end\n end",
"def show\n render json: UserBoards.find(params[\"id\"])\n end",
"def create\n @user = User.find(current_user.id)\n if @user.internship_authorization\n @internship = Internship.new(params[:internship])\n @internship.user_id = current_user.id if current_user\n @user.internship_authorization = false\n @user.save\n flash[:notice] = \"Internship was successfully created\" if @internship.save\n respond_with(@internship)\n else\n flash[:notice] = \"You cannot create an internship\"\n redirect_to internships_url\n end\n end",
"def show\n @monitorship = Monitorship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monitorship }\n end\n end",
"def index\n @player_ships = PlayerShip.all\n end",
"def index\n @discipleships = Discipleship.all\n end",
"def update\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n if @internship.update_attributes(params[:internship])\n format.html { redirect_to @internship, notice: 'Internship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @internship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n if @internship.update_attributes(params[:internship])\n format.html { redirect_to @internship, notice: 'Internship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @internship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @neighborhood = Neighborhood.find(params[:id])\n\n render json: @neighborhood\n end",
"def show\n @ship = Ship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ship }\n end\n end",
"def index\n @ships = Ship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ships }\n end\n end",
"def create\n @internship = Internship.new(params[:internship])\n \n respond_to do |format|\n if @internship.save\n format.html { redirect_to(@internship, :notice => 'Internship was successfully created.') }\n format.xml { render :xml => @internship, :status => :created, :location => @internship }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @internship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @fellowships = Fellowship.all\n end",
"def index\n @identities = Identity.all\n\n render json: @identities\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to(internships_url) }\n format.xml { head :ok }\n end\n end",
"def index\n @communities = Community.all\n respond_with @communities\n end",
"def show\n render json: Server.where(name: params[:name]).first\n end",
"def show\n @warrior = Warrior.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @warrior }\n end\n end",
"def show\n @warrior = Warrior.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @warrior }\n end\n end",
"def show\n @county = Entity.where(id: params[:id]).where(entity_type: 'County').first\n respond_with(@county) do |format|\n format.geojson { render text: @county.to_geojson }\n end\n end",
"def show\n @friendship = @user.friendships.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendship }\n end\n end",
"def index\n @manifestships = Manifestship.all\n end",
"def new\n @internship = Internship.new\n \n @internship.user = @current_user if @internship.user == nil\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @internship }\n end\n end",
"def new\n @clientship = Clientship.new\n @users = User.all\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clientship }\n end\n end",
"def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end",
"def show\n @internship = Internship.find(params[:id])\n @comment = UserComment.new\n @answer = Answer.new\n \n respond_with(@internship)\n end",
"def show\n @island = Island.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @island }\n end\n end",
"def index\n @friendships = Friendship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end",
"def index\n @friendships = Friendship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end",
"def index\n @followships = Follower.all\n render json: @followships\n end",
"def show\n render json: @championship\n end",
"def show\n #@my_ministry = MyMinistry.find(params[:id])\n @coworker = Coworker.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @my_ministry }\n end\n end",
"def show\n @instrulife_list = InstrulifeList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instrulife_list }\n end\n end",
"def show\n @incident = Incident.find(params[:id])\n\n render json: @incident\n end",
"def show\n @county = County.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @county }\n end\n end",
"def index\n @interno_unidads = InternoUnidad.all\n render json: @interno_unidads\n end",
"def index\n\n respond_to do |format|\n format.html { @boards = Board.where network_id: current_user.network_id }\n format.json { @boards = Board.where network_id: current_user.network_id }\n \n end\n end",
"def show\n @community = @district.communities.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @community }\n end\n end",
"def index\n @networkings = Networking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @networkings }\n end\n end",
"def index\n @communities = Community.all\n end",
"def index\n @communities = Community.all\n end",
"def index\n @fleet_ships = FleetShip.all\n end",
"def index\n @authorships = Authorship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @authorships }\n end\n end",
"def show\n @neighborhood = Neighborhood.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def show\n @championship = Championship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @championship }\n end\n end",
"def show\n @name_server = NameServer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @name_server }\n end\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 p1ships\n @p1ships\n end",
"def index\n render json: UserBoards.all\n end",
"def index\n @clients = current_user.clients\n render json: @clients\n end",
"def index\n @neighborhoods = Neighborhood.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @neighborhoods }\n end\n end",
"def index\n @job_ships = JobShip.all\n @user = current_user\n end",
"def destroy\n @intern = Intern.find(params[:id])\n @intern.destroy\n\n respond_to do |format|\n format.html { redirect_to interns_url }\n format.json { head :no_content }\n end\n end",
"def show\n @networking = Networking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @networking }\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 show\n @neighborhood = Neighborhood.find(params[:id])\n @units = @neighborhood.units\n @jobs = @neighborhood.jobs\n @operations_centers = @neighborhood.operations_centers\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def show\n @ship_class = ShipClass.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ship_class }\n end\n end",
"def index\n if params['user_id']\n @user = User.find(params['user_id'])\n @spaces = @user.spaces.visible_by(current_user)\n else\n @spaces = Space.visible_by(current_user).first(10)\n end\n #render json: @spaces.as_json(only: [:id, :name, :description, :updated_at, :user_id])\n render json: SpacesRepresenter.new(@spaces).to_json\n end",
"def update\n @internship = Internship.find(params[:id])\n respond_to do |format|\n if @internship.update_attributes(params[:internship])\n format.html { redirect_to(@internship, :notice => 'Internship was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @internship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @ship = Ship.find(params[:id])\n @weapon = WeaponCard.find_by_ship_id(params[:id])\n @weapon_card = WeaponCard.new\n weapon_names = Weapon.all\n @weapon_names = {}\n weapon_names.each do |name|\n @weapon_names[name.name] = name.id\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ship }\n format.js\n end\n end",
"def show\n @student_cell_leader = StudentCellLeader.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_cell_leader }\n end\n end",
"def show\n @conn = current_user.conns.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conn }\n end\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 @community = Community.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @community }\n end\n end",
"def index\n @laboratories = Laboratory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @laboratories }\n end\n end",
"def index\n @cartships = Cartship.all\n end",
"def index\n @occupants = Occupant.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @occupants }\n end\n end"
] | [
"0.7740879",
"0.69764984",
"0.6767799",
"0.67013353",
"0.63916594",
"0.6220732",
"0.61513543",
"0.61513543",
"0.60837674",
"0.6080233",
"0.59437764",
"0.592135",
"0.59164244",
"0.5878888",
"0.56879574",
"0.5631579",
"0.55941236",
"0.5592559",
"0.55666196",
"0.55666196",
"0.55666196",
"0.55507076",
"0.55507076",
"0.5461281",
"0.5415455",
"0.54043466",
"0.54034853",
"0.53759784",
"0.5359848",
"0.5352241",
"0.5331699",
"0.5327291",
"0.5325781",
"0.531295",
"0.5312108",
"0.530415",
"0.53000313",
"0.5298561",
"0.52930987",
"0.5282382",
"0.5282382",
"0.5261675",
"0.5261005",
"0.5258921",
"0.5230836",
"0.5183865",
"0.51725286",
"0.5170938",
"0.5163625",
"0.516095",
"0.5158983",
"0.5158983",
"0.51572365",
"0.51510584",
"0.51486033",
"0.5144876",
"0.5111637",
"0.5104994",
"0.5101849",
"0.50969976",
"0.5095686",
"0.5095686",
"0.5087605",
"0.5083698",
"0.5071077",
"0.5058358",
"0.50576615",
"0.504541",
"0.5043816",
"0.5040074",
"0.50388384",
"0.5038502",
"0.50359625",
"0.50359625",
"0.5035892",
"0.5032876",
"0.50268704",
"0.50168246",
"0.50096893",
"0.50066787",
"0.5002915",
"0.4981106",
"0.49806333",
"0.49785078",
"0.4978231",
"0.49747276",
"0.4965943",
"0.4965816",
"0.49629527",
"0.4961958",
"0.49567842",
"0.49501655",
"0.49499294",
"0.49498206",
"0.49445254",
"0.49388516",
"0.49382952",
"0.4937888",
"0.49313706",
"0.49250686"
] | 0.70109886 | 1 |
GET /internships/new GET /internships/new.json | def new
@internship = Internship.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @internship }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n if User.find(current_user.id).internship_authorization\n @internship = Internship.new\n respond_with(@internship)\n else\n flash[:notice] = \"You cannot create an internship\"\n redirect_to internships_url\n end\n end",
"def new\n @internships_user = InternshipsUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @internships_user }\n end\n end",
"def new\n @intern = Intern.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @intern }\n end\n end",
"def create\n @user = current_user\n @internship = @user.internships.build(params[:internship])\n #@internship = Internship.new(params[:internship])\n\n respond_to do |format|\n if @internship.save\n format.html { redirect_to @internship, notice: 'Internship was successfully created.' }\n format.json { render json: @internship, status: :created, location: @internship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @internship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @internship = Internship.new(params[:internship])\n\n respond_to do |format|\n if @internship.save\n format.html { redirect_to @internship, notice: 'Internship was successfully created.' }\n format.json { render json: @internship, status: :created, location: @internship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @internship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n \n @ship = Ship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ship }\n end\n end",
"def new\n \t@internship_position = InternshipPosition.new\n\n \trespond_to do |format|\n \t\tformat.html #new.html.erb\n \t\tformat.json { render json: @internship_position }\n \tend\n end",
"def create\n @internship = Internship.new(params[:internship])\n \n respond_to do |format|\n if @internship.save\n format.html { redirect_to(@internship, :notice => 'Internship was successfully created.') }\n format.xml { render :xml => @internship, :status => :created, :location => @internship }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @internship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @ship = Ship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ship }\n end\n end",
"def new\n @spaceship = Spaceship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spaceship }\n end\n end",
"def new\n @internship = Internship.new\n \n @internship.user = @current_user if @internship.user == nil\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @internship }\n end\n end",
"def new\n @battle = Battle.new\n @ships = Ship.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @battle }\n end\n end",
"def new\n @clientship = Clientship.new\n @users = User.all\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clientship }\n end\n end",
"def create\n @internships_user = InternshipsUser.new(params[:internships_user])\n\n respond_to do |format|\n if @internships_user.save\n format.html { redirect_to @internships_user, :notice => 'Internships user was successfully created.' }\n format.json { render :json => @internships_user, :status => :created, :location => @internships_user }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @internships_user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find(current_user.id)\n if @user.internship_authorization\n @internship = Internship.new(params[:internship])\n @internship.user_id = current_user.id if current_user\n @user.internship_authorization = false\n @user.save\n flash[:notice] = \"Internship was successfully created\" if @internship.save\n respond_with(@internship)\n else\n flash[:notice] = \"You cannot create an internship\"\n redirect_to internships_url\n end\n end",
"def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def new\n @ship_class = ShipClass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ship_class }\n end\n end",
"def new\n @island = Island.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @island }\n end\n end",
"def new\n @assigned = Assigned.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assigned }\n end\n end",
"def new\n @gossip = Gossip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gossip }\n end\n end",
"def new\n @monitorship = Monitorship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monitorship }\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 @intern = Intern.new\n @intern.assets.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @intern }\n end\n end",
"def new\n @county = County.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @county }\n end\n end",
"def new\n @citizenship_class = @grantee.citizenship_classes.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @citizenship_class }\n end\n end",
"def new\n @membership = Membership.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @membership }\n end\n end",
"def new\n @ministries = Ministries.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ministries }\n end\n end",
"def new\n @board_info = BoardInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @board_info }\n end\n end",
"def show\n @intern = Intern.find(params[:id])\n @internships = Internship.where(intern_id: @intern.id)\n respond_to do |format|\n format.html #show.html.erb\n format.json { render json: @intern }\n end\n end",
"def new\n return\n @board = Board.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @board }\n end\n end",
"def new\n @committees_voivodeship = CommitteesVoivodeship.new\n\t@committees = Committee.all.map do |commi|\n\t\t[commi.id]\n\tend\n\t@voivodeships = Voivodeship.all.map do |voi|\n\t\t[voi.id]\n\tend\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @committees_voivodeship }\n end\n end",
"def new\n @membership = Membership.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @membership }\n end\n end",
"def new\n @project = Project.new(user_id: current_user.id)\n find_people_list\n fetch_clients\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 @ident = Ident.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ident }\n end\n end",
"def new\n @inning = Inning.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inning }\n end\n end",
"def new\n @community = Community.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @community }\n end\n end",
"def new\n @battle = Battle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @battle }\n end\n end",
"def new\n @community = @district.communities.new\n\n respond_to do |format|\n format.html\n format.json { render json: @community }\n end\n end",
"def index\n @internship = Internship.new\n @internships = Internship.newer(params).page(params[:page]).per(10)\n \n respond_to do |format|\n format.js\n format.html # index.html.erb\n format.json { render :json => @internships }\n end\n end",
"def new\n @board = Board.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @board }\n end\n end",
"def new\n @board = Board.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @board }\n end\n end",
"def new\n @board = Board.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @board }\n end\n end",
"def new\n @friendship = Friendship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @friendship }\n end\n end",
"def new\n @friendship = Friendship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @friendship }\n end\n end",
"def new\n @origin = OriginAddr.new\n \n drop_breadcrumb('新增')\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @origin }\n end\n end",
"def new\n @board = Board.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @board }\n end\n end",
"def new\n @shiftmap = Shiftmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shiftmap }\n end\n end",
"def new\n @comp = Comp.new\n\t@games = Game.find_all_by_comp_id(nil)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comp }\n end\n end",
"def new_link\n @project = Project.new(user_id: current_user.id)\n fetch_projects\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 @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 @network = Network.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @network }\n end\n end",
"def new\n @ship_methods = ShipMethods.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ship_methods }\n end\n end",
"def new\n @board = Board.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @board }\n end\n end",
"def new\n @board = Board.new_with_initial_items\n @template = Template.find(1)\n session[:board] = @board\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @board }\n end\n end",
"def new\n @new_comm = NewComm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_comm }\n end\n end",
"def new\n @identifier = Identifier.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @identifier }\n end\n end",
"def new\n @space = Space.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @space }\n end\n end",
"def new\n @sproject = current_user.sprojects.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sproject }\n end\n end",
"def create\n @intern = Intern.new(params[:intern])\n @intern[:is_archived]=nil;\n\n respond_to do |format|\n if @intern.save\n UserMailer.new_intern_app_notify(@intern.id).deliver\n format.html { redirect_to \"/intern_thank_you\", notice: 'Intern was successfully created.' }\n #format.json { render json: @intern, status: :created, location: @intern }\n else\n format.html { render action: \"new\" }\n format.json { render json: @intern.errors, status: :unprocessable_entity }\n end\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 @mini_map_road = MiniMapRoad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mini_map_road }\n end\n end",
"def new\n @ip = @customer.ips.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ip }\n end\n end",
"def new\n @conn = current_user.conns.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @conn }\n end\n end",
"def new\n @assigned_project = AssignedProject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assigned_project }\n end\n end",
"def new\n @mentorship = Mentorship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mentorship }\n end\n end",
"def new\n @initiative = Initiative.new\n @user = User.find_by_id(current_user2)\n @city = City.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @initiative }\n end\n end",
"def new\n @primary = current_user\n @friendship = Friendship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @friendship }\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 @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 @before_intership = BeforeIntership.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @before_intership }\n end\n end",
"def new\n @presence = Presence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @presence }\n end\n end",
"def new\n @organism = Organism.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organism }\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 @balance = scope.new\n @routes = current_user.locations.collect(&:routes).flatten\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @balance }\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 @idiom = Idiom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @idiom }\n end\n end",
"def new\n @loc = current_user.locs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loc }\n end\n end",
"def new\n @shipdesign = Shipdesign.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shipdesign }\n end\n end",
"def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @membership }\n end\n end",
"def new\n @server = Server.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server }\n end\n end",
"def new\n @server = Server.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server }\n end\n end",
"def new\n @leader = Leader.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @leader }\n end\n end",
"def new\n @serverroom = Serverroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serverroom }\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 @nightclub = Nightclub.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nightclub }\n end\n end",
"def new\n @ci = Ci.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ci }\n end\n end",
"def new\n @shift = Shift.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shift }\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 @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 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 @proyect = Proyect.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @proyect }\n end\n end",
"def new\n @ip = Ip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ip }\n end\n end",
"def new\n @climate = Climate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @climate }\n end\n end",
"def new\n @tile = Tile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tile }\n end\n end",
"def new\n @userclubs = Club.where('userlist like ?', (\"% \" + current_user.id.to_s + \"\\n%\"))\n @pin = current_user.pins.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pin }\n end\n end",
"def new\n @server_info = ServerInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server_info }\n end\n end",
"def new\n @straddle = Straddle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @straddle }\n end\n end",
"def new\r\n @org = Org.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @org }\r\n end\r\n end"
] | [
"0.73454684",
"0.7180421",
"0.70278883",
"0.69433635",
"0.68479043",
"0.64587957",
"0.64562577",
"0.64349633",
"0.6387319",
"0.6384726",
"0.6348978",
"0.62818676",
"0.6273575",
"0.6244404",
"0.61915636",
"0.61668205",
"0.61668205",
"0.6164066",
"0.6134938",
"0.60961914",
"0.6072412",
"0.6057476",
"0.6011799",
"0.6005973",
"0.59709567",
"0.59622574",
"0.59562534",
"0.5931233",
"0.5925791",
"0.59144616",
"0.5909735",
"0.5900627",
"0.58956313",
"0.5895104",
"0.58877975",
"0.58681685",
"0.5857617",
"0.5845259",
"0.5841674",
"0.5841645",
"0.58410543",
"0.58410543",
"0.58410543",
"0.5837709",
"0.5837709",
"0.58308953",
"0.58225375",
"0.58188003",
"0.5800947",
"0.58002555",
"0.5799375",
"0.57959825",
"0.57953244",
"0.5790238",
"0.57877004",
"0.57865286",
"0.57856673",
"0.57842296",
"0.57833886",
"0.5780596",
"0.5778422",
"0.57784045",
"0.5778108",
"0.5777533",
"0.57759595",
"0.5766841",
"0.5759432",
"0.5744069",
"0.5743891",
"0.5742402",
"0.5741414",
"0.57383984",
"0.5731694",
"0.57305163",
"0.5726941",
"0.5724028",
"0.5720603",
"0.571941",
"0.5717089",
"0.5715928",
"0.57075834",
"0.57075834",
"0.57075775",
"0.5704444",
"0.5695559",
"0.5692122",
"0.5684912",
"0.5681777",
"0.56803155",
"0.56801784",
"0.5675915",
"0.56742185",
"0.56613076",
"0.56590635",
"0.5657891",
"0.56577444",
"0.5653378",
"0.5653303",
"0.5648514"
] | 0.7488251 | 1 |
POST /internships POST /internships.json | def create
@internship = Internship.new(params[:internship])
respond_to do |format|
if @internship.save
format.html { redirect_to @internship, notice: 'Internship was successfully created.' }
format.json { render json: @internship, status: :created, location: @internship }
else
format.html { render action: "new" }
format.json { render json: @internship.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @user = current_user\n @internship = @user.internships.build(params[:internship])\n #@internship = Internship.new(params[:internship])\n\n respond_to do |format|\n if @internship.save\n format.html { redirect_to @internship, notice: 'Internship was successfully created.' }\n format.json { render json: @internship, status: :created, location: @internship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @internship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find(current_user.id)\n if @user.internship_authorization\n @internship = Internship.new(params[:internship])\n @internship.user_id = current_user.id if current_user\n @user.internship_authorization = false\n @user.save\n flash[:notice] = \"Internship was successfully created\" if @internship.save\n respond_with(@internship)\n else\n flash[:notice] = \"You cannot create an internship\"\n redirect_to internships_url\n end\n end",
"def create\n @internship = Internship.new(params[:internship])\n \n respond_to do |format|\n if @internship.save\n format.html { redirect_to(@internship, :notice => 'Internship was successfully created.') }\n format.xml { render :xml => @internship, :status => :created, :location => @internship }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @internship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @internships_user = InternshipsUser.new(params[:internships_user])\n\n respond_to do |format|\n if @internships_user.save\n format.html { redirect_to @internships_user, :notice => 'Internships user was successfully created.' }\n format.json { render :json => @internships_user, :status => :created, :location => @internships_user }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @internships_user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n if User.find(current_user.id).internship_authorization\n @internship = Internship.new\n respond_with(@internship)\n else\n flash[:notice] = \"You cannot create an internship\"\n redirect_to internships_url\n end\n end",
"def index\n @internships = Internship.all\n @current_user = User.find(current_user.id)\n respond_with(@internships)\n end",
"def new\n @internship = Internship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @internship }\n end\n end",
"def new\n @internship = Internship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @internship }\n end\n end",
"def create\n @internship = Internship.new(params[:internship])\n @internship.description.strip!\n @internship.owner_hash = cookies[:hash] \n \n fields = params[:fields].split(\",\")\n fields.each do |desc|\n @internship.fields << Field.new(:description => desc.strip)\n end\n\n respond_to do |format|\n if @internship.save\n #format.html { redirect_to @internship }\n format.js\n #format.json { render :json => @internship, :status => :created, :location => @internship }\n else\n format.js {render :action => :create_error }\n #format.html { render :json => @internship.errors, :status => :unprocessable_entity }\n end\n end \n end",
"def internships\n respond_to do |format|\n format.html # internships.html.erb\n format.xml { render :xml => nil }\n end\n end",
"def set_internship\n @internship = Internship.find params[:id]\n authorize @internship\n end",
"def show\n @intern = Intern.find(params[:id])\n @internships = Internship.where(intern_id: @intern.id)\n respond_to do |format|\n format.html #show.html.erb\n format.json { render json: @intern }\n end\n end",
"def new\n @internships_user = InternshipsUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @internships_user }\n end\n end",
"def create\n @intern = Intern.new(params[:intern])\n @intern[:is_archived]=nil;\n\n respond_to do |format|\n if @intern.save\n UserMailer.new_intern_app_notify(@intern.id).deliver\n format.html { redirect_to \"/intern_thank_you\", notice: 'Intern was successfully created.' }\n #format.json { render json: @intern, status: :created, location: @intern }\n else\n format.html { render action: \"new\" }\n format.json { render json: @intern.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.find(params[:game_id])\n @game.authorships.create_from_names(params[:authorship])\n respond_to do |format|\n flash[:notice] = 'Les autheurs sont enregistres'\n format.html { redirect_to game_path(@game) }\n format.xml { head :created, :location => authorship_url(@authorship) }\n end\n end",
"def create\n @intern = Intern.new(intern_params)\n\n\n if @intern.save\n redirect_to @intern, notice: 'Post was successfully created.'\n else\n render action: \"new\"\n end\n\n end",
"def create\n @internship_committee = InternshipCommittee.new(internship_committee_params)\n\n respond_to do |format|\n if @internship_committee.save\n format.html { redirect_to @internship_committee, notice: 'Internship committee was successfully created.' }\n format.json { render :show, status: :created, location: @internship_committee }\n else\n format.html { render :new }\n format.json { render json: @internship_committee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @internship = Internship.new\n @internships = Internship.newer(params).page(params[:page]).per(10)\n \n respond_to do |format|\n format.js\n format.html # index.html.erb\n format.json { render :json => @internships }\n end\n end",
"def createShips\n for ship in Ship.find(:all, :order => \"id\")\n self.my_ships.build(ship_id: ship.id)\n self.enemy_ships.build(ship_id: ship.id)\n end\n self.save\n end",
"def friendships_create(options = {})\n @req.post(\"/1.1/friendships/create.json\", options)\n end",
"def update\n @internship = Internship.find(params[:id])\n\n if @internship.update_attributes(params[:internship])\n flash[:notice] = 'Internship was successfully updated.'\n end\n respond_with(@internship)\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to(internships_url) }\n format.json { head :ok }\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end",
"def create\n @game = Game.new(params[:game])\n respond_to do |format|\n if @game.save\n @game.tag_with params[:tag][:tag_list] if params[:tag] && params[:tag][:tag_list] != \"\"\n flash[:notice] = 'Game was successfully created.'\n @game.authorships.create_from_names(params[:authorship])\n format.html { redirect_to game_path(@game) }\n format.xml { head :created, :location => game_path(@game) }\n else\n format.html do\n @base_games = Game.base_games.find(:all)\n @authorships = []\n 3.times{@authorships << Authorship.new}\n render :action => \"new\"\n end\n format.xml { render :xml => @game.errors.to_xml }\n end\n end\n end",
"def new\n @intern = Intern.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @intern }\n end\n end",
"def create\n @fellowship = Fellowship.new(fellowship_params)\n @fellowship.users << current_user\n\n # Capitalize fellowship name\n @fellowship.fellowship_name = @fellowship.fellowship_name.titleize\n\n respond_to do |format|\n if @fellowship.save\n format.html { redirect_to @fellowship, notice: 'Fellowship was successfully created.' }\n format.json { render :show, status: :created, location: @fellowship }\n else\n format.html { render :new }\n format.json { render json: @fellowship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n if @internship.update_attributes(params[:internship])\n format.html { redirect_to @internship, notice: 'Internship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @internship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n if @internship.update_attributes(params[:internship])\n format.html { redirect_to @internship, notice: 'Internship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @internship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ship = Ship.new(params[:ship])\n respond_to do |format|\n if @ship.save\n format.html { redirect_to @ship, notice: 'Ship was successfully created.' }\n format.json { render json: @ship, status: :created, location: @ship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \t@internship_position = InternshipPosition.new(internship_position_params)\n\n \trespond_to do |format|\n \t\tif @internship_position.save\n \t\t\tformat.html { redirect_to @internship_position, notice: 'Position was successfully created'}\n \t\t\tformat.json { render json: @internship_position, status: :created, location: @internship_position }\n \t\telse\n \t\t\tformat.html { render action: \"new\" }\n \t\t\tformat.json { render json: @internship_position.errors, status: :unprocessable_entity }\n \t\tend\n \tend\n end",
"def create\n @monitorship = Monitorship.new(params[:monitorship])\n\n respond_to do |format|\n if @monitorship.save\n format.html { redirect_to @monitorship, notice: 'Monitorship was successfully created.' }\n format.json { render json: @monitorship, status: :created, location: @monitorship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @monitorship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @internship }\n end\n end",
"def new\n @internship = Internship.new\n \n @internship.user = @current_user if @internship.user == nil\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @internship }\n end\n end",
"def index\n @internships = Internship.all\n\n # Very inefficient when users table has thousands of rows.\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @internships }\n format.json {\n\n if params[:filters] != nil\n @internships = Internship.joins(:locations, :fields, :languages, :academic_focuses).select(\"internships.id\").group(\"internships.id\")\n \n @internships = @internships.where(\"internships.for_credit = ?\", true) if params[:for_credit] == 'true'\n @internships = @internships.where(\"internships.for_credit = ?\", false) if params[:for_credit] == 'false'\n \n @internships = @internships.where(\"internships.is_part_time = ?\", true) if params[:part_time] == 'true'\n @internships = @internships.where(\"internships.is_part_time = ?\", false) if params[:part_time] == 'false'\n\n @internships = @internships.where(\"internships.is_full_time = ?\", true) if params[:full_time] == 'true'\n @internships = @internships.where(\"internships.is_full_time = ?\", false) if params[:full_time] == 'false'\n\n @internships = @internships.where(\"internships.requires_us_citizenship = ?\", true) if params[:us_citizenship] == 'true'\n @internships = @internships.where(\"internships.requires_us_citizenship = ?\", false) if params[:us_citizenship] == 'false'\n\n @internships = @internships.where(\"internships.is_paid = ?\", true) if params[:paid] == 'true'\n @internships = @internships.where(\"internships.is_paid = ?\", false) if params[:paid] == 'false'\n\n @internships = @internships.where(\"languages.id IN (?)\", params[:languages].split(',') << Language.find_by_name('unspecified')) if params[:languages] != 'null'\n @internships = @internships.where(\"fields.id IN (?)\", params[:fields].split(',') << Field.find_by_name('unspecified')) if params[:fields] != 'null'\n @internships = @internships.where(\"fields.industry_id IN (?)\", params[:industries].split(',') << Industry.find_by_name('unspecified')) if params[:industries] != 'null'\n @internships = @internships.where(\"internships.provider_id IN (?)\", params[:providers].split(',') << Provider.find_by_name('unspecified')) if params[:providers] != 'null'\n @internships = @internships.where(\"locations.id IN (?)\", params[:locations].split(',')) if params[:locations] != 'null'\n @internships = @internships.where(\"academic_focuses.id IN (?)\", params[:academic_focuses].split(',') << AcademicFocus.find_by_name('unspecified')) if params[:academic_focuses] != 'null'\n end\n \n #Format Response\n internships = Hash.new\n @internships.each do |internship|\n internship = Internship.find(internship.id)\n internship.locations.each do |location|\n internships[location.country.un_code] = Array.new if internships[location.country.un_code] == nil\n internships[location.country.un_code] << {\n 'id' => internship.id,\n 'name' => internship.name,\n 'provider_name' => internship.provider.name,\n 'city' => location.city, \n 'state' => location.state.name, \n 'country' => location.country.name, \n }\n end \n end\n \n #send response\n render :json => internships\n \n }\n end\n end",
"def create\n @interno_unidad = InternoUnidad.new(interno_unidad_params)\n\n respond_to do |format|\n if @interno_unidad.save\n format.html { redirect_to @interno_unidad, notice: 'Interno unidad was successfully created.' }\n format.json { render :show, status: :created, location: @interno_unidad }\n else\n format.html { render :new }\n format.json { render json: @interno_unidad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @clientship = current_user.clientships.build(:client_id => params[:client_id], :fee => params[:fee])\n\n respond_to do |format|\n if @clientship.save\n format.html { redirect_to @clientship, notice: 'Clientship was successfully created.' }\n format.json { render json: @clientship, status: :created, location: @clientship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clientship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @discipleship = Discipleship.new(discipleship_params)\n\n respond_to do |format|\n if @discipleship.save\n format.html { redirect_to @discipleship, notice: 'Discipleship was successfully created.' }\n format.json { render action: 'show', status: :created, location: @discipleship }\n else\n format.html { render action: 'new' }\n format.json { render json: @discipleship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def internship_params\n params[:internship].delete :organisation\n # binding.pry\n params.require(:internship).permit(:student_id, :institution_id, :mentor_id, :contract_proved,\n :block, :start_date, :end_date, :comments, :exchange)\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 create\n @spaceship = Spaceship.new(params[:spaceship])\n\n respond_to do |format|\n if @spaceship.save\n format.html { redirect_to @spaceship, notice: 'Spaceship was successfully created.' }\n format.json { render json: @spaceship, status: :created, location: @spaceship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @spaceship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n params[:internship][:field_ids] ||= []\n @internship = Internship.find(params[:id])\n \n respond_to do |format|\n if @internship.owner_hash == cookies[:hash] and\n @internship.update_attributes(params[:internship])\n format.js\n format.html { redirect_to(@internship, :notice => 'Internship was successfully updated.') }\n format.json { head :ok }\n else\n format.json { render :json => @internship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @friendship = @user.friendships.new(params[:friendship])\n\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to [@game, @user, @friendship], notice: 'Friendship was successfully created.' }\n format.json { render json: [@game, @user, @friendship], status: :created, location: [@game, @user, @friendship] }\n else\n format.html { render action: \"new\" }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @society_member_ship = SocietyMemberShip.new(society_member_ship_params)\n\n respond_to do |format|\n if @society_member_ship.save\n format.html { redirect_to @society_member_ship, notice: 'Society member ship was successfully created.' }\n format.json { render :show, status: :created, location: @society_member_ship }\n else\n format.html { render :new }\n format.json { render json: @society_member_ship.errors, status: :unprocessable_entity }\n end\n end\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 internship_committee_params\n params.require(:internship_committee).permit(:internship_id, :home_c_id, :away_c_id)\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 new\n @clientship = Clientship.new\n @users = User.all\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clientship }\n end\n end",
"def create\n \n @ship = current_user.create_ship(ship_params)\n \n\n respond_to do |format|\n if @ship!=nil\n current_user.activeShip = @ship.id\n if @ship.save\n format.html { redirect_to @ship, notice: 'Ship was successfully created.' }\n format.json { render :show, status: :created, location: @ship }\n else\n format.html { render :new }\n format.json { render json: @ship.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to ships_path, notice: 'Kauf nicht erfolgreich!' }\n \n end\n end\n end",
"def create\n @creator.works << Work.where(id: work_ids)\n if @creator.save\n render json: @creator, status: :created, location: @creator\n else\n render json: @creator.errors, status: :unprocessable_entity\n end\n end",
"def destroy\n @internship.destroy\n @complete_internship = current_user.student.complete_internship\n respond_to do |format|\n format.html { redirect_to @complete_internship }\n format.json { head :no_content }\n end\n end",
"def show\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n format.html \n format.json { render :json => @internship }\n end\n end",
"def create\n @eleccion_interna = EleccionInterna.new(eleccion_interna_params)\n\n respond_to do |format|\n if @eleccion_interna.save\n format.html { redirect_to @eleccion_interna, notice: 'Eleccion interna was successfully created.' }\n format.json { render :show, status: :created, location: @eleccion_interna }\n else\n format.html { render :new }\n format.json { render json: @eleccion_interna.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ship_params\n params.require(:ship).permit(:name, :ships_id, :stations_id, :level, :activeShip)\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to(internships_url) }\n format.xml { head :ok }\n end\n end",
"def create\n # render json: params\n render json: UserBoards.create(params[\"user_board\"])\n end",
"def create\n @airplane = Airplane.new(airplane_params)\n \n respond_to do |format|\n if @airplane.save\n format.html { redirect_to @airplane, notice: 'Airplane was successfully created.' }\n format.json { render action: 'show', status: :created, location: @airplane }\n else\n format.html { render action: 'new' }\n format.json { render json: @airplane.errors, status: :unprocessable_entity }\n end\n end\n\n # rows_array = (1..@airplane.row.to_i).to_a\n # column_array = (1..@airplane.column.to_i).to_a\n \n\n # rows_array.each do |row_name|\n # column_array.each do |column_name|\n # seat_name = row_name.to_s + \"-\" + column_name.to_s \n # seat = Seat.create(:column_row => seat_name, :flight_id => @airplane.id, :available => true)\n # end\n # end\n\n \n end",
"def build_ships\n 5.times do\n ship = self.ships.build\n ship.populate\n end\n end",
"def create\n @player_ship = PlayerShip.new(player_ship_params)\n\n respond_to do |format|\n if @player_ship.save\n format.html { redirect_to @player_ship, notice: 'Player ship was successfully created.' }\n format.json { render :show, status: :created, location: @player_ship }\n else\n format.html { render :new }\n format.json { render json: @player_ship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @internship }\n format.json {\n internship = {\n 'id' => @internship.id, \n 'name' => @internship.name, \n 'is_paid' => @internship.is_paid,\n 'is_full_time' => @internship.is_full_time, \n 'is_part_time' => @internship.is_part_time, \n 'stipend' => @internship.stipend,\n 'description' => @internship.description,\n 'qualifications' => @internship.qualifications,\n 'qualifications_academic' => @internship.qualifications_academic,\n 'for_credit' => @internship.for_credit,\n 'requires_us_citizenship' => @internship.requires_us_citizenship,\n 'application_process' => @internship.application_process,\n 'deadline' => @internship.deadline,\n 'academic_contact_name' => false,\n 'provider_contact_name' => false,\n 'provider_name' => @internship.provider.name,\n 'locations' => Array.new,\n 'academic_focuses' => Array.new,\n 'fields' => Array.new,\n 'languages' => Array.new,\n 'financial_assistance_options' => Array.new,\n 'semesters' => Array.new\n }\n #These 2 fields are one or the other, so they are set here on thier own so we avoid calling 'name' on an nil object\n internship['academic_contact_name'] = @internship.academic_contact.name if @internship.academic_contact != nil\n internship['provider_contact_name'] = @internship.provider_contact.name if @internship.provider_contact != nil\n \n @internship.locations.each do |location|\n internship['locations'] << {\n 'city' => location.city, \n 'state' => location.state.name, \n 'country' => location.country.name\n }\n end\n @internship.academic_focuses.each do |academic_focus|\n internship['academic_focuses'] << {\n 'name' => academic_focus.name, \n 'type' => academic_focus.academic_focus_type.name\n }\n end\n @internship.fields.each do |field|\n internship['fields'] << {\n 'name' => field.name,\n 'industry' => field.industry.name\n }\n end\n @internship.languages.each do |language|\n internship['languages'] << {\n 'name' => language.name\n }\n end\n @internship.financial_assistance_options.each do |financial_assistance_option|\n internship['financial_assistance_options'] << {\n 'name' => financial_assistance_option.name,\n 'type' => financial_assistance_option.financial_assistance_option_type.name,\n 'how_much' => financial_assistance_option.how_much,\n 'qualifications' => financial_assistance_option.qualifications,\n 'source' => financial_assistance_option.source,\n 'website' => financial_assistance_option.website \n }\n end\n @internship.semesters.each do |semester|\n internship['semesters'] << {\n 'name' => semester.name\n }\n end\n\n render :json => internship \n }\n end\n end",
"def index\n @ships = Ship.all\n end",
"def index\n @ships = Ship.all\n end",
"def new\n \t@internship_position = InternshipPosition.new\n\n \trespond_to do |format|\n \t\tformat.html #new.html.erb\n \t\tformat.json { render json: @internship_position }\n \tend\n end",
"def update\n @internship = Internship.find(params[:id])\n respond_to do |format|\n if @internship.update_attributes(params[:internship])\n format.html { redirect_to(@internship, :notice => 'Internship was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @internship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @island = Island.new(params[:island])\n\n respond_to do |format|\n if @island.save\n format.html { redirect_to @island, notice: 'Island was successfully created.' }\n format.json { render json: @island, status: :created, location: @island }\n else\n format.html { render action: \"new\" }\n format.json { render json: @island.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @internships_user = InternshipsUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @internships_user }\n end\n end",
"def create\n @friendship = current_person.friendships.build(:granter_id => params[:granter_id], :accepted => params[:accepted])\n\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to people_url, notice: 'A friend request has been sent to ' + Person.find(params[:granter_id]).name }\n format.json { render :show, status: :created, location: @friendship }\n else\n format.html { render :new }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @server = Server.new(server_params)\n @neo = Neography::Rest.new\n\n respond_to do |format|\n if @server.save && n = Neography::Node.create(\"name\" => server_params[:name])\n n.add_to_index('servers', 'name', server_params[:name])\n n.id = n.neo_id # this construct should be improved..\n format.html { redirect_to @server, notice: 'Server was successfully created.' }\n format.json { render :show, status: :created, location: @server }\n else\n format.html { render :new }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @before_intership = BeforeIntership.new(params[:before_intership])\n\n respond_to do |format|\n if @before_intership.save\n format.html { redirect_to @before_intership, notice: 'Before intership was successfully created.' }\n format.json { render json: @before_intership, status: :created, location: @before_intership }\n else\n format.html { render action: \"new\" }\n format.json { render json: @before_intership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @township = Township.new(township_params)\n\n respond_to do |format|\n if @township.save\n format.html { redirect_to @township, notice: 'Township was successfully created.' }\n format.json { render :show, status: :created, location: @township }\n else\n format.html { render :new }\n format.json { render json: @township.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 unless current_user.assignments.find_by(id: params[:assignment_id])\n render json: format_errors({ assignment_id: [\"is not one of current user's assignments\"] }),\n status: :forbidden\n return\n end\n\n @iteration = Iteration.create(iteration_params)\n\n if @iteration.save\n render json: @iteration, status: :created\n else\n render json: format_errors(@iteration.errors),\n status: :unprocessable_entity\n end\n end",
"def create\n \n @max_ships=50 \n @ship_group = ShipGroup.new(ship_group_params)\n @ship_name =Unit.find(@ship_group.unit_id).name\n respond_to do |format|\n if @ship_group.save\n format.html { redirect_to @ship_group, notice: 'Ship group was successfully created.' }\n format.json { render :show, status: :created, location: @ship_group }\n else\n format.html { render :new }\n format.json { render json: @ship_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def criar_sobrevivente\n @suvivor = Sobrevivente.create(\n name: params[:name], genero: params[:genero], idade: params[:idade],\n lat: params[:lat], lon: params[:lon],\n agua: params[:agua], comida: params[:comida], medicamento: params[:medicamento],\n municao: params[:municao]\n )\n render json: @suvivor\n end",
"def create\n @shipcount = Shipcount.new(shipcount_params)\n\n respond_to do |format|\n if @shipcount.save\n format.html { redirect_to @shipcount, notice: 'Shipcount was successfully created.' }\n format.json { render action: 'show', status: :created, location: @shipcount }\n else\n format.html { render action: 'new' }\n format.json { render json: @shipcount.errors, status: :unprocessable_entity }\n end\n end\n end",
"def leaderboard\n result = service.save(params.permit!.to_h[:leaderboard])\n render json: {success: true}\n end",
"def create\n @championship = Championship.new(championship_params.merge(user: current_user))\n\n if @championship.save\n render json: @championship, status: :created, location: @championship\n else\n render json: @championship.errors, status: :unprocessable_entity\n end\n end",
"def create\n @orphan_sponsorship = OrphanSponsorship.new(orphan_sponsorship_params)\n\n respond_to do |format|\n if @orphan_sponsorship.save\n format.html { redirect_to @orphan_sponsorship, notice: 'Orphan sponsorship was successfully created.' }\n format.json { render :show, status: :created, location: @orphan_sponsorship }\n else\n format.html { render :new }\n format.json { render json: @orphan_sponsorship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # prevent user from adding friends who are already on friends list.\n if @friendship\n render json: { Message: \"You're already friends!\" }, status: :unprocessable_entity\n else\n @friend = current_user.friendships.create(:friend_id => @friend_id)\n render json: @friend, status: 201\n end\n end",
"def create\n Friendship.request(@user, @friend)\n @friend = Friendship.find_by_user_id_and_friend_id(@user, @friend)\n render :json => { :success => true, :new_friend => @friend }\n end",
"def index\n @kinships = Kinship.all\n end",
"def create\n @ship = Ship.new(params[:ship])\n @ship.game_id = @game.id\n @ship.health = @ship.ship_type.length\n @ship.vertical = true\n @ship.player_id = @player.id\n\n respond_to do |format|\n if @ship.save\n format.html { redirect_to [@game, @ship], notice: 'Ship was successfully created.' }\n format.json { render json: @ship, status: :created, location: @ship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_from_candidates\n authorize @competition.competitors.new\n\n heat = params[:heat].to_i\n competitors = params[:competitors]\n begin\n LaneAssignment.transaction do\n competitors.each do |_, competitor|\n reg = Registrant.find_by!(bib_number: competitor[:bib_number])\n lane_assignment = LaneAssignment.new(registrant_id: reg.id, lane: competitor[:lane].to_i, heat: heat, competition: @competition)\n lane_assignment.allow_competitor_auto_creation = true\n lane_assignment.save!\n end\n end\n flash[:notice] = \"Created Lane Assignments & Competitors\"\n rescue StandardError => e\n flash[:alert] = \"Error creating lane assignments/competitors #{e}\"\n end\n redirect_to competition_competitors_path(@competition)\n end",
"def new\n \n @ship = Ship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ship }\n end\n end",
"def generate_individual_ships\n # for each ship type, create it and then assign it to its accessor\n %w|carrier battleship submarine warship destroyer|.each do |type|\n ship = Ship.new(type)\n case type\n when \"carrier\"\n then @carrier = ship\n when \"battleship\"\n then @battleship = ship\n when \"submarine\"\n then @submarine = ship\n when \"warship\"\n then @warship = ship\n when \"destroyer\"\n then @destroyer = ship\n end\n @fleet << ship # for fleet-building\n end\n end",
"def create\n @job_ship = JobShip.new(job_ship_params)\n if @job_ship.save\n redirect_to @job_ship, notice: 'Job ship was successfully created.'\n else\n render 'new'\n end\n end",
"def create\n @championship = Championship.new(championship_params)\n\n if @championship.save\n render :show, status: :created, location: @championship\n else\n render json: @championship.errors, status: :unprocessable_entity\n end\n end",
"def create\n @ship_methods = ShipMethods.new(params[:ship_methods])\n\n respond_to do |format|\n if @ship_methods.save\n flash[:notice] = 'ShipMethods was successfully created.'\n format.html { redirect_to(@ship_methods) }\n format.xml { render :xml => @ship_methods, :status => :created, :location => @ship_methods }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ship_methods.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @player_ships = PlayerShip.all\n end",
"def create\n @friendship = Friendship.new\n @friendship.user1_id = current_user.id\n @friendship.user2_id = @owner.id\n @friendship.approved = false\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to friendships_main_path, flash: { :success => 'Request of friendship was successfully sent.' } }\n format.json { render :index, status: :created, location: @friendship }\n else\n set_index_friendships\n format.html { render :index }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_shippment(items)\n fill_boxes(items)\n shippment_object\n make_json_object\n end",
"def create\n @fleet_ship = FleetShip.new(fleet_ship_params)\n\n respond_to do |format|\n if @fleet_ship.save\n format.html { redirect_to @fleet_ship, notice: 'Fleet ship was successfully created.' }\n format.json { render :show, status: :created, location: @fleet_ship }\n else\n format.html { render :new }\n format.json { render json: @fleet_ship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @ship = Ship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ship }\n end\n end",
"def ships_sub_params\n params.require(:ships_sub).permit(:name)\n end",
"def create\n @shipdesign = Shipdesign.new(params[:shipdesign])\n\n respond_to do |format|\n if @shipdesign.save\n format.html { redirect_to @shipdesign, notice: 'Shipdesign was successfully created.' }\n format.json { render json: @shipdesign, status: :created, location: @shipdesign }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shipdesign.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @spaceship = Spaceship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spaceship }\n end\n end",
"def create\r\n @intern_question = InternQuestion.new(params[:intern_question])\r\n\r\n respond_to do |format|\r\n if @intern_question.save\r\n format.html { redirect_to @intern_question, notice: 'Intern question was successfully created.' }\r\n format.json { render json: @intern_question, status: :created, location: @intern_question }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @intern_question.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @shiping = Shiping.new(shiping_params)\n @user = current_user\n\n respond_to do |format|\n if @shiping.save\n format.html { redirect_to @shiping, notice: 'Shiping was successfully created.' }\n format.json { render :show, status: :created, location: @shiping }\n else\n format.html { render :new }\n format.json { render json: @shiping.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @interest = Interest.new(params[:interest])\n \n respond_to do |format|\n if @interest.save\n format.json { render :json => @interest,\n :status => :created, :location => @interest }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.73136866",
"0.6690699",
"0.66506475",
"0.62748206",
"0.6123335",
"0.6034088",
"0.5963591",
"0.5963591",
"0.5858024",
"0.58463675",
"0.58346415",
"0.5827366",
"0.5743004",
"0.5739911",
"0.57243204",
"0.555894",
"0.54834324",
"0.5419208",
"0.5410784",
"0.5372609",
"0.5342743",
"0.53147954",
"0.5263939",
"0.5263939",
"0.5263939",
"0.5223019",
"0.5221579",
"0.5192779",
"0.5189592",
"0.5189592",
"0.5178956",
"0.51714134",
"0.5170395",
"0.5156948",
"0.514813",
"0.51475805",
"0.51412654",
"0.5127447",
"0.5100053",
"0.50903904",
"0.50839597",
"0.508192",
"0.50664455",
"0.5058193",
"0.5050623",
"0.5038237",
"0.5011455",
"0.5002049",
"0.49809435",
"0.496925",
"0.49691418",
"0.4961589",
"0.49462685",
"0.49353242",
"0.49076015",
"0.48990664",
"0.48987612",
"0.4885564",
"0.4880489",
"0.4873544",
"0.4873064",
"0.48631343",
"0.48631343",
"0.48620817",
"0.4860853",
"0.48555472",
"0.48535383",
"0.48464915",
"0.48393914",
"0.48083025",
"0.4805341",
"0.48049596",
"0.47963244",
"0.47885963",
"0.47877595",
"0.47706366",
"0.4764512",
"0.47587267",
"0.47446045",
"0.47424203",
"0.47250387",
"0.47167954",
"0.4694603",
"0.46935973",
"0.46910784",
"0.46770424",
"0.4670137",
"0.46685272",
"0.46622217",
"0.46617836",
"0.4656856",
"0.46550116",
"0.46491307",
"0.4644864",
"0.46412528",
"0.46411425",
"0.46329734",
"0.46260706",
"0.46239594",
"0.4612642"
] | 0.7115359 | 1 |
PUT /internships/1 PUT /internships/1.json | def update
@internship = Internship.find(params[:id])
respond_to do |format|
if @internship.update_attributes(params[:internship])
format.html { redirect_to @internship, notice: 'Internship was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @internship.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @internship = Internship.find(params[:id])\n\n if @internship.update_attributes(params[:internship])\n flash[:notice] = 'Internship was successfully updated.'\n end\n respond_with(@internship)\n end",
"def update\n @internship = Internship.find(params[:id])\n respond_to do |format|\n if @internship.update_attributes(params[:internship])\n format.html { redirect_to(@internship, :notice => 'Internship was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @internship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_internship\n @internship = Internship.find params[:id]\n authorize @internship\n end",
"def update\n @intern = Intern.find(params[:id])\n\n respond_to do |format|\n if @intern.update_attributes(params[:intern])\n format.html { redirect_to @intern, notice: 'Intern was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @intern.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = current_user\n @internship = @user.internships.build(params[:internship])\n #@internship = Internship.new(params[:internship])\n\n respond_to do |format|\n if @internship.save\n format.html { redirect_to @internship, notice: 'Internship was successfully created.' }\n format.json { render json: @internship, status: :created, location: @internship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @internship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @internships_user = InternshipsUser.find(params[:id])\n\n respond_to do |format|\n if @internships_user.update_attributes(params[:internships_user])\n format.html { redirect_to @internships_user, :notice => 'Internships user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @internships_user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @internship = Internship.new(params[:internship])\n\n respond_to do |format|\n if @internship.save\n format.html { redirect_to @internship, notice: 'Internship was successfully created.' }\n format.json { render json: @internship, status: :created, location: @internship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @internship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n params[:internship][:field_ids] ||= []\n @internship = Internship.find(params[:id])\n \n respond_to do |format|\n if @internship.owner_hash == cookies[:hash] and\n @internship.update_attributes(params[:internship])\n format.js\n format.html { redirect_to(@internship, :notice => 'Internship was successfully updated.') }\n format.json { head :ok }\n else\n format.json { render :json => @internship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find(current_user.id)\n if @user.internship_authorization\n @internship = Internship.new(params[:internship])\n @internship.user_id = current_user.id if current_user\n @user.internship_authorization = false\n @user.save\n flash[:notice] = \"Internship was successfully created\" if @internship.save\n respond_with(@internship)\n else\n flash[:notice] = \"You cannot create an internship\"\n redirect_to internships_url\n end\n end",
"def update\n respond_to do |format|\n name = Server.find(params[:id]).name\n n = Neography::Node.find('servers', 'name', name)\n n.name = server_params[:name]\n n.add_to_index('servers', 'name', server_params[:name]) #TODO: is this necessary?\n if @server.update(server_params)\n format.html { redirect_to @server, notice: 'Server was successfully updated.' }\n format.json { render :show, status: :ok, location: @server }\n else\n format.html { render :edit }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @internship_committee.update(internship_committee_params)\n format.html { redirect_to @internship_committee, notice: 'Internship committee was successfully updated.' }\n format.json { render :show, status: :ok, location: @internship_committee }\n else\n format.html { render :edit }\n format.json { render json: @internship_committee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @intern = Intern.find(params[:id])\n @internships = Internship.where(intern_id: @intern.id)\n respond_to do |format|\n format.html #show.html.erb\n format.json { render json: @intern }\n end\n end",
"def update\n @clientship = current_user.clientships.find(params[:id])\n\n respond_to do |format|\n if @clientship.update_attributes(params[:clientship])\n format.html { redirect_to @clientship, notice: 'Clientship was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clientship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @internship = Internship.new(params[:internship])\n \n respond_to do |format|\n if @internship.save\n format.html { redirect_to(@internship, :notice => 'Internship was successfully created.') }\n format.xml { render :xml => @internship, :status => :created, :location => @internship }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @internship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to(internships_url) }\n format.json { head :ok }\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end",
"def update\n @intern = Intern.find(params[:id])\n\n if @intern.update_attributes(intern_params)\n redirect_to @intern, notice: 'Post was successfully updated.'\n else\n render action: \"edit\"\n\n end\n\n end",
"def new\n if User.find(current_user.id).internship_authorization\n @internship = Internship.new\n respond_with(@internship)\n else\n flash[:notice] = \"You cannot create an internship\"\n redirect_to internships_url\n end\n end",
"def index\n @internships = Internship.all\n @current_user = User.find(current_user.id)\n respond_with(@internships)\n end",
"def show\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @internship }\n end\n end",
"def update\n @ship = Ship.find(params[:id])\n\n respond_to do |format|\n if @ship.update_attributes(params[:ship])\n format.html { redirect_to @ship, notice: 'Ship was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ship = Ship.find(params[:id])\n\n respond_to do |format|\n if @ship.update_attributes(params[:ship])\n format.html { redirect_to @ship, notice: 'Ship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \t@internship_position = InternshipPosition.find(params[:id])\n\n \trespond_to do |format|\n \t\tif @internship_position.update_attributes(internship_position_params)\n \t\t\tformat.html { redirect_to @internship_position, notice: 'Posiiton was successfully updated.' }\n \t\t\tformat.json { head :no_content }\n \t\telse\n \t\t\tformat.html { render action: \"edit\" }\n \t\t\tformat.json { render json: @internship_position.errors, status: :unprocessable_entity }\n \t\tend\n \tend\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to(internships_url) }\n format.xml { head :ok }\n end\n end",
"def new\n @internship = Internship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @internship }\n end\n end",
"def new\n @internship = Internship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @internship }\n end\n end",
"def update\n @spaceship = Spaceship.find(params[:id])\n\n respond_to do |format|\n if @spaceship.update_attributes(params[:spaceship])\n format.html { redirect_to @spaceship, notice: 'Spaceship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spaceship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @internships_user = InternshipsUser.new(params[:internships_user])\n\n respond_to do |format|\n if @internships_user.save\n format.html { redirect_to @internships_user, :notice => 'Internships user was successfully created.' }\n format.json { render :json => @internships_user, :status => :created, :location => @internships_user }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @internships_user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n render json: UserBoards.update(params[\"id\"], params[\"user_board\"])\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def internships\n respond_to do |format|\n format.html # internships.html.erb\n format.xml { render :xml => nil }\n end\n end",
"def update_ships\n # A data structure to store the ships in\n\n ships = [\n [\"Brittana\", [\"Brittany P.\", \"Santana L.\"]],\n [\"Faberry\", [\"Quinn F.\", \"Rachel B.\"]],\n [\"Flanamotta\", [\"Rory F.\", \"Sugar\"]],\n [\"Sory\", [\"Rory F.\", \"Sam E.\"]],\n [\"Seblaine\", [\"Sebastian S.\", \"Blaine A.\"]],\n [\"Santofsky\", [\"D. Karofsky\", \"Santana L.\"]],\n [\"Bartie\", [\"Brittany P.\", \"Artie A.\"]],\n [\"Tike\", [\"Mike C.\", \"Tina C.\"]],\n [\"Pezberry\", [\"Santana L.\", \"Rachel B.\"]],\n [\"Pizes\", [\"Lauren Z.\", \"Puck\"]],\n [\"St. Berry\", [\"Jesse sJ.\", \"Rachel B.\"]],\n [\"Kill\", [\"Kurt H.\", \"Will S.\"]],\n [\"Puckurt\", [\"Kurt H.\", \"Puck\"]],\n [\"Artina\", [\"Tina C.\", \"Artie A.\"]],\n [\"Partie\", [\"Puck\", \"Artie A.\"]],\n [\"Blainofskyve\", [\"Blaine A.\", \"D. Karofsky\"]],\n [\"Klaine\", [\"Kurt H.\", \"Blaine A.\"]],\n [\"Hummelberry\", [\"Kurt H.\", \"Rachel B.\"]],\n [\"Furt\", [\"Kurt H.\", \"Finn H.\"]],\n [\"Pinn\", [\"Puck\", \"Finn H.\"]],\n [\"Samcedes\", [\"Sam E.\", \"Mercedes J.\"]],\n [\"Artcedes\", [\"Artie A.\", \"Mercedes J.\"]],\n [\"Finchel\", [\"Finn H.\", \"Rachel B.\"]],\n [\"Puckleberry\", [\"Puck\", \"Rachel B.\"]],\n [\"Wemma\", [\"Will S.\", \"Emma P.\"]]\n ]\n\n ships.each do |ship_data|\n ship = Ship.find_by_name(ship_data[0])\n\n # Make sure the ship doesn't already exist\n if !ship\n\n # create a new ship\n ship = Ship.new()\n ship.name = ship_data[0]\n ship.save\n\n # For each character in the ship\n ship_characters = ship_data[1]\n generate_log(\"Generating New Ship: #{ship_data[0]} between #{ship_data[1]}\")\n ship_characters.each do |ship_character|\n character = generate_character(ship_character)\n # Save the relationship\n relationship = Relationship.new()\n relationship.ship = ship\n relationship.character = character\n relationship.save\n\n end\n else\n ship.update_attributes(:name => ship_data[0])\n ship.save\n generate_log(\"Updating: #{ship_data[0]} between #{ship_data[1]}\")\n\n\n end\n end\nend",
"def update\n @monitorship = Monitorship.find(params[:id])\n\n respond_to do |format|\n if @monitorship.update_attributes(params[:monitorship])\n format.html { redirect_to @monitorship, notice: 'Monitorship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @monitorship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @discipleship.update(discipleship_params)\n format.html { redirect_to @discipleship, notice: 'Discipleship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @discipleship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @championship.update(championship_params)\n render :show, status: :ok, location: @championship\n else\n render json: @championship.errors, status: :unprocessable_entity\n end\n end",
"def put(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_put(@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 @game = Game.find(params[:id])\n \n respond_to do |format|\n if @game.update_attributes(params[:game])\n @game.tag_with params[:tag][:tag_list] if params[:tag] && params[:tag][:tag_list] != \"\"\n flash[:notice] = 'Game was successfully updated.'\n @game.authorships.create_from_names(params[:authorship])\n format.html { redirect_to game_path(@game) }\n format.xml { head :ok }\n else\n @base_games = Game.base_games.find(:all)\n if !@game.authors\n @authors = []\n 3.times{@authors << Author.new}\n else\n @authors = @game.authors.find(:all)\n (3 - @authors.size).times{@authors << Author.new }\n end\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @game.errors.to_xml }\n end\n end\n end",
"def update\n @island = Island.find(params[:id])\n\n respond_to do |format|\n if @island.update_attributes(params[:island])\n format.html { redirect_to @island, notice: 'Island was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @island.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @eleccion_interna.update(eleccion_interna_params)\n format.html { redirect_to @eleccion_interna, notice: 'Eleccion interna was successfully updated.' }\n format.json { render :show, status: :ok, location: @eleccion_interna }\n else\n format.html { render :edit }\n format.json { render json: @eleccion_interna.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_internship_committee\n @internship_committee = InternshipCommittee.find(params[:id])\n end",
"def update\n @ministries = Ministries.find(params[:id])\n\n respond_to do |format|\n if @ministries.update_attributes(params[:ministries])\n flash[:notice] = 'Ministries was successfully updated.'\n format.html { redirect_to(@ministries) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ministries.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ship.update(ship_params)\n format.html { redirect_to @ship, notice: 'Ship was successfully updated.' }\n format.json { render :show, status: :ok, location: @ship }\n else\n format.html { render :edit }\n format.json { render json: @ship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @interno_unidad.update(interno_unidad_params)\n format.html { redirect_to @interno_unidad, notice: 'Interno unidad was successfully updated.' }\n format.json { render :show, status: :ok, location: @interno_unidad }\n else\n format.html { render :edit }\n format.json { render json: @interno_unidad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sprint.update!(sprint_params)\n json_response(@sprint)\n end",
"def show\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n format.html \n format.json { render :json => @internship }\n end\n end",
"def update\n respond_to do |format|\n if @shipcount.update(shipcount_params)\n format.html { redirect_to @shipcount, notice: 'Shipcount was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @shipcount.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n request :put, *args\n end",
"def update\n @championship = Championship.find(params[:id])\n\n if @championship.update(championship_params.merge(user: current_user))\n head :no_content\n else\n render json: @championship.errors, status: :unprocessable_entity\n end\n end",
"def friendships_update(options = {})\n @req.post(\"/1.1/friendships/update.json\", options)\n end",
"def set_interno\n @interno = Interno.find(params[:id])\n end",
"def set_ships_sub\n @ships_sub = ShipsSub.find(params[:id])\n end",
"def destroy\n @intern = Intern.find(params[:id])\n @intern.destroy\n\n respond_to do |format|\n format.html { redirect_to interns_url }\n format.json { head :no_content }\n end\n end",
"def update\n @name = Name.find(params[:id])\n\n\t\tif params[:index]\n\t\t\tn = @name.sei.length\n\t\t\ti = params[:index].to_i\n\t\t\tif i < n\n\t\t\t\tparams[:name][:mei] = params[:name][:sei][i .. n]\n\t\t\t\tparams[:name][:sei] = params[:name][:sei][0 .. i-1]\n\t\t\tend\n\t\tend\n\n respond_to do |format|\n if @name.update_attributes(params[:name])\n format.html { redirect_to @name, notice: 'Name was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @orphan_sponsorship.update(orphan_sponsorship_params)\n format.html { redirect_to @orphan_sponsorship, notice: 'Orphan sponsorship was successfully updated.' }\n format.json { render :show, status: :ok, location: @orphan_sponsorship }\n else\n format.html { render :edit }\n format.json { render json: @orphan_sponsorship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @society_member_ship.update(society_member_ship_params)\n format.html { redirect_to @society_member_ship, notice: 'Society member ship was successfully updated.' }\n format.json { render :show, status: :ok, location: @society_member_ship }\n else\n format.html { render :edit }\n format.json { render json: @society_member_ship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.find(params[:game_id])\n @game.authorships.create_from_names(params[:authorship])\n respond_to do |format|\n flash[:notice] = 'Les autheurs sont enregistres'\n format.html { redirect_to game_path(@game) }\n format.xml { head :created, :location => authorship_url(@authorship) }\n end\n end",
"def update\n @inventorship = Inventorship.find(params[:id])\n\n respond_to do |format|\n if @inventorship.update_attributes(params[:inventorship])\n flash[:notice] = 'Inventorship was successfully updated.'\n format.html { redirect_to(@inventorship) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @inventorship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @authorship = Authorship.find(params[:id])\n\n respond_to do |format|\n if @authorship.update_attributes(params[:authorship])\n flash[:notice] = 'Authorship was successfully updated.'\n format.html { redirect_to authorship_url(@authorship) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @authorship.errors.to_xml }\n end\n end\n end",
"def update\n @before_intership = BeforeIntership.find(params[:id])\n\n respond_to do |format|\n if @before_intership.update_attributes(params[:before_intership])\n format.html { redirect_to @before_intership, notice: 'Before intership was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @before_intership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\nlogger.debug \"update discipline: \"+@discipline.inspect\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 destroy\n @internship.destroy\n @complete_internship = current_user.student.complete_internship\n respond_to do |format|\n format.html { redirect_to @complete_internship }\n format.json { head :no_content }\n end\n end",
"def new\n @internships_user = InternshipsUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @internships_user }\n end\n end",
"def update\n @shichoson = Shichoson.find(params[:id])\n\n respond_to do |format|\n if @shichoson.update_attributes(params[:shichoson])\n format.html { redirect_to @shichoson, notice: 'Shichoson was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shichoson.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ship = Ship.find(params[:id])\n\n respond_to do |format|\n if @ship.update_attributes(params[:ship])\n flash[:notice] = 'Ship was successfully updated.'\n format.html { redirect_to(@ship) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ship = Ship.find(params[:id])\n\n respond_to do |format|\n if @ship.update_attributes(params[:ship])\n flash[:notice] = 'Ship was successfully updated.'\n format.html { redirect_to(@ship) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def update\n @initiative = Initiative.find(params[:id])\n \n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n \n format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @initiative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n request(:put, *args)\n end",
"def set_studentship\n @studentship = Studentship.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @fellowship.update(fellowship_params)\n format.html { redirect_to @fellowship, notice: 'Fellowship was successfully updated.' }\n format.json { render :show, status: :ok, location: @fellowship }\n else\n format.html { render :edit }\n format.json { render json: @fellowship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @internships_user = InternshipsUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @internships_user }\n end\n end",
"def put!\n request! :put\n end",
"def update\r\n @intern_question = InternQuestion.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @intern_question.update_attributes(params[:intern_question])\r\n format.html { redirect_to @intern_question, notice: 'Intern question 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: @intern_question.errors, status: :unprocessable_entity }\r\n end\r\n end\r\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(resource,identifier,json)\n raise 'Not Yet Implemented'\n end",
"def internship_params\n params[:internship].delete :organisation\n # binding.pry\n params.require(:internship).permit(:student_id, :institution_id, :mentor_id, :contract_proved,\n :block, :start_date, :end_date, :comments, :exchange)\n end",
"def update\n @community_farm = @raid.community_farms.find(params[:id])\n respond_to do |format|\n if @community_farm.update(community_farm_params)\n format.html { redirect_to dashboard_index_path, notice: COMMUNITY_ASSIGN }\n format.json { render :show, status: :ok, location: @community_farm }\n else\n format.html { render :edit }\n format.json { render json: @community_farm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @county = County.find(params[:id])\n\n respond_to do |format|\n if @county.update_attributes(params[:county])\n format.html { redirect_to @county, notice: 'County was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @county.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @intern = Intern.new(params[:intern])\n @intern[:is_archived]=nil;\n\n respond_to do |format|\n if @intern.save\n UserMailer.new_intern_app_notify(@intern.id).deliver\n format.html { redirect_to \"/intern_thank_you\", notice: 'Intern was successfully created.' }\n #format.json { render json: @intern, status: :created, location: @intern }\n else\n format.html { render action: \"new\" }\n format.json { render json: @intern.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_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 @shelter = Shelter.find(params[:id])\n\n if @shelter.update(shelter_params)\n head :no_content\n else\n render json: @shelter.errors, status: :unprocessable_entity\n end\n end",
"def update(name: nil)\n data = name.nil? ? {} : {name: name}\n cf_patch(path: \"/organizations/#{org_id}\", data: data)\n end",
"def update\n friendship_new = Friendship.new\n friendship_new.user1_id = @friendship.user2_id\n friendship_new.user2_id = @friendship.user1_id\n friendship_new.approved = true\n friendship_new.save!\n @friendship.approved = true\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to back_page, flash: { :success => 'Friendship was approved.' } }\n format.json { render :index, status: :ok, location: @friendship }\n else\n set_index_friendships\n format.html { render :index }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @authorship = Authorship.in_conference(current_conference).find(params[:id])\n @authorship.conference_confirm = current_conference\n\n # respond_to do |format|\n if @authorship.update_attributes(params[:authorship])\n flash[:notice] = 'Authorship was successfully updated.'\n # format.html { render action: \"edit\" }\n # format.html { redirect_to @authorship, notice: 'Authorship was successfully updated.' }\n else\n flash[:error] = 'Failed to update Authorship.'\n # format.html { render action: \"edit\" }\n end\n # end\n respond_with @authorship, :success_action => :back\n end",
"def update\n respond_to do |format|\n if @api_v1_initiative.update(api_v1_initiative_params)\n format.html { redirect_to @api_v1_initiative, notice: 'Initiative was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gossip = Gossip.find(params[:id])\n\n respond_to do |format|\n if @gossip.update_attributes(params[:gossip])\n format.html { redirect_to @gossip, notice: 'Gossip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gossip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @incident = Incident.find(params[:id])\n\n if @incident.update(incident_params)\n head :no_content\n else\n render json: @incident.errors, status: :unprocessable_entity\n end\n end",
"def update\n @island = Island.find(params[:id])\n\n respond_to do |format|\n if @island.update_attributes(params[:island])\n flash[:notice] = 'Island was successfully updated.'\n format.html { redirect_to(@island) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @island.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ship_class = ShipClass.find(params[:id])\n\n respond_to do |format|\n if @ship_class.update_attributes(params[:ship_class])\n format.html { redirect_to @ship_class, notice: 'Ship class was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ship_class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_society_member_ship\n @society_member_ship = SocietyMemberShip.find(params[:id])\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 @space_station = SpaceStation.find(params[:id])\n\n if @space_station.update(space_station_params)\n head :no_content\n else\n render json: @space_station.errors, status: :unprocessable_entity\n end\n end",
"def update\n @friendship = @user.friendships.find(params[:id])\n\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n format.html { redirect_to [@game, @user, @friendship], notice: 'Friendship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @community = Community.find(params[:id])\n\n respond_to do |format|\n if @community.update_attributes(params[:community])\n format.html { redirect_to @community, notice: 'Community was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @clientship = current_user.clientships.find(params[:id])\n @clientship.destroy\n\n respond_to do |format|\n format.html { redirect_to clientships_url }\n format.json { head :ok }\n end\n end",
"def update\n @ship_methods = ShipMethods.find(params[:id])\n\n respond_to do |format|\n if @ship_methods.update_attributes(params[:ship_methods])\n flash[:notice] = 'ShipMethods was successfully updated.'\n format.html { redirect_to(@ship_methods) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ship_methods.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.67898536",
"0.6564102",
"0.6362706",
"0.63572764",
"0.6338132",
"0.62355536",
"0.6099583",
"0.5964067",
"0.57670724",
"0.576195",
"0.57573897",
"0.57526064",
"0.57436526",
"0.5684591",
"0.56517744",
"0.5623222",
"0.5623222",
"0.5623222",
"0.55432534",
"0.54426694",
"0.53340715",
"0.5319608",
"0.5312869",
"0.5294926",
"0.52800703",
"0.5271328",
"0.5264529",
"0.5264529",
"0.5259785",
"0.52315235",
"0.52212733",
"0.5195789",
"0.5190854",
"0.5174255",
"0.51686877",
"0.51675946",
"0.5160241",
"0.5159008",
"0.51233906",
"0.5119192",
"0.51150006",
"0.51093334",
"0.510355",
"0.5102207",
"0.51018566",
"0.5095714",
"0.50921535",
"0.5081018",
"0.5071301",
"0.5069531",
"0.5043423",
"0.50212026",
"0.5014823",
"0.50117147",
"0.500252",
"0.4999969",
"0.49974287",
"0.49898422",
"0.49829358",
"0.49813354",
"0.49797973",
"0.49781615",
"0.4976422",
"0.49758837",
"0.49676037",
"0.49640083",
"0.49640083",
"0.495373",
"0.4952643",
"0.49518862",
"0.49351528",
"0.49308294",
"0.49247384",
"0.49115258",
"0.49089763",
"0.49032137",
"0.48798907",
"0.48797983",
"0.48766503",
"0.48642918",
"0.4860928",
"0.4859092",
"0.48586878",
"0.48544934",
"0.48540705",
"0.48521838",
"0.48436645",
"0.4840573",
"0.48386556",
"0.4838431",
"0.48371315",
"0.4835494",
"0.48300874",
"0.48289445",
"0.4827636",
"0.48237208",
"0.48225614",
"0.4817697",
"0.4816166"
] | 0.68532103 | 1 |
DELETE /internships/1 DELETE /internships/1.json | def destroy
@internship = Internship.find(params[:id])
@internship.destroy
respond_to do |format|
format.html { redirect_to internships_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to(internships_url) }\n format.json { head :ok }\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to(internships_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @intern = Intern.find(params[:id])\n @intern.destroy\n\n respond_to do |format|\n format.html { redirect_to interns_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @internships_user = InternshipsUser.find(params[:id])\n @internships_user.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clientship = current_user.clientships.find(params[:id])\n @clientship.destroy\n\n respond_to do |format|\n format.html { redirect_to clientships_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @internship.destroy\n @complete_internship = current_user.student.complete_internship\n respond_to do |format|\n format.html { redirect_to @complete_internship }\n format.json { head :no_content }\n end\n end",
"def destroy\n @discipleship.destroy\n respond_to do |format|\n format.html { redirect_to discipleships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @monitorship = Monitorship.find(params[:id])\n @monitorship.destroy\n\n respond_to do |format|\n format.html { redirect_to monitorships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @internship_committee.destroy\n respond_to do |format|\n format.html { redirect_to internship_committees_url, notice: 'Internship committee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @spaceship = Spaceship.find(params[:id])\n @spaceship.destroy\n\n respond_to do |format|\n format.html { redirect_to spaceships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ab_reltionship.destroy\n respond_to do |format|\n format.html { redirect_to ab_reltionships_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: UserBoards.delete(params[\"id\"])\n end",
"def destroy\n @ship = Ship.find(params[:id])\n @ship.destroy\n\n respond_to do |format|\n format.html { redirect_to ships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ship = Ship.find(params[:id])\n @ship.destroy\n\n respond_to do |format|\n format.html { redirect_to ships_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @ship = Ship.find(params[:id])\n @ship.destroy\n\n respond_to do |format|\n format.html { redirect_to(ships_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ship = Ship.find(params[:id])\n @ship.destroy\n\n respond_to do |format|\n format.html { redirect_to(ships_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @interno.destroy\n respond_to do |format|\n format.html { redirect_to internos_url, notice: 'Interno fue borrado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n ship = Sailing.joins(:travelling_parties => :party_registers).find_by(\"party_registers.id\" => params[:id]).cruise_ship_name\n @party_register.destroy\n respond_to do |format|\n format.html { redirect_to user_dashboard_path, notice: \"You have left #{ship} sailing\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @manifestship.destroy\n respond_to do |format|\n format.html { redirect_to manifestships_url, notice: 'Manifestship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shipcount.destroy\n respond_to do |format|\n format.html { redirect_to shipcounts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @authorship = Authorship.find(params[:id])\n @authorship.destroy\n\n respond_to do |format|\n format.html { redirect_to(authorships_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @championship = Championship.find(params[:id])\n @championship.destroy\n\n respond_to do |format|\n format.html { redirect_to championships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ministries = Ministries.find(params[:id])\n @ministries.destroy\n\n respond_to do |format|\n format.html { redirect_to(ministries_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @authorship = Authorship.find(params[:id])\n @authorship.destroy\n\n respond_to do |format|\n format.html { redirect_to authorships_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @society_member_ship.destroy\n respond_to do |format|\n format.html { redirect_to society_member_ships_url, notice: 'Society member ship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shipfleet.destroy\n respond_to do |format|\n format.html { redirect_to shipfleets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inventorship = Inventorship.find(params[:id])\n @inventorship.destroy\n\n respond_to do |format|\n format.html { redirect_to(inventorships_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @intern = Intern.find(params[:id])\n @intern.destroy\n\n\n redirect_to searches_url\n\n\n end",
"def destroy\n @shipdesign = Shipdesign.find(params[:id])\n @shipdesign.destroy\n\n respond_to do |format|\n format.html { redirect_to shipdesigns_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ship.destroy\n respond_to do |format|\n format.html { redirect_to ships_url, notice: 'Ship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @player_ship.destroy\n respond_to do |format|\n format.html { redirect_to player_ships_url, notice: 'Player ship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @fleet_ship.destroy\n respond_to do |format|\n format.html { redirect_to fleet_ships_url, notice: 'Fleet ship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendship = @user.friendships.find(params[:id])\n @friendship.destroy\n\n respond_to do |format|\n format.html { redirect_to game_user_friendships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n chef_rest_v1.delete(\"clients/#{@name}\")\n end",
"def destroy\n @client.delete(@name)\n end",
"def destroy\n @client.delete( name )\n end",
"def destroy\n @fellowship.destroy\n respond_to do |format|\n format.html { redirect_to fellowships_url, notice: 'Fellowship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendship.destroy\n respond_to do |format|\n format.html { redirect_to friendships_url }\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 @township.destroy\n respond_to do |format|\n format.html { redirect_to townships_url, notice: 'Township was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ship_class = ShipClass.find(params[:id])\n @ship_class.destroy\n\n respond_to do |format|\n format.html { redirect_to ship_classes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server1 = Server1.find(params[:id])\n @server1.destroy\n\n respond_to do |format|\n format.html { redirect_to server1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \t@internship_position = InternshipPosition.find(params[:id])\n \t@internship_position.destroy\n\n \trespond_to do |format|\n \t\tformat.html { redirect_to root_path, notice: 'Posiiton was successfully destroyed.' }\n \t\tformat.json { head :no_content }\n \tend\n end",
"def destroy\n @contract.contract_assignments.destroy_all\n @contract.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @mini_map_road = MiniMapRoad.find(params[:id])\n @mini_map_road.destroy\n\n respond_to do |format|\n format.html { redirect_to mini_map_roads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ipc_seat.destroy\n respond_to do |format|\n format.html { redirect_to ipc_seats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student_regedship = StudentRegedship.find(params[:id])\n @student_regedship.destroy\n\n respond_to do |format|\n format.html { redirect_to(student_regedships_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @committees_voivodeship = CommitteesVoivodeship.find(params[:id])\n @committees_voivodeship.destroy\n\n respond_to do |format|\n format.html { redirect_to committees_voivodeships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendship = Friendship.find(params[:id])\n @friendship.destroy\n\n respond_to do |format|\n format.html { redirect_to friendships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gid2name = Gid2name.find(params[:id])\n @gid2name.destroy\n\n respond_to do |format|\n format.html { redirect_to gid2names_url }\n format.json { head :no_content }\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 @replyship = Replyship.find(params[:id])\n @replyship.destroy\n\n respond_to do |format|\n format.html { redirect_to(replyships_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @server = Server.find(params[:id])\n checkaccountobject(\"servers\",@server)\n @server.send_delete\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @mentorship = Mentorship.find(params[:id])\n @mentorship.destroy\n\n respond_to do |format|\n format.html { redirect_to mentorships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @memeber_ship = MemeberShip.find(params[:id])\n @memeber_ship.destroy\n\n respond_to do |format|\n format.html { redirect_to(memeber_ships_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @championship.destroy\n\n head :no_content\n end",
"def destroy\n @voivodeship = Voivodeship.find(params[:id])\n @voivodeship.destroy\n\n respond_to do |format|\n format.html { redirect_to voivodeships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gossip = Gossip.find(params[:id])\n @gossip.destroy\n\n respond_to do |format|\n format.html { redirect_to gossips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @interno_unidad.destroy\n respond_to do |format|\n format.html { redirect_to interno_unidads_url, notice: 'Interno unidad 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 destroy\n @island = Island.find(params[:id])\n @island.destroy\n\n respond_to do |format|\n format.html { redirect_to islands_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @egreso_interno.destroy\n respond_to do |format|\n format.html { redirect_to egreso_internos_url, notice: 'Egreso interno was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Company.delete(params[\"id\"])\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @kojenadults_classe_ship = KojenadultsClasseShip.find(params[:id])\n @kojenadults_classe_ship.destroy\n\n respond_to do |format|\n format.html { redirect_to(kojenadults_classe_ships_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ambassadorship.destroy\n @ambassadorship = Ambassadorship.new(area: @ambassadorship.area)\n respond_to do |format|\n format.html { redirect_to ambassadorships_url, notice: t('.notice') }\n format.json { head :no_content }\n format.js { render :destroy }\n end\n end",
"def destroy\n @ship_methods = ShipMethods.find(params[:id])\n @ship_methods.destroy\n\n respond_to do |format|\n format.html { redirect_to(ship_methods_url) }\n format.xml { head :ok }\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 @stable = Stable.find(params[:id])\n @stable.destroy\n\n respond_to do |format|\n format.html { redirect_to stables_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @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 destroy\n @recipy = Recipy.find(params[:id])\n @recipy.destroy\n\n respond_to do |format|\n format.html { redirect_to recipies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game_server = Game::Server.find(params[:id])\n @game_server.destroy\n\n respond_to do |format|\n format.html { redirect_to game_servers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @occupant = Occupant.find(params[:id])\n @occupant.destroy\n\n respond_to do |format|\n format.html { redirect_to occupants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @county = County.find(params[:id])\n @county.destroy\n\n respond_to do |format|\n format.html { redirect_to counties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @neighborhood = Neighborhood.find(params[:id])\n @neighborhood.destroy\n\n respond_to do |format|\n format.html { redirect_to neighborhoods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @neighborhood = Neighborhood.find(params[:id])\n @neighborhood.destroy\n\n respond_to do |format|\n format.html { redirect_to neighborhoods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shichoson = Shichoson.find(params[:id])\n @shichoson.destroy\n\n respond_to do |format|\n format.html { redirect_to shichosons_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n WasabbiModship.transaction do\n @wasabbi_modship = WasabbiModship.find(params[:id])\n @wasabbi_modship.destroy\n\n respond_to do |format|\n format.html { redirect_to(wasabbi_modships_url) }\n format.xml { head :ok }\n end\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 @before_intership = BeforeIntership.find(params[:id])\n @before_intership.destroy\n\n respond_to do |format|\n format.html { redirect_to before_interships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community_health_station = CommunityHealthStation.find(params[:id])\n @community_health_station.destroy\n\n respond_to do |format|\n format.html { redirect_to community_health_stations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @warrior = Warrior.find(params[:id])\n @warrior.destroy\n\n respond_to do |format|\n format.html { redirect_to warriors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authenticate_user!\n @server = Server.find(params[:id])\n @server.destroy\n\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server_info = ServerInfo.find(params[:id])\n @server_info.destroy\n\n respond_to do |format|\n format.html { redirect_to server_infos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @neighbour.destroy\n respond_to do |format|\n format.html { redirect_to neighbours_url, notice: 'Neighbour was successfully destroyed.' }\n format.json { head :no_content }\n end\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 @warrior = Warrior.find(params[:id])\n @warrior.destroy\n respond_to do |format|\n format.html { redirect_to warriors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @neighbourhood.destroy\n respond_to do |format|\n format.html { redirect_to neighbourhoods_url, notice: 'Neighbourhood was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shard = Shard.find(params[:id])\n @shard.destroy\n\n respond_to do |format|\n format.html { redirect_to shards_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student_cell_leader = StudentCellLeader.find(params[:id])\n @student_cell_leader.destroy\n\n respond_to do |format|\n format.html { redirect_to student_cell_leaders_url }\n format.json { head :no_content }\n end\n end",
"def delete!\n server.delete(name)\n end",
"def destroy\n @climb = Climb.find(params[:id])\n @climb.destroy\n\n respond_to do |format|\n format.html { redirect_to climbs_url }\n format.json { head :no_content }\n end\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 @instagrampic.destroy\n respond_to do |format|\n format.html { redirect_to instagrampics_url, notice: 'Instagrampic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @serverroom = Serverroom.find(params[:id])\n @serverroom.destroy\n\n respond_to do |format|\n format.html { redirect_to serverrooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @orphan_sponsorship.destroy\n respond_to do |format|\n format.html { redirect_to orphan_sponsorships_url, notice: 'Orphan sponsorship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.78914624",
"0.7535926",
"0.7308347",
"0.71867704",
"0.71607774",
"0.70696986",
"0.7039584",
"0.69174975",
"0.67235",
"0.6676366",
"0.66549057",
"0.65720695",
"0.6568648",
"0.65589327",
"0.65444845",
"0.65444845",
"0.6520607",
"0.6461024",
"0.64312166",
"0.64290196",
"0.6422782",
"0.63944817",
"0.6393635",
"0.63863575",
"0.638281",
"0.6378735",
"0.6352745",
"0.63476604",
"0.6337143",
"0.63309515",
"0.63123983",
"0.63099587",
"0.62864554",
"0.6279348",
"0.62537485",
"0.6249405",
"0.6247823",
"0.6244832",
"0.62438196",
"0.62432694",
"0.6232007",
"0.6227975",
"0.6223331",
"0.6217158",
"0.62133414",
"0.62131083",
"0.6212263",
"0.6209703",
"0.620694",
"0.6201318",
"0.6197599",
"0.61949736",
"0.61923474",
"0.6189076",
"0.6186359",
"0.61786497",
"0.61769295",
"0.61739403",
"0.61699355",
"0.61691046",
"0.61596215",
"0.6157244",
"0.61453927",
"0.61438876",
"0.6141459",
"0.6133519",
"0.6133492",
"0.612598",
"0.6114421",
"0.6103944",
"0.6097729",
"0.6096295",
"0.60850716",
"0.60825145",
"0.6078281",
"0.6076621",
"0.6076621",
"0.6076459",
"0.6072907",
"0.60700506",
"0.6070047",
"0.60672355",
"0.6066338",
"0.605993",
"0.60551053",
"0.6051065",
"0.60509866",
"0.6050911",
"0.60432965",
"0.604087",
"0.6040314",
"0.60330194",
"0.60323423",
"0.6030448",
"0.60270363",
"0.60246384",
"0.6021766",
"0.6012603"
] | 0.789848 | 2 |
TODO: Check whether this can be deleted | def hydra
Restulicious.config.hydra
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n \n end",
"def delete\n # TODO: implement delete\n end",
"def deletedaysedit\n end",
"def delete\n \n end",
"def delete_operations; end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n raise NotImplementedError\n end",
"def delete; raise ActiveRecord::ReadOnlyRecord; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def delete\n raise NotImplementedError\n end",
"def delete\n raise NotImplementedError\n end",
"def delete\n raise NotImplementedError\n end",
"def delete\n\n end",
"def delete_last()\n \n end",
"def deleted?\n false\n end",
"def deleted(build)\n end",
"def delete\n\n\tend",
"def deleted?\n end",
"def deleted?\n end",
"def before_destroy; raise ActiveRecord::ReadOnlyRecord; end",
"def destroy\n \n end",
"def destroy\n \n end",
"def remove\r\n self.update(deleted: true)\r\n end",
"def deleted(item)\n end",
"def delete_blocked\n end",
"def delete_front()\n \n end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def after_soft_delete; end",
"def delete\n\t\tfalse\n\tend",
"def destroy; delete end",
"def remove!; end",
"def deleted\n @is_deleted = true\n end",
"def ensure_deletion_fixes \n # TO DO\n end",
"def delete(object); end",
"def delete\n NotImplemented\n end",
"def delete\n NotImplemented\n end",
"def delete_snat\n super\n end",
"def delete(obj) ; end",
"def delete\n raise ActiveRecord::ReadOnlyRecord\n end",
"def delete\n raise ActiveRecord::ReadOnlyRecord\n end",
"def delete\n raise ActiveRecord::ReadOnlyRecord\n end",
"def delete\n deleted\n save\n end",
"def delete(name); end",
"def delete(name); end",
"def deleted\n @changed = true\n @deleted = true\n end",
"def destroy \n\t\traise 'This feature is not supported'\n\tend",
"def delete\n return false\n end",
"def destroy!; end",
"def destroy\r\n\r\n end",
"def destroy \n \n end",
"def deleted?\n deleted == true\n end",
"def deleted?\n deleted == true\n end",
"def del\n delete\n end",
"def delete(name)\n\n end",
"def delete_local\n super\n end",
"def delete!\n deleted\n save!\n end",
"def delete\n @one.info\n @one.delete\n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def destroy\n\t\t\n\tend",
"def delete(value)\n end",
"def delete(value)\n end",
"def delete\n ret_val = error_if_exists('delete')\n super if ret_val\n return ret_val\n end",
"def delete!\n clear!\n delete\n end",
"def delete\n data.delete( self ); self\n end",
"def destroy \r\n\r\n end",
"def flag_as_deleted!\n set(:deleted, true)\n end",
"def delete\n before_delete\n this.delete\n self\n end",
"def deleted; status[:deleted]; end",
"def destroy\n raise ActiveRecord::ReadOnlyRecord\n end",
"def destroy\r\n end",
"def before_destroy\n raise ActiveRecord::ReadOnlyRecord\n end",
"def before_destroy\n raise ActiveRecord::ReadOnlyRecord\n end",
"def deleted?\n @deleted == true\n end",
"def destroy\n result = nil\n obj = self.inst_strip_braces(self.object)\n if obj\n # first delete the record from viewable list\n result = Rhom::RhomDbAdapter::delete_from_table(Rhom::TABLE_NAME,\n {\"object\"=>obj})\n # now add delete operation\n result = Rhom::RhomDbAdapter::insert_into_table(Rhom::TABLE_NAME,\n {\"source_id\"=>self.get_inst_source_id,\n \"object\"=>obj,\n \"update_type\"=>'delete'})\n end\n result\n end"
] | [
"0.7630774",
"0.7286127",
"0.7017122",
"0.6984595",
"0.69741404",
"0.69398296",
"0.6926708",
"0.6914731",
"0.69043946",
"0.69043946",
"0.69043946",
"0.69043946",
"0.69043946",
"0.69043946",
"0.69043946",
"0.688594",
"0.68819296",
"0.68800443",
"0.68800443",
"0.68800443",
"0.68800443",
"0.6865106",
"0.68505967",
"0.68505967",
"0.68242747",
"0.6745883",
"0.66935307",
"0.6658336",
"0.6646429",
"0.6645869",
"0.6645869",
"0.6623685",
"0.6564096",
"0.6564096",
"0.6549992",
"0.6535572",
"0.65316254",
"0.64877814",
"0.648577",
"0.648577",
"0.648577",
"0.648577",
"0.648577",
"0.648577",
"0.648577",
"0.648577",
"0.648577",
"0.648577",
"0.646519",
"0.6464365",
"0.64607614",
"0.642847",
"0.64260525",
"0.6416008",
"0.64126086",
"0.63668686",
"0.63668686",
"0.6356588",
"0.6355493",
"0.63497204",
"0.63497204",
"0.63497204",
"0.6348952",
"0.63408583",
"0.63408583",
"0.63319176",
"0.6330581",
"0.6315154",
"0.6306137",
"0.62953395",
"0.628358",
"0.62824744",
"0.62824744",
"0.6272862",
"0.6266705",
"0.62654805",
"0.6249119",
"0.6247351",
"0.6242312",
"0.6242312",
"0.6242312",
"0.6242312",
"0.6242312",
"0.6242312",
"0.6242312",
"0.6241088",
"0.62409776",
"0.62409776",
"0.6231786",
"0.62230784",
"0.6216082",
"0.62065583",
"0.6205247",
"0.6198167",
"0.6179118",
"0.61708355",
"0.6165234",
"0.6161028",
"0.6161028",
"0.6160808",
"0.61607647"
] | 0.0 | -1 |
join all the rows separated by newlines | def to_s
@image.map { |row| row.join }.join("\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_cr\n self.compact.reject { |element| element.to_s.empty? || element.to_s.strip == \"\\n\" }.join(\"\\n\")\n end",
"def csv(rows)\n rows.map { |r| r.join(';') }.join(\"\\n\")\n end",
"def join_lines\n\t\toutput = []\n\t\tn = 0\n\t\twhile n < @lines.length do\n\t\t\tcur_line = n \n\t\t\tlonger_line = String.new;\n\t\t\t\n\t\t\tif @lines[cur_line].text[-1] == '\\\\'\n\t\t\t\tlonger_line = @lines[cur_line].text.chop()\n\t\t\t\tcur_line += 1\n\t\t\t\tlonger_line += @lines[cur_line].text\n\t\t\t\tlonger_line.chop!() if longer_line[-1] == '\\\\'\n\t\t\tend\n\t\t\twhile @lines[cur_line].text[-1] == '\\\\'\n\t\t\t\tcur_line += 1\n\t\t\t\tlonger_line += @lines[cur_line].text[0..-2]\n\t\t\tend\n\t\t\t\n\t\t\t# if there were joined lines\n\t\t\tif n < cur_line\n\t\t\t\t@lines[n].text = longer_line\n\t\t\t\t\n\t\t\t\t# catch up\n\t\t\t\twhile n < cur_line\n\t\t\t\t\tn += 1\n\t\t\t\t\t@lines[n].text = nil\n\t\t\t\tend\n\t\t\tend\n\t\t\tn += 1\n\t\tend\n\tend",
"def to_s\n # @rows.join(\"\\n\")\n end",
"def to_s\n rows.empty? ? '' : rows.collect { |row| row_output_string(row) }.join(\"\\n\")\n end",
"def to_s\n [@rows.collect { |row| row.inspect }].join(\"\\n\")\n end",
"def row_join_string\n @row_join_string ||= \" \"\n end",
"def join\n a = []\n each{|s| a << s}\n a.join\n end",
"def to_s\n self.to_a.map{ |row| row.join(' ') }.join(\"\\n\")\n end",
"def joinlines(lines)\n lines.is_a?(Array) ? lines.join : lines\n end",
"def map_join(list, *opts, &block)\n options = opts.extract_options!\n if options[:nowrap]\n options[:surround] = [raw('<span style=\"white-space: nowrap;\">'), raw(''), raw('</span> ')]\n end\n separator = options[:separator] || opts[0] || raw(options[:surround] ? ',' : ', ')\n last_separator = options[:last_separator] || opts[1] || separator\n\n results = list.map &block\n case results.length\n when 0 then ''\n when 1 then results[0]\n else\n # Array#join doesn't support html_safe => concatenate with inject\n if options[:surround]\n s1,s2,s3 = options[:surround]\n s1 + results[0..-2].inject { |a,b| a.to_s + s2 + separator + s3 + s1 + b.to_s } +\n s2 + last_separator + s3 + results.last\n else\n results[0..-2].inject {|a,b| a.to_s + separator + b.to_s } + last_separator + results.last\n end\n end\n end",
"def my_join(separator = \"\")\n ret = \"\"\n each_with_index do |el, i|\n if i == count - 1\n ret << el\n else\n ret << el + separator\n end\n end\n ret\n end",
"def unlines\n join $RS\n end",
"def to_s(sep=\"\\t\")\n map do |row|\n row.join(sep)\n end.join(\"\\n\")\n end",
"def display\n array = stringify_rows\n print_line_seperator\n array.each do |row|\n puts \"|\" << row.join( \"|\" ) << \"|\"\n print_line_seperator\n end\nend",
"def wrapped\n @lines.join(\"\\n\")\n end",
"def to_s\n @lines.map { |line| line.to_s }.join(\"\\n\") \n end",
"def full_text_string_join(cols)\n cols = Array(cols).map{|x| SQL::Function.new(:COALESCE, x, '')}\n cols = cols.zip([' '] * cols.length).flatten\n cols.pop\n SQL::StringExpression.new(:'||', *cols)\n end",
"def to_s\n lines.join(\"\\n\")\n end",
"def my_join(separator = '')\n out_str = ''\n each do |x|\n out_str << x\n out_str << separator\n end\n out_str[0..-1 * separator.length]\n end",
"def my_join(sep='')\n str = ''\n self.each_with_index do |ele, i|\n if i == self.length-1\n str += ele \n else\n str += ele + sep\n end\n end\n str\n end",
"def join_nested_strings(src)\n row_index = 0\n string_data = [ ]\n while row_index < src.length do\n grab_string = src[row_index].grep(String)\n string_data.push(grab_string)\n row_index += 1 \n end\n string_data.join(\" \")\nend",
"def format_row(data)\n data.join(col_sep * 2) + row_sep\n end",
"def generate_row(row)\n '|' + \"#{(row.map {|x| generate_item(x)}).join('|')}\\n\"\n end",
"def to_s\n @chars.map { |row| row.join }.join(\"\\n\")\n end",
"def my_join(arr, separator = \"\")\n result = \"\"\n (0...arr.length).each do |idx|\n if idx != arr.length - 1\n result << arr[idx] << separator\n else\n result << arr[idx]\n end\n end\n\n return result\n\nend",
"def to_s\n join(\"\\n\")\n end",
"def try_join_arr(val)\n val.join(\"\\n\") rescue val\n end",
"def to_csv\n self.find.map {|row| row.join(',')}.join(\"\\n\")\n end",
"def convertFinalArrayToString\n string = \"\"\n @arrayOfElements.each { |row| \n rowString = \"\"\n row.each { |word|\n if \"\" == rowString\n rowString = rowString + word\n else\n rowString = rowString + \" \" + word\n end\n }\n if \"\" == string\n string = rowString\n else\n string = string + \"\\n\" + rowString\n end\n }\n return string\nend",
"def csv_multi_replacements\n [\n [/\\n\\n/ , \"\\n\"]\n ]\n end",
"def to_csv\n map {|row|\n row.map {|f|\n f =~ /[[:punct:]]/ ? '\"' + f.gsub(/\"/, '\"\"') + '\"' : f }.\n join(\",\")}.\n join(\"\\n\")\n end",
"def to_csv\n str = ''\n str << ( columns.join(\",\") + \"\\n\" )\n rows.each { |row|\n next if is_hr(row) || !row_visible(row)\n str << ( row.map{|x|\n x = x.to_s\n x.gsub(/[\\r\\n]/, ' ').gsub(/\\s+/, ' ').gsub('\"', '\"\"')\n }.map{|x| \"\\\"#{x}\\\"\" }.join(\",\") + \"\\n\" )\n }\n str\n end",
"def join(separator = $OFS)\n '' + _join(separator)\n end",
"def raw\n @lines.map(&:line).join(\"\\n\") << \"\\n\"\n end",
"def to_s\n @out.join\n end",
"def to_html\n map(&:to_html).join('</br>')\n end",
"def to_s\n @matrix.inject('') do |combined_rows, row|\n formatted_row =\n row.inject('') { |combined_cells, cell| \"#{combined_cells} #{cell}\" }\n \"#{combined_rows}\\n#{formatted_row}\"\n end\n end",
"def to_s\n join\n end",
"def to_s\n return if empty?\n result = []\n each do |item|\n result << item\n end\n result.join(\"\\n\")\n end",
"def question_join\n strings_joined = @data.map do |question|\n question.join(' ')\n end\n @data = strings_joined\n end",
"def to_s\n to_data.map(&:to_s).join(\"\\n\")\n end",
"def my_join(arr, separator = \"\")\n result = \"\"\n arr.each_index do |index|\n if index != arr.length-1\n result += (arr[index] + separator)\n else\n result += arr[index]\n end\n end\n result\nend",
"def generate_row(row)\n (row.map {|x| generate_item(x)}).join\n end",
"def join(array, delimiter = \"\")\n result = \"\"\n i = 1\n array.each do |item|\n result += item.to_s\n unless i == array.length\n result += delimiter\n end\n i += 1\n end\n result\nend",
"def all\n @contents.flatten.join\n end",
"def join(separator = T.unsafe(nil)); end",
"def custom_join(array, delimiter = \"\")\r\n array.join(delimiter)\r\nend",
"def to_s\n str = \"\"\n count_row = 0\n count_col = 0\n str << \"-\"*25 << \"\\n\"\n rows.each do |row|\n row.each do |ele|\n str << ele.to_s << \" \"\n count_col += 1\n if count_col == 3\n str << \"| \"\n count_col = 0\n end\n end\n count_row += 1\n if count_row == 3\n str << \"\\n\" << \"-\"*25 << \"\\n\"\n count_row = 0\n else\n str << \"\\n\"\n end\n end\n str << \"-\"*25\n end",
"def to_line_string lr\n str = lr.from.line.to_s.dup\n if lr.from.line != lr.to.line\n str << \",\" << lr.to.line.to_s\n end\n str\n end",
"def convert_to_string\n @data.join(\"\\n\")\n end",
"def join(separator = $,)\n result = \"\"\n if separator\n each_with_index { |obj, i| result << separator if i > 0; result << obj.to_s }\n else\n each { |obj| result << obj.to_s }\n end\n result\n end",
"def to_s\n self.join\n end",
"def raw\n @lines.map(&:first).join(\"\\n\") + \"\\n\"\n end",
"def join_rows(rows)\n return @join_rows if defined? @join_rows\n\n conn = @model.connection\n join_table = conn.quote_table_name @ref.join_table\n assoc_fkey = conn.quote_column_name @ref.association_foreign_key\n fkey = conn.quote_column_name @ref.foreign_key\n quoted_ids = rows.map { |r| conn.quote r.send @ref.active_record_primary_key }\n\n @join_rows = conn.\n exec_query(\"SELECT #{fkey}, #{assoc_fkey} FROM #{join_table} WHERE #{fkey} IN (#{quoted_ids.join ','})\").\n rows\n end",
"def __joinStrings\n # called from generated code\n str = ''\n n = 0\n siz = self.__size\n while n < siz\n str << self.__at(n).to_s\n n += 1\n end\n str\n end",
"def to_s\n @data.map(&:to_s).join(\"\\n\")\n end",
"def row_to_s(row) # :nodoc:\n line = ' ' * indent\n last_cell = nil\n last_idx = nil\n row.each_with_index { |cell, idx|\n if (idx != 0)\n line << pad(' ', last_cell.to_s, last_idx)\n end\n # Limit wide cells\n if colprops[idx]['MaxChar']\n last_cell = cell.to_s[0..colprops[idx]['MaxChar'].to_i]\n line << style_table_field(last_cell, idx)\n else\n line << style_table_field(cell.to_s, idx)\n last_cell = cell\n end\n last_idx = idx\n }\n\n return line + \"\\n\"\n end",
"def to_s\n data.map { |ar| ar.map { |v| v.to_s.gsub(/\\t|\\n|\\r/,' ') }.join \"\\t\" }.join( $/ )\n end",
"def my_join(arr, separator = \"\")\n join = \"\"\n idx = 0\n while idx < arr.length\n join = join + arr[idx]\n if idx != arr.length - 1 # Don't want to add the separator after the last element\n join = join + separator\n end\n idx = idx + 1\n end\n join\nend",
"def fn_join(separator, lines)\n {\n \"Fn::Join\" => [\n separator, lines\n ]\n }\n end",
"def plain_source\n lines.join\n end",
"def custom_join(array, delimiter = \"\")\r\n string = \"\"\r\n last_index = array.length - 1\r\n array.each_with_index do |elem, index|\r\n string << elem\r\n string << delimiter unless index == last_index\r\n end\r\n string\r\nend",
"def my_join(arr, separator = \"\")\n result = \"\"\n arr.each_with_index do |ele, idx|\n idx < arr.size - 1 ? result += (ele + separator) : result += ele\n end\n result\nend",
"def line_break\n append '(?:\\n|(?:\\r\\n))'\n end",
"def csv_from_row(op, row)\n res = \"\"\n until row.empty?\n entry = row.shift.to_s\n if /[,\"]/ =~ entry\n entry = entry.gsub(/\"/, '\"\"')\n res << '\"' << entry << '\"'\n else\n res << entry\n end\n res << \",\" unless row.empty?\n end\n op << res << CRLF\nend",
"def my_join(array, separator)\n\tarray_string = \" \"\n\tarray.each{ |a| array_string << a + separator }\n\treturn array_string\nend",
"def my_join(arr, separator=\"\")\r\n # your code goes here\r\n my_join = \"\"\r\n\r\n i=0\r\n while i<arr.length\r\n if i < arr.length - 1\r\n my_join += arr[i] + separator\r\n else\r\n my_join += arr[i]\r\n end\r\n i+=1\r\n end\r\n my_join\r\nend",
"def to_s\n @out.join\n end",
"def plain_source\n lines.join\n end",
"def my_join(arr, separator = \"\")\nr = \"\"\narr.each_with_index { |c, i| r += separator if i != 0; r += c.to_s }\nr\nend",
"def serialize(row)\n row\n .map { |c| db_format(c) }\n .join(\",\")\nend",
"def build_table_body\n data.each_with_index do |row, i|\n output << \",\\n\" if i > 0 \n build_row(row)\n end\n output << \"\\n\"\n end",
"def fancy_newline\n @results += '|'\n newline\n end",
"def join(separator=nil)\n to_a.join(separator)\n end",
"def address_lines(join_chars = ', ')\n address_lines_array.join(join_chars)\n end",
"def address_lines(join_chars = ', ')\n address_lines_array.join(join_chars)\n end",
"def newline\n @results += nl\n end",
"def combineLines(theLines)\n\n\ttheText = \"\";\n\t\n\ttheLines.each do |theLine|\n\t\ttheText += theLine[:text] + theLine[:comment] + \"\\n\";\n\tend\n\n\treturn theText;\n\nend",
"def join_nested_strings(src)\n # src will be an Array of Arrays of Strings and Integers\n # Combine all Strings present in the AoA into a single value and return it\n result = \"\"\n \n # loop over outer array\n row_index = 0\n while row_index < src.count do\n \n # loop over inner array\n element_index = 0\n while element_index < src[row_index].count do\n element = src[row_index][element_index]\n if element.is_a? String\n result += element + \" \"\n end\n \n # do something with each element of the inner array\n element_index += 1\n end\n\n row_index += 1\n end\n\n # return \"The brown fox ... \"\n result\nend",
"def to_s\n \"Row #{@line}\"\n end",
"def to_s\n \"Matrix[\" + @rows.collect{\n |row|\n \"[\" + row.collect{|e| e.to_s}.join(\", \") + \"]\" # no yield\n }.join(\", \")+\"]\"\n end",
"def all_text\r\n @texts.inject(\"\") {|r, text| r += text + \"\\n\" }\r\n end",
"def rows_as_char_arrays(text)\n rows = text.split(\"\\n\")\n\n max_length = rows.map(&:length).max\n\n rows.map do |row|\n # add padding to fix row length if necessary\n row += ' ' * (max_length - row.length)\n row.chars\n end\n end",
"def fill_row(row)\n \" #{row[0]} | #{row[1]} | #{row[2]} \\n\"\nend",
"def join\n str = @feedback.join(@separator)\n str << @separator.strip if @trailing_separator\n str\n end",
"def join_repeats(hash)\n\t\t\t\thash.each do |key,val|\n\t\t\t\t\tif val.kind_of? Array\n\t\t\t\t\t\thash[key] = val.join('\\x1D')\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\thash\n\t\t\tend",
"def to_s\n to_a.join(\"\\n\")\n end",
"def my_join(spacer = '')\n str = ''\n\n self.each_with_index do |char, idx|\n str += char\n str += spacer if idx != self.length - 1\n end\n\n str\n end",
"def to_s\n statements.collect { |s| s.to_s }.join(\";\\n\")\n end",
"def join(x, sep = \",\")\n y = []\n x.each do |element|\n y.push element.text\n end\n y.join(sep)\n end",
"def plaintext(delim=\"\\n\")\n @text_blocks.join(delim)\n end",
"def to_s\n to_a.join(\"\\n\")\n end",
"def my_join(arr, separator = \"\")\n return \"\" if arr.empty?\n joined_str = \"\"\n arr[0...-1].each {|elem| joined_str << elem + separator}\n joined_str << arr[-1]\nend",
"def my_join(array, separator)\n\n string = ''\n array.each_with_index do |elem, index|\n if index < array.length - 1\n string << elem + separator\n else\n string << elem\n end\n end\n \n string\nend",
"def matrix_join\n return self.dup if size == 0 # Deal with the trivial case\n normalized_matrixes = self.map{|matrix| matrix.normalize } # Ensure component matrixes are squared up\n row_counts = normalized_matrixes.map {|matrix| matrix.size }\n column_counts = normalized_matrixes.map {|matrix| matrix.row_sizes.max || 0 }\n result_rows = row_counts.max\n padded_matrixes = normalized_matrixes.map.with_index do |matrix, i|\n matrix + [[\"\"]*column_counts[i]]*(result_rows-matrix.size)\n end\n result = []\n result_rows.times do |i|\n joined_row = padded_matrixes.map{|matrix| matrix[i]}.flatten\n result << joined_row\n end\n result\n end",
"def to_s\n string_to_add = \" with cells: \"\n @reconstructed_table.each do |row|\n string_to_add += \"\\n\\t#{row}\"\n end\n super + string_to_add\n end",
"def join_list(delim, list) { :'Fn::Join' => [ delim, list ] } end",
"def join_nested_strings(src)\n words = []\n row_idx = 0\n while row_idx < src.length do\n sub_array = src[row_idx]\n row_idx += 1\n ele_idx = 0\n while ele_idx < sub_array.count do\n ele = sub_array[ele_idx]\n if ele.is_a? String \n words.push(ele)\n end\n ele_idx += 1\n end\n end\n words.join(\" \")\nend",
"def join(sep = $,)\n map(&:to_s).join(sep)\n end",
"def to_text(data)\n data.each{|r| r.each{|c| c[:content].gsub!(/\\r\\n/, ' ') } }\n\n widths = data.collect{|r| r.collect{|c| c[:content].to_s.size } }.transpose.collect{|x| x.max }\n line = '+' + widths.collect{|w| '-'*(w+2)}.join('+') + '+'\n\n rows = data.collect do |r|\n d = []\n \n r.each_with_index do |c, i|\n w = widths[i]\n case c[:align]\n when :right\n d << c[:content].rjust(w, ' ')\n else\n d << c[:content].ljust(w, ' ')\n end\n end\n \n d.join(' | ')\n end.collect{|r| \"| #{r} |\"}\n\n \n rows << line\n rows.insert(1, line)\n rows.insert(0, line)\n\n rows.join(\"\\n\")\n end"
] | [
"0.7148511",
"0.7127152",
"0.6800459",
"0.67851365",
"0.6634408",
"0.6582164",
"0.6520546",
"0.63280714",
"0.62706",
"0.61845845",
"0.60294646",
"0.6021414",
"0.59976083",
"0.5965973",
"0.5934499",
"0.59138894",
"0.5909701",
"0.58726776",
"0.5868856",
"0.5864222",
"0.5846963",
"0.5839856",
"0.5807377",
"0.58032584",
"0.57888",
"0.57554996",
"0.5754628",
"0.57527816",
"0.5748961",
"0.57452494",
"0.57418495",
"0.5733914",
"0.57263887",
"0.5717532",
"0.57139647",
"0.57105124",
"0.56912243",
"0.5683341",
"0.56803185",
"0.5670001",
"0.5667295",
"0.56668645",
"0.5653324",
"0.5652075",
"0.5648884",
"0.564572",
"0.5629232",
"0.56276405",
"0.56271195",
"0.56241125",
"0.5619122",
"0.56177473",
"0.56086904",
"0.5594012",
"0.55885273",
"0.5581816",
"0.5572669",
"0.55686486",
"0.55671597",
"0.5563067",
"0.55513144",
"0.5548891",
"0.55487466",
"0.55470103",
"0.5542154",
"0.5536672",
"0.5525672",
"0.55201733",
"0.5504742",
"0.54838556",
"0.5481556",
"0.5476501",
"0.54762536",
"0.5470922",
"0.5466128",
"0.54612184",
"0.54612184",
"0.5448092",
"0.5445783",
"0.54451543",
"0.5435151",
"0.54326123",
"0.5431188",
"0.54215944",
"0.5399721",
"0.5396142",
"0.5379272",
"0.53771704",
"0.53765106",
"0.53761214",
"0.5368374",
"0.5364626",
"0.53635126",
"0.5358313",
"0.53569317",
"0.5345271",
"0.5341094",
"0.5334819",
"0.5333997",
"0.5330871",
"0.5324781"
] | 0.0 | -1 |
set pixels left, right, up and down of a '1' to 1 unless out of bounds | def blur(distance)
find_ones.each do |one|
spread(one, distance)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_to_one(coords)\n if (0..@max_x).include?(coords[:x]) && (0..@max_y).include?(coords[:y])\n @image[coords[:y]][coords[:x]] = 1\n end\n end",
"def set_one(row,col)\n\t\tpixels[row][col] = 1\n\tend",
"def count_left(x, y)\n if x - 1 < 0\n return 0\n end\n return $canvas[x - 1][y] == 1 ? 1 : 0\nend",
"def left_cell_x_at(x); x / WIDTH; end",
"def right_cell_x_at(x); (x + WIDTH - 1) / WIDTH; end",
"def x1\n {left: 0, right: Pong::WIDTH - WIDTH}[side]\n end",
"def count_up(x, y)\n if y + 1 >= $height\n return 0\n end\n return $canvas[x][y + 1] == 1 ? 1 : 0\nend",
"def count_right(x, y)\n if x + 1 >= $width\n return 0\n end\n return $canvas[x + 1][y] == 1 ? 1 : 0\nend",
"def north(i=@cursor) i-width end",
"def fix_floor(state)\n for i in 0..(state[state.length - 1].length - 1) do\n state[state.length - 1][i] = 1\n end\nend",
"def set_at(x, y)\n self.x = x\n self.x = 0 if x < 0\n self.y = y\n if x + self.width > 640\n self.x -= (x + self.width - 640)\n end\n if y + self.height > 480\n self.y -= (y + self.height - 480)\n end\n end",
"def check_bounds\n\t\tif @x + SUB_TILE_WIDTH > @game_state.width\n\t\t\tupdate_x( -(@x + SUB_TILE_WIDTH - @game_state.width) )\n\t\telsif @x < 0\n\t\t\tupdate_x( @x.abs )\n\t\tend\n\t\tif @y + SUB_TILE_HEIGHT > @game_state.height\n\t\t\tupdate_y( -(@y + SUB_TILE_HEIGHT - @game_state.height) )\n\t\telsif @y < 0\n\t\t\tupdate_y( @y.abs )\n\t\tend\n\tend",
"def ox=(val)\n @sprite.ox = (val % (@bitmap.nil? ? 1 : @bitmap.width))\n end",
"def pixel_x; @x / PIXEL_WIDTH; end",
"def pixel_x; @x / PIXEL_WIDTH; end",
"def coord_to_pos(row,col)\n return nil if row.even? && col.even? || row.odd? && col.odd? #these are always empty squares in checkers!\n return row*4+(col/2).floor+1\n end",
"def check_limits_on_x_and_y\n\t\tself.x = self.window.limit_max_x if x > self.window.limit_max_x \n\t\tself.y = self.window.limit_min_y if y > self.window.limit_max_y \n\tend",
"def snap_offset\n @y += @off_y / 32\n @x += @off_x / 32\n @real_x = @x * 128\n @real_y = @y * 128\n @off_y = 0#@off_y % 32\n @off_x = 0#@off_x % 32\n end",
"def fix_value( val )\n Pos.abs( ( @container.pos.x! + val.x! ), ( @container.pos.y! + val.y! ) )\n end",
"def count_down(x, y)\n if y - 1 < 0\n return 0\n end\n return $canvas[x][y - 1] == 1 ? 1 : 0\nend",
"def position(val)\n @inside = true\n return val if (low..high).cover? val\n @inside = false\n return constrain(val, low, high)\n end",
"def out_of_bounds?(x, y)\n x < 0 || y < 0 || x > @width - 1 || y > @height - 1\n end",
"def bound_x (x)\n if x == @world.width\n return 0\n elsif x == -1\n return (@world.width - 1)\n else\n return x\n end\n end",
"def rect(col, row)\n row.times do |row_index|\n col.times do |col_index|\n @data[row_index][col_index] = true\n end\n end\n end",
"def check_range(x, y)\n !(x < 1 || y < 1 || x > width || y > height)\n end",
"def controlled_square(_)\n ([-1, 1, 0].product([-1, 1, 0]) - [[0, 0]])\n .map { |mod| [@position[0] + mod[0], @position[1] + mod[1]] }\n .select { |i| Helper::in_border?(*i) }\n end",
"def restricted?(x, y)\n out_of_bounds?(x, y) || @image.color(x, y) == 0\n end",
"def rectified_liniar_unit(x)\n\t\tx > 0 ? x : 0.0\n\tend",
"def bottom!\n self.ox = self.width/2\n self.oy = self.height\n end",
"def up\n @y.positive? ? $theGrid[@y-1][@x] : nil\n end",
"def test_alignLeft\n [@window, @sprite, @bitmap].each{|container|\n uc = UCNumericUpDown.new(container, Rect.new(0, 72, @window.contents.width, 24), 5, nil, 0, 99, 1, 0)\n uc.draw()\n }\n return true\n end",
"def blur!\r\n ones = get_ones\r\n ones.each do |found_row_number, found_col_number| \r\n @picture[found_row_number -1][found_col_number] = 1 unless found_row_number == 0 #up\r\n @picture[found_row_number +1][found_col_number] = 1 unless found_row_number == @picture.length-1 #down\r\n @picture[found_row_number][found_col_number -1] = 1 unless found_col_number == 0 #left\r\n @picture[found_row_number][found_col_number +1] = 1 unless found_col_number == @picture[found_row_number].length-1 #right\r\n end\r\n end",
"def safe_position?(x, y)\n x >= 0 &&\n x <= 4 &&\n y >= 0 &&\n y <= 4\n end",
"def update_canvas()\n for x in 0...$width\n for y in 0...$height\n \n neighbor_count = count_neighbors(x, y)\n\n if $canvas[x][y] == 1\n if neighbor_count < 2 or neighbor_count > 3\n $canvas[x][y] = 0\n end\n else\n if neighbor_count == 3\n $canvas[x][y] = 1\n end\n end\n end\n end\nend",
"def wrap\n max_h, max_w = w.h, w.w\n\n self.x = max_w if x < 0\n self.y = max_h if y < 0\n\n self.x = 0 if x > max_w\n self.y = 0 if y > max_h\n end",
"def move_west\n @x -= 1\n end",
"def space(x,y)\n return nil if x < 0\n return nil if y < 0\n return nil if x >= @width\n return nil if y >= @height\n @grid[y][x]\n end",
"def leaky_rectified_liniar_unit(x)\n\t\tx > 0 ? x : (x / 5.0)\n\tend",
"def set_direction(value)\n value = validate_direction(value)\n @sprite.src_rect.y = @sprite.src_rect.height * (value / 2 - 1)\n @sprite.src_rect.x += @sprite.src_rect.width\n if @turncount\n @sprite.src_rect.x = 0 if @sprite.src_rect.x >= @sprite.bitmap.width\n @sprite.src_rect.x += @sprite.src_rect.width\n @sprite.src_rect.x = 0 if @sprite.src_rect.x >= @sprite.bitmap.width\n end\n @turncount = 6\n end",
"def bounds_check\n r,c = rowcol\n @current_index = 0 if @current_index < 0\n @current_index = @content_rows-1 if @current_index > @content_rows-1\n #$status_message.value = \"visible #{@prow} , #{@current_index} \"\n unless is_visible? @current_index\n if @prow > @current_index\n #$status_message.value = \"1 #{@prow} > #{@current_index} \"\n @prow -= 1\n else\n end\n end\n #end\n check_prow\n #$log.debug \"XXX: PAD BOUNDS ci:#{@current_index} , old #{@oldrow},pr #{@prow}, max #{@maxrow} pcol #{@pcol} maxcol #{@maxcol}\"\n @crow = @current_index + r - @prow\n @crow = r if @crow < r\n # 2 depends on whetehr suppressborders\n @crow = @row + @height -2 if @crow >= r + @height -2\n setrowcol @crow, @curpos+c\n lastcurpos @crow, @curpos+c\n if @oldrow != @prow || @oldcol != @pcol\n @repaint_required = true\n end\n end",
"def left\n self.y = ((y-1)+10)%10\n end",
"def index(x, y)\n (y - 1) * width + (x - 1)\n end",
"def []=(position, value)\n if value == 1\n @field[position / ELEMENT_WIDTH] |= 1 << (position % ELEMENT_WIDTH)\n elsif (@field[position / ELEMENT_WIDTH]) & (1 << (position % ELEMENT_WIDTH)) != 0\n @field[position / ELEMENT_WIDTH] ^= 1 << (position % ELEMENT_WIDTH)\n end\n end",
"def off_board(x, y)\n \tif (x < 0 || x > 7 || y < 0 || y > 7)\n \t\treturn true\n \tend\n \treturn false\n end",
"def init_white_panel!\n grid.cells[grid.pos] = 1\n end",
"def can_go_up?(the_maze, floor, position)\r\n (floor - 1 > -1) and (the_maze[floor - 1][position] == \"0\") \r\nend",
"def set_adjacent(pos)\r\n row, col = pos\r\n adjacent_tiles(pos)\r\n adj_left(pos)\r\n adj_right(pos)\r\n adj_up(pos)\r\n adj_down(pos)\r\n end",
"def move_valid?(x, y)\n (0...@width).cover?(x) && (0...@height).cover?(y) && !@visited[x][y]\n end",
"def relative_left_cell\n return left_cell if @facing == 'up'\n return up_cell if @facing == 'right'\n return right_cell if @facing == 'down'\n return down_cell if @facing == 'left'\n end",
"def out_of_bounds?\n (0..@grid_size[0]).cover?(@coordinates[0]) &&\n (0..@grid_size[1]).cover?(@coordinates[1])\nend",
"def calculate_boundaries!\n return unless @dirty\n\n # Init to vals of first point\n # We will do it this way so we only need one iteration\n point = @points.first\n @minx = point.x\n @maxx = point.x\n @miny = point.y\n @maxy = point.y\n @points.each do |point|\n @minx = [@minx, point.x].min\n @maxx = [@maxx, point.x].max\n @miny = [@miny, point.y].min\n @maxy = [@maxy, point.y].max\n end\n @grid_width = @maxx - @minx\n @grid_height = @maxy - @miny\n\n @dirty = false\n end",
"def looping_position_check(bitmap, point1)\n if Looping_Background\n plus_x = (Graphics.width - bitmap.width)/2\n plus_y = (Graphics.height - bitmap.height)/2\n else\n plus_x = Graphics.width / 2\n plus_y = Graphics.height / 2\n end\n if point1\n @point1.set(*initpos_1)\n @point1.x += plus_x\n @point1.y += plus_y\n else\n @point2.set(*initpos_2)\n @point2.x += plus_x\n @point2.y += plus_y\n end\n end",
"def neighUpLeft(cur_row,cur_col)\n if cur_col == 0 || cur_row == 0\n return 0\n else\n neighbor_cell = getCell(cur_row - 1,cur_col - 1)\n if(neighbor_cell.living == true)\n return 1\n else\n return 0\n end\n end # end if statement\n\n end",
"def incrementX\n @currentPos.x += 1\n if @currentPos.x > @grid.maxX\n @currentPos.x = @grid.minX\n end\n end",
"def valid_position?(x, y)\n !!(x && y && x > 0 && y > 0 && x <= 8 && y <= 8)\n end",
"def set_one_pixel(pixelno,r,g,b)\n# puts \"Set one pixel length packetdata in \" + @@packetdata.size.to_s\n pixelno = pixelno % @@numpixels\n if r < 256 then\n temp = [r]\n @@packetdata[pixelno * 3] = temp.pack(\"C\")\n end\n if g < 256 then\n temp = [g]\n @@packetdata[(pixelno * 3) + 1] = temp.pack(\"C\")\n end\n if b < 256 then\n temp = [b]\n @@packetdata[(pixelno * 3) + 2] = temp.pack(\"C\") \n end \nend",
"def out_of_bounds?(x, y)\n x >= (Game::Width - Game::Padding) || x <= (0 + Game::Padding) || y >= (Game::Height - Game::Padding) || y <= (0 + Game::Padding)\n end",
"def adjacent_mines(row, col)\n 0\n end",
"def adjacent_mines(row, col)\n 0\n end",
"def adjacent_mines(row, col)\n 0\n end",
"def logical_pos(x, y)\n [\n (x / @tile_width).floor,\n (y / @tile_height).floor\n ]\n end",
"def adjust_x(x)\n if loop_horizontal? and x < @display_x - @margin_x\n return x - @display_x + @map.width * 256\n else\n return x - @display_x\n end\n end",
"def move_up\n unless @value.eql? 1\n @y -= 50\n @value -= 1\n end\n end",
"def set( x, y, number=nil )\n correct = (0..@size_pow-1).to_a\n if ( correct.include? x ) && ( correct.include? y) then\n @board[x][y] = number\n return true\n else\n puts \"Set error, wrong coordinates!\"\n false\n end\n end",
"def adjacent_mines(row, col)\n count = 0\n if col < @column_count-1\n count+=1 unless @grid[row][col+1].fill.nil?\n end\n if col > 0\n count +=1 unless @grid[row][col-1].fill.nil?\n end\n if row < @row_count-1\n count+=1 unless @grid[row+1][col].fill.nil?\n end\n if row > 0\n count+=1 unless @grid[row-1][col].fill.nil?\n end\n if row < @row_count-1 && col < @column_count-1\n count+=1 unless @grid[row+1][col+1].fill.nil?\n end\n if row > 0 && col > 0\n count+=1 unless @grid[row-1][col-1].fill.nil?\n end\n if row > 0 && col < @column_count-1\n count +=1 unless @grid[row-1][col+1].fill.nil?\n end\n if row < @row_count-1 && col > 0\n count +=1 unless @grid[row+1][col-1].fill.nil?\n end\n count\n end",
"def set_right_start_point\n @leading_x = 0\n @leading_y = find_right_entry\n end",
"def [](position)\n @field[position / ELEMENT_WIDTH] & 1 << (position % ELEMENT_WIDTH) > 0 ? 1 : 0\n end",
"def [](position)\n @field[position / ELEMENT_WIDTH] & 1 << (position % ELEMENT_WIDTH) > 0 ? 1 : 0\n end",
"def cent_x\n self.x + (@width / 2)\n end",
"def transform(row_index,col_index)\n\n if row_index-1 >= 0\n @image[row_index-1][col_index] = 1\n end\n if col_index - 1 >= 0\n @image[row_index][col_index-1] = 1\n end\n if row_index + 1 <= @image.length - 1\n @image[row_index+1][col_index] = 1\n end\n if col_index + 1 <= @image[row_index].length - 1\n @image[row_index][col_index+1] = 1\n end\n\n end",
"def set_left_start_point\n @leading_x = 0\n @leading_y = find_left_entry\n end",
"def left_edge?(row,col)\n\t\tpixels[row][col+1] == nil\n\tend",
"def set_livings_cell\n @board[2][2] = 1\n @board[2][3] = 1\n @board[3][3] = 1\n @board[3][4] = 1\n @board[4][4] = 1\n end",
"def column_next dir=0\n if dir == 0\n $stact += $grows\n $stact = 0 if $stact >= $viewport.size\n else\n $stact -= $grows\n $stact = 0 if $stact < 0\n end\nend",
"def column_next dir=0\n if dir == 0\n $stact += $grows\n $stact = 0 if $stact >= $viewport.size\n else\n $stact -= $grows\n $stact = 0 if $stact < 0\n end\nend",
"def column_next dir=0\n if dir == 0\n $stact += $grows\n $stact = 0 if $stact >= $viewport.size\n else\n $stact -= $grows\n $stact = 0 if $stact < 0\n end\nend",
"def chech_first_corner_edge()\n\t\tposition = 4\n\t\treturn position\n\tend",
"def chech_first_corner_edge()\n\t\tposition = 4\n\t\treturn position\n\tend",
"def offset_x_position(offset)\n offset = offset % 32\n return if offset <= 0\n \n change = 1.0 / 32.0 * offset\n @x = @x.floor + change\n end",
"def test_min\n [@window, @sprite, @bitmap].each{|container|\n uc = UCNumericUpDown.new(container, Rect.new(0, 24, 100, 24), 0, nil, -1000)\n uc.draw()\n }\n return true\n end",
"def x_coord(num)\n x = num%65536\n x -= 65536 if x > 32768\n x\nend",
"def legal_red_move(start_x, start_y, x, y, board)\n y + 1 == start_y && (x - 1 == start_x || x + 1 == start_x) && board[y][x] == 0\n end",
"def center(board)\n !board.taken?(5) ? 5 : nil\n end",
"def ox=(ox)\n #\n unless @tilemap_drawn\n @ox = ox\n @ox_oy_set[0] = true\n return\n end\n \n return if @ox == ox\n # Shift all tiles left or right by the difference\n shift = @ox - ox\n \n @tile_sprites.each {|set| set.each{|tile| tile.x += shift }}\n @ox = ox\n # Determine if columns need to be shifted\n col_num = @corner_index\n #return unless @tile_sprites[col_num][0].x <= -49 || @tile_sprites[col_num][0].x >= -17\n while @tile_sprites[col_num][0].x <= -49 || @tile_sprites[col_num][0].x >= -17\n \n @corner_tile_loc[0] += (shift < 0 ? 1 : -1)\n modTileId = ((SCREEN[0]+64)*(SCREEN[1]+64))/1024 \n # If new ox is greater than old ox\n if shift < 0\n # Move all sprites in left column to the right side and change bitmaps\n # and z-values\n (0...(SCREEN[1]/32+2)).each{|n|\n j = ((SCREEN[0]/32+2) * n + col_num) % modTileId\n @tile_sprites[j].each_index{|i|\n tile = @tile_sprites[j][i]\n @animating_tiles.delete(tile.tile_sprite_id)\n tile.x += 64 + SCREEN[0]\n \n map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32\n tile_id = @map_data[map_x,map_y,i]\n \n if tile_id.nil?\n tile.z = [map_y * 32, 0].max\n tile.bitmap = RPG::Cache.picture('')\n tile.src_rect.set(0,0,0,0)\n next\n else\n if @priorities[tile_id] == 0\n tile.z = 0\n else\n tile.z = 32 + (tile.y/32) * 32 + @priorities[tile_id] * 32\n end\n end\n if tile_id == 0\n tile.bitmap = RPG::Cache.picture('')\n tile.src_rect.set(0,0,0,0)\n elsif tile_id >= 384\n tile.bitmap = @tileset\n tile.src_rect.set(((tile_id - 384) % 8) * 32,((tile_id - 384) / 8) *32, 32, 32)\n else\n auto_id = tile_id/48-1\n tile.bitmap = @autotiles[auto_id]\n tile.src_rect.set(((tile_id % 48) % 8)*32 + @current_frame[auto_id] * 256,((tile_id % 48) / 8)*32, 32, 32)\n @animating_tiles[tile.tile_sprite_id] = tile if @total_frames[auto_id] > 1\n end\n }\n }\n # New corner should be the tile immediately right of the previous tile\n col_num /= SCREEN[0]/32+2\n col_num *= SCREEN[0]/32+2\n @corner_index = (@corner_index + 1) % (SCREEN[0]/32+2) + col_num\n else\n # Shift right column to the left\n # Gets the right column\n row_index = col_num / (SCREEN[0]/32+2)\n row_index *= (SCREEN[0]/32+2)\n col_num = (@corner_index - 1) % (SCREEN[0]/32+2) + row_index\n \n (0...(SCREEN[1]/32+2)).each{|n|\n j = ((SCREEN[0]/32+2) * n + col_num) % modTileId\n @tile_sprites[j].each_index{|i|\n tile = @tile_sprites[j][i]\n @animating_tiles.delete(tile.tile_sprite_id)\n tile.x -= 64 + SCREEN[0]\n \n map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32\n tile_id = @map_data[map_x,map_y,i]\n if tile_id.nil?\n tile.z = [map_y * 32, 0].max\n tile.bitmap = @tileset\n tile.src_rect.set(0,0,0,0)\n next\n else\n if @priorities[tile_id] == 0\n tile.z = 0\n else\n tile.z = 32 + (tile.y/32) * 32 + @priorities[tile_id] * 32\n end\n end\n if tile_id == 0\n tile.bitmap = RPG::Cache.picture('')\n tile.src_rect.set(0,0,0,0)\n elsif tile_id >= 384\n tile.bitmap = @tileset\n tile.src_rect.set(((tile_id - 384) % 8)*32,((tile_id - 384) / 8)*32, 32, 32)\n else\n auto_id = tile_id/48-1\n tile.bitmap = @autotiles[auto_id]\n tile.src_rect.set(((tile_id % 48) % 8)*32 + @current_frame[auto_id] * 256,((tile_id % 48) / 8)*32, 32, 32)\n @animating_tiles[tile.tile_sprite_id] = tile if @total_frames[auto_id] > 1\n end\n }\n }\n col_num /= SCREEN[0]/32+2\n col_num *= SCREEN[0]/32+2\n @corner_index = (@corner_index - 1) % (SCREEN[0]/32+2) + col_num\n end\n col_num = @corner_index\n end #end of while\n end",
"def OLDsetrowcol r, c\n $log.debug \" SCROLL setrowcol #{r}, #{c} + #{@cols_panned}\"\n # aha ! here's where i can check whether the cursor is falling off the viewable area\n cc = nil\n rr = nil\n if c\n cc = c #+ @cols_panned\n if c+@cols_panned < @orig_left\n # this essentially means this widget (button) is not in view, its off to the left\n $log.debug \" setrowcol OVERRIDE #{c} #{@cols_panned} < #{@orig_left} \"\n $log.debug \" aborting settrow col for now\"\n return\n end\n if c+@cols_panned > @orig_left + @display_w\n # this essentially means this button is not in view, its off to the right\n $log.debug \" setrowcol OVERRIDE #{c} #{@cols_panned} > #{@orig_left} + #{@display_w} \"\n $log.debug \" aborting settrow col for now\"\n return\n end\n end\n if r\n rr = r+@rows_panned\n end\n super rr, cc\n end",
"def center\n if @board.square(1,1).nil?\n [1,1]\n else\n nil\n end\n end",
"def check_grid_coordinates(x, y)\n (x >= 0) && (x < @height) && (y >= 0) && (y < @width)\n end",
"def corner_open\n case \n when space_open?(1)\n 1\n when space_open?(3)\n 3\n when space_open?(7)\n 7\n when space_open?(9)\n 9\n end\n end",
"def set(position)\n # duplicated code to avoid a method call\n @field[position / ELEMENT_WIDTH] |= 1 << (position % ELEMENT_WIDTH)\n end",
"def clamp; end",
"def set_position(row, col)\n if row.between?(0, 7) && col.between?(0, 7)\n @position[:row] = row\n\t @position[:col] = col\n\tend\n end",
"def on_board?(*args)\n x, y, length, direction = args.flatten\n\n x_max = x\n y_max = y\n case direction\n when :across\n x_max = x + length\n when :down\n y_max = y + length\n end\n\n @x_range.cover?(x) && @y_range.cover?(y) && @x_range.cover?(x_max) && @y_range.cover?(y_max)\n end",
"def center_origins\n return if !self.bitmap\n self.ox = self.bitmap.width / 2\n self.oy = self.bitmap.height / 2\n end",
"def []=(position, value)\n value == 1 ? @field[position / ELEMENT_WIDTH] |= 1 << (position % ELEMENT_WIDTH) : @field[position / ELEMENT_WIDTH] ^= 1 << (position % ELEMENT_WIDTH)\n end",
"def out_of_bounds?\n (0..@grid_size[0]).cover?(@coordinates[0]) &&\n (0..@grid_size[1]).cover?(@coordinates[1])\n end",
"def move_up_left\n i = 1\n until false\n x, y = @pos\n x -= i\n y -= i\n pos = [x, y]\n break if x > 7 || x < 0 || y > 7 || y < 0 || @board[pos].color == @color\n @moves << pos\n break if @board[pos].color != @color\n i += 1\n end\n end",
"def clip\n max_h, max_w = w.h, w.w\n\n if x < 0 then\n self.x = x.abs\n return :west\n elsif x > max_w then\n self.x = 2 * max_w - x\n return :east\n end\n\n if y < 0 then\n self.y = y.abs\n return :south\n elsif y > max_h then\n self.y = 2 * max_h - y\n return :north\n end\n\n nil\n end",
"def []=(position, value)\n if value == 1\n @field[position / ELEMENT_WIDTH] |= 1 << (position % ELEMENT_WIDTH)\n elsif (@field[position / ELEMENT_WIDTH]) & (1 << (position % ELEMENT_WIDTH)) != 0\n @field[position / ELEMENT_WIDTH] ^= 1 << (position % ELEMENT_WIDTH)\n end\n end",
"def width\n @x1 - @x0\n end",
"def boundaries(x, y)\n return false if x > 7 || x < 0 || y > 7 || y < 0\n return true\n\n end",
"def rel_x\n return x - Graphics.width/2\n end"
] | [
"0.6460228",
"0.6400039",
"0.60692316",
"0.6062662",
"0.60308903",
"0.5995022",
"0.59543717",
"0.5893334",
"0.58867455",
"0.5814616",
"0.57997775",
"0.5773628",
"0.5760343",
"0.5665251",
"0.5665251",
"0.55761063",
"0.55661297",
"0.5562214",
"0.55349624",
"0.5527016",
"0.5526079",
"0.5503621",
"0.54971224",
"0.54701006",
"0.54482305",
"0.54472184",
"0.54445565",
"0.5440274",
"0.54350865",
"0.54305744",
"0.54296064",
"0.5428469",
"0.5422073",
"0.5413999",
"0.5409304",
"0.5386024",
"0.53792584",
"0.5379134",
"0.5376403",
"0.5372164",
"0.53667986",
"0.5361928",
"0.53354007",
"0.53329176",
"0.5313323",
"0.53107595",
"0.52993226",
"0.5295941",
"0.5295929",
"0.52883285",
"0.52830595",
"0.52824265",
"0.52710533",
"0.5269519",
"0.5268036",
"0.52655405",
"0.52602875",
"0.5258463",
"0.5258463",
"0.5258463",
"0.52489614",
"0.52461576",
"0.5239667",
"0.523064",
"0.5227482",
"0.5220333",
"0.52192694",
"0.52192694",
"0.5214684",
"0.52045274",
"0.5199758",
"0.51996446",
"0.5197221",
"0.5195266",
"0.5195266",
"0.5195266",
"0.51951814",
"0.51951814",
"0.51817715",
"0.5181078",
"0.51780283",
"0.5177528",
"0.5163803",
"0.5161928",
"0.51610774",
"0.51600325",
"0.5159675",
"0.51593536",
"0.515817",
"0.5156155",
"0.5150766",
"0.51479053",
"0.5147757",
"0.51456845",
"0.51370794",
"0.51351446",
"0.51313555",
"0.5129487",
"0.51283705",
"0.51240265",
"0.51161385"
] | 0.0 | -1 |
calculates and sets ones in a cardinal direction from a pixel then spreads out on the other axis | def spread(pixel, distance)
xforms = [{:pri => 'x', :sec => 'y', :mod => '-'},
{:pri => 'x', :sec => 'y', :mod => '+'},
{:pri => 'y', :sec => 'x', :mod => '-'},
{:pri => 'y', :sec => 'x', :mod => '+'}]
xforms.each do |xform|
distance.times do |i|
if xform[:pri] == 'y'
pcoords = { :y => pixel[:y] + "#{xform[:mod]}#{i + 1}".to_i,
:x => pixel[:x] }
else
pcoords = { :x => pixel[:x] + "#{xform[:mod]}#{i + 1}".to_i,
:y => pixel[:y] }
end
set_to_one(pcoords)
(distance - (i + 1)).times do |j|
['+', '-'].each do |sign|
if xform[:sec] == 'y'
scoords = { :y => pcoords[:y] + "#{sign}#{j + 1}".to_i,
:x => pcoords[:x] }
else
scoords = { :x => pcoords[:x] + "#{sign}#{j + 1}".to_i,
:y => pcoords[:y] }
end
set_to_one(scoords)
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(row_index,col_index)\n\n if row_index-1 >= 0\n @image[row_index-1][col_index] = 1\n end\n if col_index - 1 >= 0\n @image[row_index][col_index-1] = 1\n end\n if row_index + 1 <= @image.length - 1\n @image[row_index+1][col_index] = 1\n end\n if col_index + 1 <= @image[row_index].length - 1\n @image[row_index][col_index+1] = 1\n end\n\n end",
"def transform \n \n @pixel_location = get_pixel_points \n puts \"px loc : #{@pixel_location}\"\n \n while @pixel_location.size != 0 \n transform_pixel_points(@pixel_location)\n @pixel_location.shift\n @pixel_location.shift\n end\n end",
"def blur_pixel(ones_array)\n ones_array.each do |point_array|\n # => breaks the point_array inner arrays into its two parts --\n # => wouldn't work if there was stuff in the middle\n row = point_array.first\n col = point_array.last\n # => this is where the transformation happens\n @image_array[row - 1][col] = 1\n @image_array[row][col - 1] = 1 unless col == 0\n @image_array[row + 1][col] = 1 unless row >= @num_row - 1\n @image_array[row][col + 1] = 1 unless col >= @num_col - 1 \n\n end\n end",
"def blur_pixel(ones_array)\n ones_array.each do |point_array|\n # => breaks the point_array inner arrays into its two parts --\n # => wouldn't work if there was stuff in the middle\n row = point_array.first\n col = point_array.last\n # => this is where the transformation happens\n @image_array[row - 1][col] = 1\n @image_array[row][col - 1] = 1 unless col == 0\n @image_array[row + 1][col] = 1 unless row >= @num_row - 1\n @image_array[row][col + 1] = 1 unless col >= @num_col - 1 \n end\n end",
"def transform(manHatDist)\r\n\t\tpixel_on = []\r\n\t\tmanHatDist.times do\r\n\t\t@image.each.with_index do |row, row_index|\r\n\t\t\trow.each.with_index do |pixel, col_index|\r\n\t\t\t\tif pixel == 1\r\n\t\t\t\t\tpixel_on.push [row_index, col_index]\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\t\tpixel_on.each do |touple|\r\n\t\t\t#blur(*touple)\r\n\t\t\trow_index, col_index = touple\r\n\t\t\tblur(row_index, col_index)\r\n\t\tend\r\n\tend\r\n\tend",
"def set_to_one(coords)\n if (0..@max_x).include?(coords[:x]) && (0..@max_y).include?(coords[:y])\n @image[coords[:y]][coords[:x]] = 1\n end\n end",
"def converse_bit(pixel) \n\t\tpixel.red /= 257\n\t\tpixel.green /= 257\n\t\tpixel.blue /= 257\n\t\t\n\tend",
"def set_one(row,col)\n\t\tpixels[row][col] = 1\n\tend",
"def blur!\r\n ones = get_ones\r\n ones.each do |found_row_number, found_col_number| \r\n @picture[found_row_number -1][found_col_number] = 1 unless found_row_number == 0 #up\r\n @picture[found_row_number +1][found_col_number] = 1 unless found_row_number == @picture.length-1 #down\r\n @picture[found_row_number][found_col_number -1] = 1 unless found_col_number == 0 #left\r\n @picture[found_row_number][found_col_number +1] = 1 unless found_col_number == @picture[found_row_number].length-1 #right\r\n end\r\n end",
"def snap_offset\n @y += @off_y / 32\n @x += @off_x / 32\n @real_x = @x * 128\n @real_y = @y * 128\n @off_y = 0#@off_y % 32\n @off_x = 0#@off_x % 32\n end",
"def shift!(dr)\r\n (0..1).each { |i| @center[i] += dr[i] }\r\n end",
"def mark(x,y)\n\t\t@grid[y][x] |= @@IN\n\n\t\tadd_to_frontier( x-1, y )\t\n\t\tadd_to_frontier( x+1, y )\n\t\tadd_to_frontier( x, y-1 )\n\t\tadd_to_frontier( x, y+1 )\n\tend",
"def forward (from); from[:y] += from[:orientation]; from; end",
"def apply_direction_and_mark(direction)\n change_direction = direction[0] == \"L\" ? -1 : 1\n movement = direction[1, direction.length - 1].to_i\n @current_direction = (@current_direction + change_direction) % 4\n orientation = @compass[@current_direction]\n (1..movement).each do |move|\n x = @x\n y = @y\n if orientation[:dir] == :y\n y = @y + (move * orientation[:mult])\n else\n x = @x + (move * orientation[:mult])\n end\n if @city[x,y] == 1\n puts (x-500).abs + (y-500).abs\n else\n @city[x,y] = 1\n end\n end\n if orientation[:dir] == :y\n @y = @y + (movement * orientation[:mult])\n else\n @x = @x + (movement * orientation[:mult])\n end\nend",
"def set_direction(value)\n value = validate_direction(value)\n @sprite.src_rect.y = @sprite.src_rect.height * (value / 2 - 1)\n @sprite.src_rect.x += @sprite.src_rect.width\n if @turncount\n @sprite.src_rect.x = 0 if @sprite.src_rect.x >= @sprite.bitmap.width\n @sprite.src_rect.x += @sprite.src_rect.width\n @sprite.src_rect.x = 0 if @sprite.src_rect.x >= @sprite.bitmap.width\n end\n @turncount = 6\n end",
"def makeImage\n for i in 0...@width\n ti = 2.0*Math::PI*i/ImageWidth.to_f\n for j in 0...@height\n tj = 2.0*Math::PI*j/ImageHeight.to_f\n\n $image[3 * (@height * i + j)] = 127*(1.0 + Math::sin(ti))\n $image[3 * (@height * i + j) +1] = 127*(1.0 + Math::cos(2*tj))\n $image[3 * (@height * i + j) +2] = 127*(1.0 + Math::cos(ti+tj))\n end\n end\n end",
"def move\n @coordinates[1] += 1 if @rover_facing == 'N'\n @coordinates[0] += 1 if @rover_facing == 'E'\n @coordinates[1] -= 1 if @rover_facing == 'S'\n @coordinates[0] -= 1 if @rover_facing == 'W'\nend",
"def walk(grid, x, y)\n [N, S, E, W].shuffle.each do |dir|\n nx, ny = x + DX[dir], y + DY[dir]\n if nx >= 0 && ny >= 0 && ny < grid.length && nx < grid[ny].length && grid[ny][nx] == 0\n grid[y][x] |= dir\n grid[ny][nx] |= OPPOSITE[dir]\n \n return [nx, ny]\n end\n end\n \n nil\nend",
"def blur!(distance = 1) #needs the !, is a bang, syntax is telling that is going to change the state of what we are operating on.\r\n distance.times do #looping for distance\r\n\r\n blur_pixels = coords # accessing array from previous method\r\n @array.each_with_index do |row, row_int|\r\n row.each_with_index do |int, col_index|\r\n blur_pixels.each do |row_int_coord, col_index_coord|\r\n\r\n if row_int == row_int_coord && col_index == col_index_coord\r\n # left of 1\r\n @array[row_int][col_index -1] = 1 unless col_index == 0\r\n # right of 1\r\n @array[row_int][col_index +1] = 1 unless col_index >= @col_length-1\r\n # above 1\r\n @array[row_int -1][col_index] = 1 unless row_int == 0\r\n # below 1\r\n @array[row_int +1][col_index] = 1 unless row_int >= @row_length-1\r\n end\r\n end\r\n end\r\n end\r\n end\r\n end",
"def am(amida, y, x)\n #p \"==== NOW ===\"\n #p y \n #p x\n #p amida\n\n if y == H \n #p \"=====GOAL\"\n if x + 1 == K\n $cnt = $cnt + 1\n end\n return\n end\n\n if x < W - 1\n to_right_amida = Marshal.load(Marshal.dump(amida))\n to_right_amida[y][x] = 1\n am(to_right_amida, y + 1, x + 1)\n end\n\n to_streight_amida = Marshal.load(Marshal.dump(amida))\n am(to_streight_amida, y + 1, x)\n\n if x > 0\n to_left_amida = Marshal.load(Marshal.dump(amida))\n to_left_amida[y][x - 1] = 1\n am(to_left_amida, y + 1, x - 1)\n end\nend",
"def blur(distance)\n row_max = @image[0].length() - 1\n column_max = @image.length() - 1\n\n ones = self.get_ones\n\n while distance > 0\n ones.each do |one|\n vert = one[1]\n horiz = one[0]\n \n # down \n @image[vert + distance][horiz] = 1 unless vert + distance > column_max\n\n # up\n @image[vert - distance][horiz] = 1 unless vert - distance < 0\n\n # right\n @image[vert][horiz + distance] = 1 unless horiz + distance > row_max\n\n # left\n @image[vert][horiz - distance] = 1 unless horiz - distance < 0\n\n sub_distance = distance\n diag = 1\n while sub_distance > 1\n\n # bottom sides\n unless vert + sub_distance - 1 > column_max || horiz - diag < 0 || horiz + diag > row_max\n @image[vert + sub_distance - 1][horiz - diag] = 1\n @image[vert + sub_distance - 1][horiz + diag] = 1 \n end\n\n # top\n unless vert - sub_distance + 1 < 0 || horiz - diag < 0 || horiz + diag > row_max\n @image[vert - sub_distance + 1][horiz - diag] = 1\n @image[vert - sub_distance + 1][horiz + diag] = 1\n end\n\n # right sides\n unless vert - diag < 0 || vert + diag > column_max || horiz + sub_distance - 1 > column_max\n @image[vert - 1][horiz + sub_distance - diag] = 1\n @image[vert + 1][horiz + sub_distance - diag] = 1\n end\n\n # left sides\n unless vert - diag < 0 || vert + diag > column_max || horiz + sub_distance - 1 < 0\n @image[vert - 1][horiz - sub_distance + diag] = 1\n @image[vert + 1][horiz - sub_distance + diag] = 1\n end\n\n sub_distance -= 1\n diag += 1\n\n end\n end\n\n distance -= 1\n end\n\n end",
"def blur_image(distance)\r\n @length = @image.length\r\n @width = 0\r\n @image.each do |x|\r\n x.each do |cell|\r\n @width += 1\r\n end\r\n end\r\n i = 0\r\n j = 0\r\n n = distance\r\n while n > 0\r\n i = 0\r\n j = 0 \r\n while i < @length\r\n j = 0\r\n while j < @width\r\n if @image[i][j] == 1\r\n\r\n # This looks down from the rows\r\n if i < @length - 1\r\n if @image[i+1][j] == 0\r\n @image[i+1][j] = 2\r\n end\r\n end\r\n\r\n # This looks up from the rows\r\n if i > 0 && @image[i-1][j] == 0\r\n @image[i-1][j] = 2 \r\n end\r\n\r\n # This looks to the right until it gets to the end.\r\n if @image[i][j+1] == 0\r\n @image[i][j+1] = 2\r\n end\r\n\r\n # This looks to te left. I tried to set this so it will never look over the side of the array.\r\n # I'm afraid of what might happen if my program does that too muc.\r\n if j > 0 && @image[i][j - 1] == 0\r\n @image[i][j - 1] = 2\r\n end\r\n end\r\n j += 1\r\n end\r\n i += 1\r\n end\r\n # This code goes back through the array and turns the temporary shade values into 1s for output.\r\n i = 0\r\n j = 0\r\n while i < @length\r\n j = 0\r\n while j < @width\r\n if @image[i][j] == 2\r\n @image[i][j] = 1\r\n end\r\n j += 1\r\n end\r\n i += 1\r\n end\r\n n -= 1\r\n puts n\r\n end\r\n \r\n puts \"Inside blur_image\\n\"\r\n puts \"\\n\"\r\n end",
"def stitching(x, y)\n\t\t# Return only what's already been generated (that is, what's above and to the left).\n\t\treturn [:normal, [\n\t\t\t([x - 1, y] if x > 0),\n\t\t\t([x - 1, y - 1] if x > 0 and y > 0),\n\t\t\t([x, y - 1] if y > 0),\n\t\t\t([x + 1, y - 1] if y > 0 and x < @field_width - 1)\n\t\t].compact]\n\tend",
"def set_one_pixel(pixelno,r,g,b)\n# puts \"Set one pixel length packetdata in \" + @@packetdata.size.to_s\n pixelno = pixelno % @@numpixels\n if r < 256 then\n temp = [r]\n @@packetdata[pixelno * 3] = temp.pack(\"C\")\n end\n if g < 256 then\n temp = [g]\n @@packetdata[(pixelno * 3) + 1] = temp.pack(\"C\")\n end\n if b < 256 then\n temp = [b]\n @@packetdata[(pixelno * 3) + 2] = temp.pack(\"C\") \n end \nend",
"def steer(where)\n case where\n when :left\n @right_pin.set(0)\n @left_pin.set(1)\n when :right\n @left_pin.set(0)\n @right_pin.set(1)\n else\n @left_pin.set(0)\n @right_pin.set(0)\n end\n end",
"def invert!( axis )\n case axis\n when :x\n base_image.flip!\n when :y\n base_image.flop!\n else\n nil\n end\n end",
"def mirror_update pt\n pt.x = pt.x * (-1)\nend",
"def moveto(x, y)\n @x = x \n @y = y \n @real_x = @x * 128\n @real_y = @y * 128\n @prelock_direction = 0\n end",
"def shift!(dr)\r\n @pos.x += dr[0]\r\n @pos.y += dr[1]\r\n end",
"def x1\n {left: 0, right: Pong::WIDTH - WIDTH}[side]\n end",
"def draw_plank x, y, image\r\n image.draw(x,y,1) # 1 denotes the ZOrder \r\nend",
"def color_image_pixel\n @pixel_x = @cmd_options[0]-1\n @pixel_y = @cmd_options[1]-1\n @color = @cmd_options[2]\n @matrix[@pixel_y][@pixel_x] = @color\n end",
"def can_you_see?(map, dim, direction)\n plus = case direction\n when 1 then [-1,-1]\n when 2 then [-1, 0]\n when 3 then [-1, 1]\n when 4 then [ 0,-1]\n when 6 then [ 0, 1]\n when 7 then [ 1,-1]\n when 8 then [ 1, 0]\n when 9 then [ 1, 1]\n end\n\n #print \"whereami: \"\n whereami = whereami(map)\n coord = whereami\n\n while dim > 0 do\n whereamfrom = coord\n coord = [coord,plus].transpose.map{|ary| ary.inject(&:+) }\n\n #print \"distance: \"\n distance = distance(whereamfrom, coord)\n\n if whereamfrom == whereami || coord == whereami\n # 最初は0.5しか進まないわけだが...。\n if plus.any?{|e| e==0}\n dim -= 0.5\n else #角度を付けて入ってきた場合\n dim -= Math.sqrt(0.5**2 + 0.5**2)\n end\n else\n dim -= distance\n end\n return false if dim < 0\n #print \"now: \"\n #p coord\n #print \"dim: \"\n #p dim\n if myself?(coord, map)\n return true\n elsif mirror?(coord, map)\n # print \"!!! mirror #{plus} -> \"\n # TODO: 入った角度による。これはきれいに反射した場合\n plus = plus.map{|e| -1*e }\n # print \"#{plus}\\n\"\n end\n end\nend",
"def scan\n\t\t\t(1..MAX_Y_AXIS).each do |y|\n\t\t\t\treset_values\n\t\t\t\t(1..MAX_X_AXIS).each do |x|\n\n\t\t\t\t\timg_pixel_color = @image.pixel_color(x, y)\n\t\t\t\t\t\n\t\t\t\t\tif img_pixel_color.red <= COLOR_THRESHOLD\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t@left_eye_width = @left_eye_width + 1 if @glabella_width < 1\n\t\t\t\t\t\twrite_to_image(x, y, 'purple')\n\n\t\t\t\t\t\tif @left_eye_width >= MIN_EYE_WIDTH and @left_eye_width < MAX_EYE_WIDTH and @glabella_width > @left_eye_width and @glabella_width < (@left_eye_width * 2) and @left_eye_width >= MIN_EYE_WIDTH\n\t\t\t\t\t\t\treturn true if check_glabella(x, y)\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t@glabella_width = 0\t\t\t\t\t\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\t# we've encountered a white pixel but cannot assume that it is a glabella\n\t\t\t\t\t\t# so we do a count of white pixels across before it encounters another black pixel\n\t\t\t\t\t\t@glabella_start_x_position = x if @glabella_width == 0\n\t\t\t\t\t\t@glabella_start_y_position = y if @glabella_width == 0\n\t\t\t\t\t\t@glabella_width = @glabella_width + 1\n\t\t\t\t\t\twrite_to_image(x, y, '#eee')\n\t\t\t\t\tend\t\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn false\n\t\tend",
"def turn direction\n return unless placed?\n direction = case\n when direction.to_s.match(/^l(?:eft)?$/i); -1\n when direction.to_s.match(/^r(?:ight)?$/i); +1\n else; nil\n end\n # The modulus is to make sure we stay within the 0-4 array boundary\n @f = (@f + direction) % DIRECTIONS.size if direction\n report\n end",
"def increment_swim_tile_index\n\t\tanimation_frames = 2\n\n\t\tif face_left?\n\t\t\tpost_adj = 1\n\t\t\t@tile_idx = (@tile_idx % animation_frames) + post_adj\n\t\telse\n\t\t\tpost_adj = 4\n\t\t\tpre_adj = post_adj - 1 \n\t\t\t@tile_idx = ((@tile_idx - pre_adj) % animation_frames) + post_adj\n\t\tend\n\tend",
"def invert( axis )\n case axis\n when :x\n set_base_image( base_image.flip )\n when :y\n set_base_image( base_image.flop )\n else\n nil\n end\n end",
"def moveto(x, y)\n @ox = @x = x\n @oy = @y = y \n @real_x = @x * 128\n @real_y = @y * 128 \n end",
"def command direction\n ny, nx, nangle = near_xy(direction)\n if @labirint[ny][nx] == 0 || @labirint[ny][nx] == 2\n @x = nx\n @y = ny\n print\n @angle = nangle % 4\n end\n end",
"def set_at(x, y)\n self.x = x\n self.x = 0 if x < 0\n self.y = y\n if x + self.width > 640\n self.x -= (x + self.width - 640)\n end\n if y + self.height > 480\n self.y -= (y + self.height - 480)\n end\n end",
"def raster_line\n @cr[4] << 1 | @cr[3][7]\n end",
"def flag()\n\tb=[0,0.2,0.6]\n\ty=[0.8,0.8,0.2]\n\tr=[1,0,0]\n\t\n\t[[b,b,y,y,r,r],\n\t[b,b,y,y,r,r],\n\t[b,b,y,y,r,r],\n\t[b,b,y,y,r,r],\n\t[b,b,y,y,r,r]]\nend",
"def reduce\n @y += 1; @height -= 2\n update_position\n end",
"def setDestination(destx, desty)\n let @lengthx = destx - @x\n let @lengthy = desty - @y\n let dx = Math.abs(@lengthx)\n let dy = Math.abs(@lengthy)\n let @invert = (dx < dy)\n let temp = 0\n let @positivex = 0\n let @positivey = 0\n\n # scan should be on Y-axis\n if (@invert)\n let temp = dx # swap dx, dy\n let dx = dy\n let dy = temp\n\n let @positivex = (@y < desty)\n let @positivey = (@x < destx)\n else\n let @positivex = (@x < destx)\n let @positivey = (@y < desty)\n end\n\n let @d = (2 * dy) - dx\n let @straightD = 2 * dy\n let @diagonalD = 2 * (dy - dx)\n end",
"def moveto(x, y)\r\r\n @x = x % $game_map.width\r\r\n @y = y % $game_map.height\r\r\n @real_x = @x\r\r\n @real_y = @y\r\r\n @prelock_direction = 0\r\r\n straighten\r\r\n update_bush_depth\r\r\n end",
"def update_move_arch\n update_zvect\n self.y -= (Math::sin(@index/@div.to_f)*@high/8) \n end",
"def setup\n size 200, 200 \n no_stroke\n background 0 \n c = load_image \"cait.jpg\" \n xoff, yoff = 0, 0\n p = 2\n pix = p * 3 \n (c.width * c.height).times do |i| \n pixel = c.pixels[i] \n fill red( pixel ), 0, 0\n rect xoff, yoff, p, pix \n fill 0, green( pixel ), 0\n rect xoff+p, yoff, p, pix \n fill 0, 0, blue( pixel )\n rect xoff+p*2, yoff, p, pix \n xoff += pix\n if xoff >= (width-pix)\n xoff = 0\n yoff += pix\n end\n end \nend",
"def find_ones\n ones_arr = []\n\n @image.each_index do |row|\n @image[row].each_index do |column|\n if @image[row][column] == 1\n ones_arr << { :x => column, :y => row }\n end\n end\n end\n return ones_arr\n end",
"def index(x, y)\n (y - 1) * width + (x - 1)\n end",
"def moveto(x, y)\r\n @x = x % $game_map.width\r\n @y = y % $game_map.height\r\n @real_x = @x\r\n @real_y = @y\r\n @prelock_direction = 0\r\n straighten\r\n update_bush_depth\r\n end",
"def conjugate!\r\n set(@axis.mirror,@real)\r\n end",
"def reflect_horizontal\r\n self.v[:x] = -self.v[:x]\r\n end",
"def point_to_index(x,y)\n return (x*(bpp >> 3))+(y*((bpp >> 3)*(width)))\n end",
"def drive(where)\n case where\n when :forward,:forwards\n @backwards_pin.set(0)\n @forwards_pin.set(1)\n when :backwards,:backward\n @forwards_pin.set(0)\n @backwards_pin.set(1)\n else\n @forwards_pin.set(0)\n @backwards_pin.set(0)\n end\n end",
"def blurred\r\n unos = []\r\n # nested loops for rows and columns\r\n @paint.each_with_index do |row, rownum| # iterating over elements in the main array for rows \r\n row.each_with_index do |element, colnum| # iterating over elements in each subarray for columns\r\n if element == 1\r\n unos << [rownum, colnum]\r\n end\r\n end\r\n end\r\n\r\n unos.each do |rownum, colnum| \r\n # assigning \"1\" above \"1\"s, except for first row\r\n @paint[rownum -1][colnum] = 1 unless rownum == 0\r\n # assigning \"1\" below \"1\"s, except for last row\r\n @paint[rownum +1][colnum] = 1 unless rownum >= @paint.length-1\r\n # assigning \"1\" to the left of \"1\"s, except for first column\r\n @paint[rownum][colnum -1] = 1 unless colnum == 0\r\n # assigning \"1\" to the right of \"1\"s, except for last column\r\n @paint[rownum][colnum +1] = 1 unless colnum >= @paint[rownum].length-1\r\n end\r\n end",
"def redesign\n x = @mat[0].length\n y = @mat.size\n (1..y-2).each do |i|\n (1..x-2).each do |j|\n @mat[i][j] = \"0\"\n end\n end\n\n divide(1,x-2,1,y-2)\n end",
"def add_to_frontier(x, y)\n\t\tif x >= 0 && y >= 0 && y < @height && x < @width && @grid[y][x] == 0\n\t\t\t@grid[y][x] |= @@FRONTIER\n\t\t\t@frontier << [x,y]\n\t\tend\n\tend",
"def vflip\n g = Grid.new\n self.each do |point,v|\n g[Point.new( point.x, @height - point.y - 1 )] = v \n end\n g\n end",
"def run\n failed_attempts = 0\n failed_white_attempts = 0\n x = 0\n y = 0\n loop do\n # If white just sail through until we hit another color\n if @current_color == 1\n x_next, y_next = move_direction(x, y)\n\n # If in white and hit boundary or black then step through dp\n if restricted?(x_next, y_next)\n toggle_cc\n step_dp\n failed_white_attempts += 1\n else\n x = x_next\n y = y_next\n @current_color = @image.color(x, y)\n failed_attempts = 0\n failed_white_attempts = 0\n end\n\n break if failed_white_attempts == 4\n else\n @size = 0\n temp_x = x\n temp_y = y\n x, y, @size = block_fill(x, y)\n # puts \"CURR: #{temp_x+1}, #{temp_y+1}, NEXT: #{x+1}, #{y+1}\"\n x_next, y_next = move_direction(x, y)\n # If we are hitting the edge or a black codel try another direction\n if restricted?(x_next, y_next)\n update_movement(failed_attempts)\n failed_attempts += 1\n else # here we move into the next color block after processing the action\n next_color = @image.color(x_next, y_next)\n process_action(@current_color, next_color)\n x = x_next\n y = y_next\n @current_color = next_color\n failed_attempts = 0\n failed_white_attempts = 0\n end\n\n break if failed_attempts == 8\n end\n end\n end",
"def perform\n @bitmap.width = @x_axis\n @bitmap.height = @y_axis\n @bitmap.generate_pixels\n end",
"def set_board_pin_mode\n\n @axis_x.set_pin_mode()\n @axis_y.set_pin_mode()\n @axis_z.set_pin_mode()\n\n end",
"def controlled_square(_)\n ([-1, 1, 0].product([-1, 1, 0]) - [[0, 0]])\n .map { |mod| [@position[0] + mod[0], @position[1] + mod[1]] }\n .select { |i| Helper::in_border?(*i) }\n end",
"def set_direction(d)\r\r\n if !@direction_fix && d != 0\r\r\n @direction = d\r\r\n if d % 2 != 0 && (!$imported[\"CXJ-AnimEx\"] || !@has_diagonal)\r\r\n @direction+= 1\r\r\n @direction-= 2 if d > 5\r\r\n @direction = 10 - direction if d > 2 && d < 8\r\r\n end\r\r\n end\r\r\n @stop_count = 0\r\r\n end",
"def vector_to_direction(x, y)\n return 8 if y > 0 && x == 0\n return 2 if y < 0 && x == 0\n return 6 if x > 0 && y == 0\n return 4 if x < 0 && y == 0\n return 7 if y > 0 && x < 0\n return 1 if y < 0 && x < 0\n return 9 if y > 0 && x > 0\n return 3 if y < 0 && x > 0\n return 0\n end",
"def test_directionLeft\n [@window, @sprite, @bitmap].each{|container|\n uc = UCCharacterGraphic.new(container, Rect.new(300, 40, 40, 40), $data_actors[1])\n uc.direction = 1\n uc.draw()\n }\n return true\n end",
"def abs2\n @real*@real + @image*@image\n end",
"def ox=(ox)\n #\n unless @tilemap_drawn\n @ox = ox\n @ox_oy_set[0] = true\n return\n end\n \n return if @ox == ox\n # Shift all tiles left or right by the difference\n shift = @ox - ox\n \n @tile_sprites.each {|set| set.each{|tile| tile.x += shift }}\n @ox = ox\n # Determine if columns need to be shifted\n col_num = @corner_index\n #return unless @tile_sprites[col_num][0].x <= -49 || @tile_sprites[col_num][0].x >= -17\n while @tile_sprites[col_num][0].x <= -49 || @tile_sprites[col_num][0].x >= -17\n \n @corner_tile_loc[0] += (shift < 0 ? 1 : -1)\n modTileId = ((SCREEN[0]+64)*(SCREEN[1]+64))/1024 \n # If new ox is greater than old ox\n if shift < 0\n # Move all sprites in left column to the right side and change bitmaps\n # and z-values\n (0...(SCREEN[1]/32+2)).each{|n|\n j = ((SCREEN[0]/32+2) * n + col_num) % modTileId\n @tile_sprites[j].each_index{|i|\n tile = @tile_sprites[j][i]\n @animating_tiles.delete(tile.tile_sprite_id)\n tile.x += 64 + SCREEN[0]\n \n map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32\n tile_id = @map_data[map_x,map_y,i]\n \n if tile_id.nil?\n tile.z = [map_y * 32, 0].max\n tile.bitmap = RPG::Cache.picture('')\n tile.src_rect.set(0,0,0,0)\n next\n else\n if @priorities[tile_id] == 0\n tile.z = 0\n else\n tile.z = 32 + (tile.y/32) * 32 + @priorities[tile_id] * 32\n end\n end\n if tile_id == 0\n tile.bitmap = RPG::Cache.picture('')\n tile.src_rect.set(0,0,0,0)\n elsif tile_id >= 384\n tile.bitmap = @tileset\n tile.src_rect.set(((tile_id - 384) % 8) * 32,((tile_id - 384) / 8) *32, 32, 32)\n else\n auto_id = tile_id/48-1\n tile.bitmap = @autotiles[auto_id]\n tile.src_rect.set(((tile_id % 48) % 8)*32 + @current_frame[auto_id] * 256,((tile_id % 48) / 8)*32, 32, 32)\n @animating_tiles[tile.tile_sprite_id] = tile if @total_frames[auto_id] > 1\n end\n }\n }\n # New corner should be the tile immediately right of the previous tile\n col_num /= SCREEN[0]/32+2\n col_num *= SCREEN[0]/32+2\n @corner_index = (@corner_index + 1) % (SCREEN[0]/32+2) + col_num\n else\n # Shift right column to the left\n # Gets the right column\n row_index = col_num / (SCREEN[0]/32+2)\n row_index *= (SCREEN[0]/32+2)\n col_num = (@corner_index - 1) % (SCREEN[0]/32+2) + row_index\n \n (0...(SCREEN[1]/32+2)).each{|n|\n j = ((SCREEN[0]/32+2) * n + col_num) % modTileId\n @tile_sprites[j].each_index{|i|\n tile = @tile_sprites[j][i]\n @animating_tiles.delete(tile.tile_sprite_id)\n tile.x -= 64 + SCREEN[0]\n \n map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32\n tile_id = @map_data[map_x,map_y,i]\n if tile_id.nil?\n tile.z = [map_y * 32, 0].max\n tile.bitmap = @tileset\n tile.src_rect.set(0,0,0,0)\n next\n else\n if @priorities[tile_id] == 0\n tile.z = 0\n else\n tile.z = 32 + (tile.y/32) * 32 + @priorities[tile_id] * 32\n end\n end\n if tile_id == 0\n tile.bitmap = RPG::Cache.picture('')\n tile.src_rect.set(0,0,0,0)\n elsif tile_id >= 384\n tile.bitmap = @tileset\n tile.src_rect.set(((tile_id - 384) % 8)*32,((tile_id - 384) / 8)*32, 32, 32)\n else\n auto_id = tile_id/48-1\n tile.bitmap = @autotiles[auto_id]\n tile.src_rect.set(((tile_id % 48) % 8)*32 + @current_frame[auto_id] * 256,((tile_id % 48) / 8)*32, 32, 32)\n @animating_tiles[tile.tile_sprite_id] = tile if @total_frames[auto_id] > 1\n end\n }\n }\n col_num /= SCREEN[0]/32+2\n col_num *= SCREEN[0]/32+2\n @corner_index = (@corner_index - 1) % (SCREEN[0]/32+2) + col_num\n end\n col_num = @corner_index\n end #end of while\n end",
"def discover_points # step 1\r\n x = 0\r\n y = 0\r\n @image_arr.each do |row|\r\n x = 0\r\n row.each do |cell|\r\n if cell == 1 # discovered the cell is 1\r\n @ordinal_arr.push([y,x]) # this is where i push the ordinals.\r\n puts \"#{y},#{x}\"\r\n end\r\n x = x + 1\r\n end\r\n y = y + 1\r\n puts \"\" \r\n end\r\n end",
"def flip_horizontally!\n @picture.flip_horizontally!\n end",
"def reflect_horizontal\n v[:x] = -v[:x]\n end",
"def flip\n Loc.new(@y,@x)\n end",
"def each_direction(x, y)\n\t\tyield x-1, y if x > 0 #up\n\t\tyield x, y-1 if y > 0 #left\n\t\tyield x, y+1 if @map[x][y+1] #right\n\t\tyield x+1, y if @map[x+1]\n\tend",
"def walk\n case @direction\n when 'N'\n @y += 1\n when 'W'\n @x += 1\n when 'S'\n @y -= 1\n when 'E'\n @x -= 1\n end\n end",
"def hexagonal_index\n (1 + Math.sqrt(1 + 8 * self)) / 4\n end",
"def axis_inches axis, tile, pixel\n @offset[axis] + tile*@tile_interval[axis] + pixel*@scale[axis]\n end",
"def axis_inches axis, tile, pixel\n @offset[axis] + tile*@tile_interval[axis] + pixel*@scale[axis]\n end",
"def encode(x, y, tool)\n (x << X_OFFSET) | (y << Y_OFFSET) | tool\nend",
"def column_next dir=0\n if dir == 0\n $stact += $grows\n $stact = 0 if $stact >= $viewport.size\n else\n $stact -= $grows\n $stact = 0 if $stact < 0\n end\nend",
"def column_next dir=0\n if dir == 0\n $stact += $grows\n $stact = 0 if $stact >= $viewport.size\n else\n $stact -= $grows\n $stact = 0 if $stact < 0\n end\nend",
"def column_next dir=0\n if dir == 0\n $stact += $grows\n $stact = 0 if $stact >= $viewport.size\n else\n $stact -= $grows\n $stact = 0 if $stact < 0\n end\nend",
"def set_bitmap_position\n end",
"def mirror\n point3.mirror!\n end",
"def transform line\n i = 1\n tortoise = line[i]\n hare = line[i * 2]\n while tortoise != hare\n i += 1\n tortoise = line[i]\n hare = line[i * 2]\n end\n v = i\n\n mu = 0\n tortoise = line[mu]\n hare = line[v * 2 + mu]\n while tortoise != hare\n mu += 1\n tortoise = line[mu]\n hare = line[v * 2 + mu]\n end\n\n lam = 1\n hare = line[mu + lam]\n while tortoise != hare\n lam += 1\n hare = line[mu + lam]\n end\n #puts \"v mu lam %d %d %d\" % [v, mu, lam]\n \n line[mu, lam] \nend",
"def shrink_to_one image, xpos, ypos, width, height\n# if @intermediate_images\n# tmp_image = \"vo-#{xpos}-#{ypos}\".to_sym\n# copy_subimage image, xpos, ypos, width, height, tmp_image\n# d_write_image(tmp_image)\n# end\n img = get_image(image)\n checkbox_pixels = img.excerpt(xpos, ypos, width, height)\n shrink_to_one = checkbox_pixels.scale(1,1)\n return shrink_to_one.get_pixels(0,0,1,1)[0].red\n end",
"def move_coin(array)\n @moneda.x = array[0]\n @moneda.y = array[1]\n end",
"def check_direction(origin_arr,destination_arr)\n\t\t horizontal_direction(origin_arr,destination_arr)\n\tend",
"def looping_position_check(bitmap, point1)\n if Looping_Background\n plus_x = (Graphics.width - bitmap.width)/2\n plus_y = (Graphics.height - bitmap.height)/2\n else\n plus_x = Graphics.width / 2\n plus_y = Graphics.height / 2\n end\n if point1\n @point1.set(*initpos_1)\n @point1.x += plus_x\n @point1.y += plus_y\n else\n @point2.set(*initpos_2)\n @point2.x += plus_x\n @point2.y += plus_y\n end\n end",
"def light_switcher(array, inc)\n counter = 0\n\n while counter < array.length\n array[counter] = !array[counter] if (counter + 1) % inc == 0\n counter += 1\n end\n\n array\nend",
"def update_offset\n @offset_counter[1] += 0.01\n @offset_counter[1]=@offset_counter[1]%90\n @offset[1] = 30*Math.sin(@offset_counter[1]);\n @offset_counter[0]+=0.005\n @offset_counter[0]=@offset_counter[0]%90\n @offset[0] = 150*Math.sin(@offset_counter[0]);\n # @offset=[0,0]\n end",
"def line_xiaolin_wu(x0, y0, x1, y1, stroke_color, inclusive = true)\n stroke_color = ChunkyPNG::Color.parse(stroke_color)\n\n dx = x1 - x0\n sx = dx < 0 ? -1 : 1\n dx *= sx\n dy = y1 - y0\n sy = dy < 0 ? -1 : 1\n dy *= sy\n\n if dy == 0 # vertical line\n x0.step(inclusive ? x1 : x1 - sx, sx) do |x|\n compose_pixel(x, y0, stroke_color)\n end\n\n elsif dx == 0 # horizontal line\n y0.step(inclusive ? y1 : y1 - sy, sy) do |y|\n compose_pixel(x0, y, stroke_color)\n end\n\n elsif dx == dy # diagonal\n x0.step(inclusive ? x1 : x1 - sx, sx) do |x|\n compose_pixel(x, y0, stroke_color)\n y0 += sy\n end\n\n elsif dy > dx # vertical displacement\n compose_pixel(x0, y0, stroke_color)\n e_acc = 0\n e = ((dx << 16) / dy.to_f).round\n (dy - 1).downto(0) do |i|\n e_acc_temp, e_acc = e_acc, (e_acc + e) & 0xffff\n x0 += sx if e_acc <= e_acc_temp\n w = 0xff - (e_acc >> 8)\n compose_pixel(x0, y0, ChunkyPNG::Color.fade(stroke_color, w))\n if inclusive || i > 0\n compose_pixel(x0 + sx, y0 + sy, ChunkyPNG::Color.fade(stroke_color, 0xff - w))\n end\n y0 += sy\n end\n compose_pixel(x1, y1, stroke_color) if inclusive\n\n else # horizontal displacement\n compose_pixel(x0, y0, stroke_color)\n e_acc = 0\n e = ((dy << 16) / dx.to_f).round\n (dx - 1).downto(0) do |i|\n e_acc_temp, e_acc = e_acc, (e_acc + e) & 0xffff\n y0 += sy if e_acc <= e_acc_temp\n w = 0xff - (e_acc >> 8)\n compose_pixel(x0, y0, ChunkyPNG::Color.fade(stroke_color, w))\n if inclusive || i > 0\n compose_pixel(x0 + sx, y0 + sy, ChunkyPNG::Color.fade(stroke_color, 0xff - w))\n end\n x0 += sx\n end\n compose_pixel(x1, y1, stroke_color) if inclusive\n end\n\n self\n end",
"def forward_move\n case @facing\n when 'NORTH'\n @y += 1\n when 'SOUTH'\n @y -= 1\n when 'EAST'\n @x += 1\n when 'WEST'\n @x -= 1\n end\n self\n end",
"def turn_left\n # a kind of matrix multiplication\n new_row_diff = 0 - @col_diff\n new_col_diff = @row_diff + 0\n @row_diff = new_row_diff\n @col_diff = new_col_diff\n end",
"def update_origin\n if bitmap\n unless @battler && @battler.data_battler.use_sprite\n self.ox = bitmap.width / 2\n self.oy = bitmap.height / 2\n else\n if @anim_cell != @battler.anim_cell\n @anim_cell = @battler.anim_cell\n src_rect.y = (@anim_cell / MaxCol) * height\n src_rect.x = (@anim_cell % MaxCol) * width\n end\n self.ox = src_rect.width/2\n self.oy = height/2\n end\n end\n end",
"def panoramic_pairs(landmarks)\n\nend",
"def half( side )\n case side\n when :u; size.dup.y * ( 0.5 )\n when :d; size.dup.y * ( 0.5 )\n when :l; size.dup.x * ( 0.5 )\n when :r; size.dup.x * ( 0.5 )\n when :v; size.dup.y * ( 0.5 )\n when :h; size.dup.x * ( 0.5 )\n end\n end",
"def mirror!\n set(-@x, -@y, -@z)\n end",
"def move_forward_two?(x_des, y_des)\n # Set forward direction based on piece color\n if y_position == 7\n direction = 1\n elsif y_position == 2\n direction = -1\n end\n\n # Subtract y_des and y_position, and check equality to 2 or -2 based on direction\n y_position - y_des.to_i == 2 * direction && no_forward_obstruction?(x_des, y_des)\n end",
"def [] y, x=nil\n if x\n @pixels[(@size[1]-y)*@size[0]+x]\n else\n @pixels[(@size[1]-y)*@size[0],@size[0]]\n end\n end",
"def [] y, x=nil\n if x\n @pixels[(@size[1]-y)*@size[0]+x]\n else\n @pixels[(@size[1]-y)*@size[0],@size[0]]\n end\n end",
"def c1= c; @c1 = (c == 1) ? 1 : 0; end"
] | [
"0.6275838",
"0.6157626",
"0.61439157",
"0.61123776",
"0.60569835",
"0.60523635",
"0.60075986",
"0.5824565",
"0.5805831",
"0.56577843",
"0.5632394",
"0.55982554",
"0.5561984",
"0.55500764",
"0.5532906",
"0.55228615",
"0.5511399",
"0.5493891",
"0.5481292",
"0.5443608",
"0.54294837",
"0.5402059",
"0.53520167",
"0.53514916",
"0.5334005",
"0.52850026",
"0.5274873",
"0.5270374",
"0.52244455",
"0.52157944",
"0.52135515",
"0.51495683",
"0.514307",
"0.51410836",
"0.51287407",
"0.510616",
"0.5096321",
"0.5087749",
"0.5045331",
"0.5039294",
"0.503897",
"0.5038882",
"0.5038853",
"0.50275695",
"0.5026734",
"0.50262123",
"0.5013073",
"0.5011836",
"0.500827",
"0.5003352",
"0.4993124",
"0.4986861",
"0.49810126",
"0.49801782",
"0.49790627",
"0.4979055",
"0.49732336",
"0.49701953",
"0.49639198",
"0.49621016",
"0.49619743",
"0.49553022",
"0.49545044",
"0.4952703",
"0.4950929",
"0.49489993",
"0.49380398",
"0.49356613",
"0.4935289",
"0.49306163",
"0.49212855",
"0.49182814",
"0.4908471",
"0.4906896",
"0.490212",
"0.490212",
"0.4897576",
"0.48943752",
"0.48943752",
"0.48943752",
"0.48895586",
"0.4885168",
"0.4882961",
"0.4879793",
"0.48763186",
"0.48695624",
"0.4865357",
"0.48634964",
"0.48600018",
"0.48588693",
"0.4858301",
"0.48572195",
"0.48561168",
"0.4852732",
"0.4850711",
"0.4844429",
"0.48443875",
"0.48410058",
"0.48410058",
"0.48396784"
] | 0.5156745 | 31 |
returns an array with coordinates of the 1's | def find_ones
ones_arr = []
@image.each_index do |row|
@image[row].each_index do |column|
if @image[row][column] == 1
ones_arr << { :x => column, :y => row }
end
end
end
return ones_arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coordinate_array\n\t\t[latitude,longitude]\n\tend",
"def coord_to_array(coordinates)\n x = coordinates[1]\n y = coordinates[0]\n conversion = ((x-1) * @size) + (y -1)\n end",
"def find_ones\n ones_locations = []\n # => finding index of ROW and COL for each 1 in grid and storing as row/col array pairs\n @image_array.each_index do |row|\n @image_array[row].each_index do |col|\n if @image_array[row][col] == 1\n puts \"#{row}, #{col}\" # <---this is just to display that it's working, can be removed\n ones_locations << [row, col]\n end\n end\n end\n return ones_locations\n end",
"def x_points\n points = [[], []]\n (0...height).each do |y|\n (0...width).each do |x|\n if (array[y][x]).nonzero? && (x - 1 < 0 || (array[y][x - 1]).zero?)\n points[0] << Point.new(x - 1, y) + @position\n end\n\n if (array[y][x]).nonzero? && (x + 1 >= length || (array[y][x + 1]).zero?)\n points[1] << Point.new(x + 1, y) + @position\n end\n end\n end\n\n points\n end",
"def get_ones\r\n ones = []\r\n @icon.each_with_index do |row, row_index|\r\n row.each_with_index do |item, col_index|\r\n if item == 1\r\n ones << [row_index, col_index]\r\n end\r\n end\r\n end\r\n ones\r\n end",
"def get_ones\r\n ones = []\r\n @picture.each_with_index do |row, row_number|\r\n row.each_with_index do |item, col_number|\r\n if item == 1\r\n ones << [row_number, col_number]\r\n end\r\n end\r\n end \r\n ones\r\n end",
"def coord_array\n _coords.dup\n end",
"def find_ones\n # => Establish an empty array to hold the index positions of all the 1s\n ones_ary = []\n # => Finding the index of ROW and COL for each 1 in the grid and storing\n # => them as row/col array pairs\n\n # => |row| denotes the top-level array (could be named anything)\n @image_array.each_index do |row|\n # => |col| is the chosen variable name for the inner array\n @image_array[row].each_index do |col|\n if @image_array[row][col] == 1\n puts \"#{row}, #{col}\"\n ones_ary << [row, col]\n end\n end\n end \n return ones_ary\n end",
"def pos_to_a\r\n [ pos.x, pos.y ]\r\n end",
"def to_array\n @points.collect { |p| [p.x, p.y] }\n end",
"def coords\r\n blur_pixels = []\r\n # blur_pixels is the array, and then we need to fill it\r\n @array.each_with_index do |row, row_int| #nested loops\r\n row.each_with_index do |int, col_index| # iterating over integers in arrays \r\n if int == 1 #1 is the number we are using as the culprit in our blur\r\n blur_pixels << [row_int, col_index] # << is pushing into the blur_pixels array\r\n end\r\n end\r\n end\r\n blur_pixels\r\n end",
"def to_xy\n a = self\n a = [a[0].x, a[0].y] if length == 1\n return *a\n end",
"def coordinates\n arr = []\n (0...@size).each do |row|\n (0...@size).each do |column|\n arr << Coordinate.new(x: row,y: column)\n end\n end\n arr\n end",
"def coords\n coord_list = []\n (@x..(@x + @size_x - 1)).each do |i|\n (@y..(@y + @size_y - 1)).each do |j|\n coord = [i, j]\n coord_list << coord\n end\n end\n\n return coord_list\n end",
"def create_position_array()\n array_2D = []\n array_1D = []\n\n (0...@row).each_with_index do |value, row_index|\n (0...@col).each_with_index { |value, col_index| array_1D.append(value+(row_index*@col)) }\n array_2D.append(array_1D)\n array_1D = []\n end\n\n return array_2D\n end",
"def coordinates_to_indices(x, y)\n [x - 1, y - 1]\n end",
"def coordinates\n coordinates = Array.new\n \n coordinates.push self.lat\n coordinates.push self.lng\n \n return coordinates\n end",
"def coordinates(image)\n image.each_with_index.flat_map do |row,x|\n (0...row.length).find_all{|i| row[i] == @char }.map{|y| [x,y] }\n end\n end",
"def to_a\n [x_point,y_point]\n end",
"def neighbours point\n [\n [-1, 0],\n [1, 0],\n [0, 1],\n [0, -1]\n ].map do |(dx, dy)|\n [\n (point[0] + dx + @map.length) % @map.length,\n (point[1] + dy + @map.length) % @map.length\n ]\n end\n end",
"def find_ones\n ones = []\n # This line will start at the beginning (upper left corner of the 2D array) so the first value, and the index of that value (i.e. [value: 0, index: 0]).\n # This will then continue on to line 17\n # Line 14 will grab the row item (0) and work along the columns. After first itiretaion (same as above since its the first index), the loop will continue until the\n # last number of the columns on that row item completes. So in this case, the three zeroes at underneath the first zero.\n # Afterwards, it will go back up to the rows line (16) and jump on to the next index and item on that row. This will continue until the entire array has been checked through.\n @image_blur_array.each_with_index do | row_item, row_index| \n row_item.each_with_index do |col_item, col_index|\n if col_item == 1 # If the col_item (since it is the last number we checked) equals to '1', the coordinates of that number will be added onto the array 'ones'\n ones << [row_index, col_index]\n end\n end\n end\n # Returns the 'ones' array to the blur method\n return ones\n end",
"def to_xy\n [x, y]\n end",
"def extract_coordinates(args)\n args.map(&:to_i).map { |int| int - 1 }\n end",
"def get_arr_x(x, y) \n x # this coordinate doesn't change\nend",
"def initpos_1\n return [0,0]\n end",
"def coordinates\n [@y_location, @x_location]\n end",
"def mineLocation field\n coords = []\n field.each_index do | i |\n field[i].each_index do | j |\n if field[i][j] == 1\n coords << i\n coords << j\n end\n end\n end\n coords\nend",
"def array\n @angles.first\n end",
"def y_points\n points = []\n (0...width).each do |x|\n (0...height).reverse_each do |y|\n if (array[y][x]).nonzero? && (y + 1 >= height || (array[y + 1][x]).zero?)\n points << Point.new(x, y + 1) + @position\n end\n end\n end\n\n points\n end",
"def coords\n [x, y]\n end",
"def image_points\n [\n @state.ctm_transform(0, 0),\n @state.ctm_transform(0, 1),\n @state.ctm_transform(1, 0),\n @state.ctm_transform(1, 1)\n ]\n end",
"def to_a\n [left, center, right]\n end",
"def to_a\n [left, center, right]\n end",
"def coordinates\n return 166, 72\n end",
"def getVertices( x0, y0, x1, y1) # arguments define bounding box\n\t\tw, h = x1 - x0, y1 - y0\n\t\td = 5 # size of corner chip\n\n\t\t[\n\t\t\t[ d, 0], [ w - d, 0],\n [ w, d], [w, h - d],\n [ w - d, h], [ d, h],\n [ 0, h - d], [ 0, d]\n\t\t].map do |v| [ v[0] + x0, v[1] + y0 ] end.flatten\n\tend",
"def generate_coordinates\n coordinates = []\n (0..@column_count - 1).to_a.each do |i|\n (0..@row_count - 1).to_a.each do |j|\n coordinates << {x: i, y: j, z: 0}\n end\n end\n coordinates\n end",
"def to_index_array a=[]\n\t\t@primitives.each do |p|\n\t\t\ta += p[:verts]\n\t\tend\n\t\ta\n\tend",
"def to_coordinates\n\n CGPointMake(self.x.to_coordinates, self.y.to_coordinates)\n end",
"def to_coordinates\n [latitude, longitude]\n end",
"def coordinates\n\t coordinate_array.map(&:to_s).join(\",\")\n\tend",
"def coordinates\n [latitude, longitude]\n end",
"def coordinates\n [rand(50), rand(90)]\n end",
"def to_xy( hex )\n tmp_q = hex.q\n x = @hex_ray * Math.sqrt(3) * ( tmp_q + hex.r/2.0 )\n y = @hex_ray * 3.0/2.0 * hex.r\n [ x, y ]\n end",
"def sub_identities(point)\r\n identities = Array.new\r\n subtracted_point = sub(point)\r\n identities << subtracted_point.identity_x unless subtracted_point.x == 0\r\n identities << subtracted_point.identity_y unless subtracted_point.y == 0\r\n return identities\r\n end",
"def coordinates\n [@data[:szer_geogr].to_f, @data[:dl_geogr].to_f]\n end",
"def get_coordinates(pos)\n row = (pos / @width) + 1\n col = (pos % @width) + 1\n [row, col]\n end",
"def discover_points # step 1\r\n x = 0\r\n y = 0\r\n @image_arr.each do |row|\r\n x = 0\r\n row.each do |cell|\r\n if cell == 1 # discovered the cell is 1\r\n @ordinal_arr.push([y,x]) # this is where i push the ordinals.\r\n puts \"#{y},#{x}\"\r\n end\r\n x = x + 1\r\n end\r\n y = y + 1\r\n puts \"\" \r\n end\r\n end",
"def coordinates\n row_values.product(col_values)\n end",
"def points\n [top_left, top_right, bottom_left, bottom_right]\n end",
"def getVertices( x0, y0, x1, y1) # arguments define bounding box\n\t\tw, h = x1 - x0, y1 - y0\n\t\thh = (h/2).to_i\n\n\t\t[\n\t\t\t[ hh, 0], [ w - hh, 0], [ w, hh], [ w - hh, h], [ hh, h], [ 0, hh]\n\t\t].map do |v| [ v[0] + x0, v[1] + y0 ] end.flatten\n\tend",
"def matrix_row\n return [ self.run, self.rise * -1, (p1.y * self.run - self.rise*p1.x)]\n end",
"def get_coords_from_node(node)\n\t\t[node.x,node.y]\n\tend",
"def coordinates\n @coordinates\n end",
"def to_a\n if defined?(@to_a)\n @to_a\n else\n cs = self.coord_seq\n @to_a = if self.has_z?\n [ cs.get_x(0), cs.get_y(0), cs.get_z(0) ]\n else\n [ cs.get_x(0), cs.get_y(0) ]\n end\n end\n end",
"def hexagonal_index\n (1 + Math.sqrt(1 + 8 * self)) / 4\n end",
"def coords\n Vector[@ob.x, @ob.y, @ob.z]\n end",
"def coordinate_list\n @board.each_index.inject([]) do |result,row_index|\n result.concat( \n @board[row_index].each_index.collect do |column_index|\n [row_index + 1, column_index + 1]\n end\n )\n end\n end",
"def coords_arr(arr)\n\tarr.map.with_index do |line, x|\n\t\tline.map.with_index do |point, y|\n\t\t\tCOORDS_HASH[[x,y]] = point\n\t\t\t[x,y]\n\t\tend\n\tend\nend",
"def to_a; [x, y] end",
"def points\n []\n end",
"def get_cell_at_xy(input_array)\n input_array.map do |coord|\n x = coord[0]\n y = coord[1]\n at_coord(x, y)\n end\n end",
"def other_vector(arry)\n\t\treturn [(arry[0] - first_point[0]), (arry[1] - first_point[1])]\n\tend",
"def points_n2\n result = [:infinity]\n (0...@p).each do |x|\n (0...@p).each do |y|\n point = [x,y]\n result << point if valid?(point)\n end\n end\n result\n end",
"def coords_of_neighbors(x, y)\n coords_of_neighbors = []\n (x - 1).upto(x + 1).each do |neighbors_x|\n (y - 1).upto(y + 1).each do |neighbors_y|\n next if (x == neighbors_x) && (y == neighbors_y)\n coords_of_neighbors << [neighbors_x, neighbors_y]\n end\n end\n coords_of_neighbors\n end",
"def to_a\n [x, y]\n end",
"def convert_position_to_array(position)\n\t\t@coordinate = position.chars\n\t\ttemp = @coordinate[0]\n\t\tx = @coordinate[1]\n\t\tx = (8 - position[1].to_i )\n\t\tconvert_y = { a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6 , h: 7 }\n\t\ty= convert_y.values_at(temp.to_sym)\n\t\t@coordinate[0]=x\n\t\t@coordinate[1]= y[0]\n\t\tposition_array = @coordinate\n\tend",
"def to_a\n [lat, lng]\n end",
"def to_a\n [lat, lng]\n end",
"def to_a\n [lat,lng]\n end",
"def to_a\n [self.x, self.y, self.z]\n end",
"def calculate_coordinates\n bresenham_circle_coordinates\n end",
"def getline_fromcoords(array)\n array.collect {|x,y| @tbls[:notformated][x][y].to_i}\n end",
"def neighbor_cell_coordinates\n NEIGHBOR_OFFSETS.map { |coordinates| [row + coordinates[0], col + coordinates[1]] }\n end",
"def latlon\r\n [latitude,longitude]\r\n end",
"def latlon\r\n [latitude,longitude]\r\n end",
"def latlon\r\n [latitude,longitude]\r\n end",
"def to_a\n [left, top, right]\n end",
"def to_a\n [left, top, right]\n end",
"def bits_to_coordinates(bits)\n a = (bits & 0b11111_00000_00000_00000_00000) >> 20\n e = (bits & 0b11111_00000_00000_00000) >> 15\n d = (bits & 0b11111_00000_00000) >> 10\n c = (bits & 0b11111_00000) >> 5\n b = bits & 0b11111\n\n coordinates = []\n\n coordinates.push(*word_to_coordinates(:A, a))\n coordinates.push(*word_to_coordinates(:B, b))\n coordinates.push(*word_to_coordinates(:C, c))\n coordinates.push(*word_to_coordinates(:D, d))\n coordinates.push(*word_to_coordinates(:E, e))\n end",
"def adjacents(pos)\n result = []\n x = pos[0]\n y = pos[1]\n (x-1..x+1).each do |row|\n (y-1..y+1).each do |col|\n result << [row,col] unless [row,col] == pos ||\n self[row,col] == nil ||\n row < 0 || col < 0\n end\n end\n result\n end",
"def to_a; [w, x, y, z] end",
"def xyz\n return [self.x,self.y,self.z]\n end",
"def calculate_coordinates\n (\n egde(@x1, @y1, @x2, @y1) +\n egde(@x2, @y1, @x2, @y2) +\n egde(@x2, @y2, @x1, @y2) +\n egde(@x1, @y2, @x1, @y1)\n ).uniq\n end",
"def get_contour_points_adv()\r\n result = []\r\n idx = 0\r\n result[idx] = Offset.vertices(@active_face.outer_loop.vertices, -(@bit_diameter * 0.5)).offsetPoints\r\n# puts \" outer #{result[idx].length} #{result[idx]} \"\r\n @active_face.loops.each { |lp|\r\n if (!lp.outer?)\r\n idx += 1\r\n result[idx] = Offset.vertices(lp.vertices, -(@bit_diameter * 0.5) ).offsetPoints \r\n# puts \" inner[#{idx}] #{result[idx]}\" \r\n end\r\n }\r\n return result \r\nend",
"def coordinates\n [@data['latitude'].to_f, @data['longitude'].to_f]\n end",
"def coordinates\n [@data['latitude'].to_f, @data['longitude'].to_f]\n end",
"def to_a\n [left, bottom, tip, top, right]\n end",
"def building_coordinates(x, y, height, width)\n puts\"building #{height}x#{width} at location (#{x},#{y})\"\n coords = Array.new\n (0..width-1).each do |j|\n\n (0..height-1).each do |i|\n\n co = Coordinate.new(x+i,y+j)\n coords.push(co)\n end\n\n end\n puts\"*getBuildingCoordinates* returning array of building coordinates\"\n coords\n end",
"def initpos_2\n return [0,0]\n end",
"def x_values\n raise ArgumentError.new(\"#{self.inspect} is not a 2D numeric array\") unless is_numeric_2d_array?\n self.collect { |item| item.first }\n end",
"def getCoords (index)\n return index%10, index/10\n end",
"def calc_center_point(aArray)\r\nend",
"def _get_square_starting_points()\n square_starting_points = []\n row_index = 0\n column_index = 0\n 3.times do\n 3.times do\n square_starting_points << [row_index, column_index]\n column_index += 3\n end\n row_index += 3\n column_index = 0\n end\n square_starting_points\n end",
"def generate_coords\n coords = [0,0]\n coords[0] = rand(9)\n coords[1] = rand(9)\n coords\n end",
"def coords; {:x => @x, :y => @y} end",
"def ring_array\n ring_array = Array.new\n self.rings.count.times{|i| ring_array << i+1}\n return ring_array\n end",
"def lonlat\r\n [longitude,latitude]\r\n end",
"def lonlat\r\n [longitude,latitude]\r\n end",
"def Array(p0) end",
"def start_coords\n marker_coords('S')\n end"
] | [
"0.6963766",
"0.69543713",
"0.6941461",
"0.68731517",
"0.68238306",
"0.6740419",
"0.67121387",
"0.67001784",
"0.66407365",
"0.66257495",
"0.6544557",
"0.6529268",
"0.6504515",
"0.6445447",
"0.643228",
"0.639688",
"0.63561594",
"0.6343164",
"0.6342545",
"0.63340247",
"0.6310052",
"0.6274925",
"0.62745225",
"0.62607646",
"0.6230708",
"0.62188053",
"0.6191246",
"0.6187951",
"0.6179135",
"0.61625576",
"0.6127987",
"0.61105824",
"0.61105824",
"0.6093543",
"0.6035448",
"0.60247946",
"0.5997291",
"0.5993509",
"0.59864116",
"0.59754366",
"0.59730196",
"0.59729606",
"0.59630036",
"0.59561443",
"0.5943815",
"0.59266174",
"0.59242547",
"0.59206134",
"0.59151965",
"0.59133804",
"0.5910502",
"0.59006286",
"0.5891779",
"0.58897305",
"0.5878054",
"0.58768266",
"0.58725744",
"0.58719283",
"0.58704144",
"0.5814713",
"0.58005315",
"0.5797481",
"0.57947975",
"0.5792503",
"0.57881325",
"0.578813",
"0.5778691",
"0.5778691",
"0.577854",
"0.57740456",
"0.57704484",
"0.57701164",
"0.57657886",
"0.575799",
"0.575799",
"0.575799",
"0.5753597",
"0.5753597",
"0.5751306",
"0.5744834",
"0.5733985",
"0.5730153",
"0.5729847",
"0.5726069",
"0.57241917",
"0.57241917",
"0.5712561",
"0.57037175",
"0.570332",
"0.5696093",
"0.56712615",
"0.5670114",
"0.5667806",
"0.56640404",
"0.566223",
"0.5654626",
"0.56544787",
"0.56544787",
"0.56538546",
"0.5646828"
] | 0.70944625 | 0 |
checks if pixel to set within bounds and sets to 1 | def set_to_one(coords)
if (0..@max_x).include?(coords[:x]) && (0..@max_y).include?(coords[:y])
@image[coords[:y]][coords[:x]] = 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restricted?(x, y)\n out_of_bounds?(x, y) || @image.color(x, y) == 0\n end",
"def check_bounds\n\t\tif @x + SUB_TILE_WIDTH > @game_state.width\n\t\t\tupdate_x( -(@x + SUB_TILE_WIDTH - @game_state.width) )\n\t\telsif @x < 0\n\t\t\tupdate_x( @x.abs )\n\t\tend\n\t\tif @y + SUB_TILE_HEIGHT > @game_state.height\n\t\t\tupdate_y( -(@y + SUB_TILE_HEIGHT - @game_state.height) )\n\t\telsif @y < 0\n\t\t\tupdate_y( @y.abs )\n\t\tend\n\tend",
"def in_bounds?(x, y)\n x >= 0 && x < @grid_width && y >= 0 && y < @grid_height\n end",
"def setBounds\n true\n end",
"def check_limits_on_x_and_y\n\t\tself.x = self.window.limit_max_x if x > self.window.limit_max_x \n\t\tself.y = self.window.limit_min_y if y > self.window.limit_max_y \n\tend",
"def inbounds?(point)\n return false if point.x < 0\n return false if point.x >= @grid_width\n return false if point.y < 0\n return false if point.y >= @grid_height\n return true\n end",
"def clips?(x, y)\n ::GD2::GD2FFI.send(:gdImageBoundsSafe, image_ptr, x.to_i, y.to_i).zero?\n end",
"def would_fit(offs_x, offs_y)\r\n # Check at the center/top and center/bottom for map collisions\r\n not $state.map.solid?(@x + offs_x, @y + offs_y) and\r\n not $state.solid?(@x + offs_x, @y + offs_y - 45)\r\n end",
"def would_fit(offs_x, offs_y)\n # Check at the center/top and center/bottom for map collisions\n not @map.solid?(@x + offs_x, @y + offs_y) and\n not @map.solid?(@x + offs_x, @y + offs_y - 45)\n end",
"def out_of_bounds?(x, y)\n x < 0 || y < 0 || x > @width - 1 || y > @height - 1\n end",
"def over_bound?(x, y)\n if (x != @x || y != @y) && $game_map.valid?(x, y)\n max_w = $game_map.max_width ; max_h = $game_map.max_height\n screen_x = $game_map.adjust_x(x) * 32 + 16\n screen_y = $game_map.adjust_y(y) * 32 + 32\n sx = (screen_x / 32).to_i; sy = (screen_y / 32).to_i\n if sx.between?(0 - out_offset, max_w + out_offset) && \n sy.between?(0 - out_offset, max_h + out_offset)\n \n return false\n end # sx, sy\n end # xy != @xy && map_valid\n return true\n end",
"def calculate_boundaries!\n return unless @dirty\n\n # Init to vals of first point\n # We will do it this way so we only need one iteration\n point = @points.first\n @minx = point.x\n @maxx = point.x\n @miny = point.y\n @maxy = point.y\n @points.each do |point|\n @minx = [@minx, point.x].min\n @maxx = [@maxx, point.x].max\n @miny = [@miny, point.y].min\n @maxy = [@maxy, point.y].max\n end\n @grid_width = @maxx - @minx\n @grid_height = @maxy - @miny\n\n @dirty = false\n end",
"def check_range(x, y)\n !(x < 1 || y < 1 || x > width || y > height)\n end",
"def in_bounds?(point, scr_height, scr_width)\n point[0].between?(0, scr_height-1) && point[1].between?(0, scr_width-1)\nend",
"def set_one(row,col)\n\t\tpixels[row][col] = 1\n\tend",
"def is_in_limits? coordinate\n\t\t((coordinate[0][0] < @width) && (coordinate[0][1] < @height) && (coordinate[1][0] < @width) && (coordinate[1][1] < @height))\n\tend",
"def pixel? = unit == 'pixel'",
"def out_of_bounds?\n (0..@grid_size[0]).cover?(@coordinates[0]) &&\n (0..@grid_size[1]).cover?(@coordinates[1])\nend",
"def boundaries(x, y)\n return false if x > 7 || x < 0 || y > 7 || y < 0\n return true\n\n end",
"def ensure_bounds\n if self.position > min_position\n self.position = min_position\n false\n elsif self.position < max_position\n self.position = max_position\n false\n else\n true\n end\n end",
"def check_grid_coordinates(x, y)\n (x >= 0) && (x < @height) && (y >= 0) && (y < @width)\n end",
"def in_bounds?(x, y)\n return false if x.to_i < 0\n return false if y.to_i < 0\n\n x.to_i < cols && y.to_i < rows\n end",
"def would_fit(offs_x, offs_y)\n # Check for map collisions\n not @map.solid?(@x + offs_x - 10, @y + offs_y) and\n not @map.solid?(@x + offs_x + 10, @y + offs_y) and\n not @map.solid?(@x + offs_x - 10, @y + offs_y - 45) and\n not @map.solid?(@x + offs_x + 10, @y + offs_y - 45)\n end",
"def inside?(x, y)\n x >= 0 && x < @width && y >= 0 && y < @height\n end",
"def outofBounds\n\t\tif @x > @window.width || @y > @window.height || @x < 0 || @y < 0 then\n\t\t\treturn true\n\t\tend\n\t\treturn false\n\tend",
"def move_valid?(x, y)\n (0...@width).cover?(x) && (0...@height).cover?(y) && !@visited[x][y]\n end",
"def at_boundary?\n\t\tif @location.x == 0 || @location.x == @dimension-1 || @location.y == 0 || @location.y == @dimension-1\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def within_bounds?(query_point)\n query_point.x >= point.x && query_point.x <= point.x + image.width &&\n query_point.y >= point.y && query_point.y <= point.y + image.height\n end",
"def out_of_bounds?\n (0..@grid_size[0]).cover?(@coordinates[0]) &&\n (0..@grid_size[1]).cover?(@coordinates[1])\n end",
"def check_bounds(sp, params)\n if params[:xdisplay] == :wrap\n sp.x %= @game_window.width\n elsif params[:xdisplay] == :bound\n sp.x = (@game_window.width - sp.width) if sp.x > (@game_window.width - sp.width)\n elsif params[:ydisplay] == :wrap\n sp.y %= @game_window.height - sp.height\n elsif params[:ybound] == :bound\n sp.y = (@game_window.height - sp.height) if sp.y > (@game_window.height - sp.height)\n end\n end",
"def out_of_bounds?(x, y, lower_limit = 0, upper_limit = 4)\n (x < lower_limit or y < lower_limit) or (x > upper_limit or y > upper_limit)\n end",
"def set?(point, how=:over)\n @cells[point] & (how == :over ? 1 : 2) != 0\n end",
"def update_bounds(xs, ys)\n x_min = xs.min\n x_max = xs.max\n y_min = ys.min\n y_max = ys.max\n @left = x_min unless @left && x_min > @left\n @top = y_min unless @top && y_min > @top\n @right = x_max unless @right && x_max < @right\n @bottom = y_max unless @bottom && y_max < @bottom\n nil\n end",
"def on_battle_pixel?(out=0)\n w = Graphics.width + out; h = Graphics.height + out\n return true if screen_x.between?(0 - out,w) and screen_y.between?(0 - out,h)\n return false\n end",
"def is_out_of_boundary?(point)\n point.x < 0 || point.y < 0 || point.x >= @dimension || point.y >= @dimension\n end",
"def contains_x(x)\n\t\t@x <= x && x <= (@x + @bg_width)\n\tend",
"def within_bounds?\n !exceeded?\n end",
"def bound_in_rect(rect)\n result = rect\n if rect.x < 0\n result.width = rect.width - rect.x\n result.x = 0\n end\n if rect.y < 0\n result.height = result.height - rect.y\n result.y = 0\n end\n if rect.width > xsize\n result.width = xsize\n end\n if rect.height > ysize\n result.height = ysize\n end\n return result\n end",
"def bounds_check\n r,c = rowcol\n @current_index = 0 if @current_index < 0\n @current_index = @content_rows-1 if @current_index > @content_rows-1\n #$status_message.value = \"visible #{@prow} , #{@current_index} \"\n unless is_visible? @current_index\n if @prow > @current_index\n #$status_message.value = \"1 #{@prow} > #{@current_index} \"\n @prow -= 1\n else\n end\n end\n #end\n check_prow\n #$log.debug \"XXX: PAD BOUNDS ci:#{@current_index} , old #{@oldrow},pr #{@prow}, max #{@maxrow} pcol #{@pcol} maxcol #{@maxcol}\"\n @crow = @current_index + r - @prow\n @crow = r if @crow < r\n # 2 depends on whetehr suppressborders\n @crow = @row + @height -2 if @crow >= r + @height -2\n setrowcol @crow, @curpos+c\n lastcurpos @crow, @curpos+c\n if @oldrow != @prow || @oldcol != @pcol\n @repaint_required = true\n end\n end",
"def contains?(x, y)\n x > bounds.x && x < bounds.x+bounds.width && y > bounds.y && y < bounds.y+bounds.height\n end",
"def rect(col, row)\n row.times do |row_index|\n col.times do |col_index|\n @data[row_index][col_index] = true\n end\n end\n end",
"def in?(x, y)\n w = ((x.to_f-@x.to_f)**2.0)/(@width.to_f/2.0)\n h = ((y.to_f-@y.to_f)**2.0)/(@height.to_f/2.0)\n w + h <= 1\n end",
"def coordinate_valid?(x, y)\n (x >= 0) && (y >= 0) && (x < @width) && (y < @height)\n end",
"def coordinate_valid?(x, y)\n (x >= 0) && (y >= 0) && (x < @width) && (y < @height)\n end",
"def is_in_map(v)\n v.x >= 0 && v.y >= 0 && v.x < @size.x && v.y < @size.y\n end",
"def valid?(x, y)\n return (x >= 0 and x < $game_map.width and y >= 0 and y < $game_map.height)\n end",
"def valid?(x, y)\n return (x >= 0 and x < $game_map.width and y >= 0 and y < $game_map.height)\n end",
"def valid?(x, y)\n return (x >= 0 and x < width and y >= 0 and y < height)\n end",
"def is_inbounds?(x, y)\n true unless y > @maze.max.size-1 or y < 0 or x > @maze.size-1 or x < 0\n end",
"def in_bounds?(x, y)\n layout.bounds.contains?(x - element_left, y - element_top)\n end",
"def within?(x, y)\n (x >= 0) && (x < height) && (y >= 0) && (y < height)\n end",
"def occupied?(x,y) #Returns true if the coordinate is in bounds and is occupied\n\t\tif (0...$dimensions[:x]).include?(x) && (0...$dimensions[:y]).include?(y)\n\t\t\t@board[y][x] == :wall\n\t\telse\n\t\t\ttrue\n\t\tend\n\tend",
"def valid?(x, y)\n x >= 0 && x < MAX_WIDTH && y >= 0 && y < MAX_HEIGHT\n end",
"def in_image(row, column)\n\t\treturn (0<=row and row<@height and 0<=column and column<@width)\n\tend",
"def check_glabella(x, y)\n\t\t\t@right_eye_width = @right_eye_width + 1\t\n\t\t\twrite_to_image(x, y, 'blue')\n\t\t\treturn true if check_right_eye\n\t\t\treturn false\t\t\t\t\t\t\n\t\tend",
"def out_of_bounds?(x, y)\n x >= (Game::Width - Game::Padding) || x <= (0 + Game::Padding) || y >= (Game::Height - Game::Padding) || y <= (0 + Game::Padding)\n end",
"def bounds\n end",
"def inbounds(destination)\n row = destination[0]\n column = destination[1]\n row >= 0 && row <= 7 && column >= 0 && column <= 7\n end",
"def valid?\n test_bounds(x, @xmin, @xmax) && test_bounds(y, @ymin, @ymax)\n end",
"def in_bounds?(x, y)\n layout.bounds.contains?(x - element_left, y - element_top)\n end",
"def falls_within?(x, y)\n x >= 0 && x < x_dimension && y >= 0 && y < y_dimension\n end",
"def self_valid?(x, y)\n # get pixel movement rate\n pix = $BlizzABS.pixel\n # checks if coordinates are valid\n return (x >= 0 && x < width * pix - pix + 1 && y >= 0 && y < height * pix - pix + 1)\n end",
"def isBoundedBy(coord)\n inBox(getBox([nw_lon,nw_lat],[se_lon,se_lat]),coord)\n end",
"def map_in_range\n clean_grid\n UNITS.each do |unit|\n position = MAP[unit.y][unit.x]\n position.occupied = true\n if unit.team == 'G'\n position.goblin_in_grid = true\n position.up.goblin_in_range = true if position.up.type == '.'\n position.right.goblin_in_range = true if position.right.type == '.'\n position.down.goblin_in_range = true if position.down.type == '.'\n position.left.goblin_in_range = true if position.left.type == '.'\n else\n position.elf_in_grid = true\n position.up.elf_in_range = true if position.up.type == '.'\n position.right.elf_in_range = true if position.right.type == '.'\n position.down.elf_in_range = true if position.down.type == '.'\n position.left.elf_in_range = true if position.left.type == '.'\n end\n end\nend",
"def filled?(x, y)\n @grid[x][y].value != 0\n end",
"def pixel_in?(x, y, precise = false)\n return false unless k_sprite\n precise ? k_sprite.precise_in?(x, y) : k_sprite.in?(x, y)\n end",
"def check_bounds(value)\n return value >= self.bound.lower_bound && value <= self.bound.upper_bound\n end",
"def solid?(x, y)\n if @tiles.length <= x / (60*LEVEL_SCALE) or @tiles[0].length <= y / (60*LEVEL_SCALE)\n return true\n end\n y < 0 || x < 0 || x > @window_width || @tiles[x / (60*LEVEL_SCALE)][y / (60*LEVEL_SCALE)]\n end",
"def out_of_bounds?(x,y)\n x < 0 || y < 0 || x > @size - 1 || y > @size - 1\n end",
"def can_clear? ( x, y )\n !self[x][y].visible && \n !self[x][y].mine && \n self[x][y].nearby_mines == 0\n end",
"def pos_rect_nt?(x, y, rect)\r\r\n pos_rect?(x, y, rect) && !@through\r\r\n end",
"def valid_location(x, y)\n return (x >= 0) && (x < Settings.get_horizontal_size) && (y >= 0) && (y < Settings.get_vertical_size)\n end",
"def rover_in_bounds?(coordinate_x, coordinate_y)\n coordinate_x <= boundary_x && coordinate_y <= boundary_y && coordinate_x >= 0 && coordinate_y >= 0\n end",
"def looping_position_check(bitmap, point1)\n if Looping_Background\n plus_x = (Graphics.width - bitmap.width)/2\n plus_y = (Graphics.height - bitmap.height)/2\n else\n plus_x = Graphics.width / 2\n plus_y = Graphics.height / 2\n end\n if point1\n @point1.set(*initpos_1)\n @point1.x += plus_x\n @point1.y += plus_y\n else\n @point2.set(*initpos_2)\n @point2.x += plus_x\n @point2.y += plus_y\n end\n end",
"def within_drawn? x1, y1, x2, y2\n ((x2 - @origin.x) < x1 && x1 < (x2 - origin.x + size.x) && (y2 - @origin.y) < y1 && y1 < (y2 - origin.y + size.y))\nend",
"def update_canvas()\n for x in 0...$width\n for y in 0...$height\n \n neighbor_count = count_neighbors(x, y)\n\n if $canvas[x][y] == 1\n if neighbor_count < 2 or neighbor_count > 3\n $canvas[x][y] = 0\n end\n else\n if neighbor_count == 3\n $canvas[x][y] = 1\n end\n end\n end\n end\nend",
"def check_encompassed_area\n @set_upper_area_sprite = false\n top_left, bot_right = get_edge_corner_dis\n last_x, last_y, copy_region = nil, nil, 0\n map_xd, map_yd = $game_map.display_x * 32, $game_map.display_y * 32\n ##total_height = (self.height + @character.jump_height).round\n total_height = (self.oy).round\n self.width.times do |x|\n xp = map_xd.to_i + top_left[0] + x\n unless xp / 32 == last_x\n last_x = xp / 32\n last_y, copy_region = nil, 0\n total_height.times do |y|\n yp = map_yd.to_i + bot_right[1] + @character.jump_height - y\n next if yp.to_i / 32 == last_y\n last_y = yp.to_i / 32\n if last_y == (@character.screen_y + map_yd).to_i / 32\n#~ if last_y == (@character.screen_y + @character.jump_height +\n#~ map_yd).to_i / 32\n break if $game_map.terrain_tag(last_x, last_y) == UpperTerrain\n next\n end\n next if $game_map.terrain_tag(last_x, last_y) != UpperTerrain\n copy_region = [self.height, total_height - y + 1].min\n set_upper_sprite\n break\n end\n end\n next if copy_region == 0\n rect = Rect.new(src_rect.x + x, src_rect.y, 1, copy_region)\n @upper_area_sprite.bitmap.blt(x, 0, self.bitmap, rect)\n self.bitmap.clear_rect(rect)\n end\n if !@set_upper_area_sprite && @upper_area_sprite\n @upper_area_sprite.visible = false\n end\n end",
"def can_place? x, y\n x >= 0 and x < @max_x and y >= 0 and y < @max_y and !object_at?(x, y)\n end",
"def is_safe_place?(x, y)\n x.between?(0, @width) and y.between?(0, @height)\n end",
"def cell_in_grid(y, x)\n return y >= 0 && x >= 0 && y < $grid.length && x < $grid.length\nend",
"def map_bounds_contain_marker_bounds\n \tresult = false\n\tif mapContainsPoint(@marker_bounds[\"n\"], @marker_bounds[\"e\"]) && mapContainsPoint(@marker_bounds[\"s\"], @marker_bounds[\"w\"])\n\t\tresult = true\n\tend\n\treturn result\nend",
"def on_board?(*args)\n x, y, length, direction = args.flatten\n\n x_max = x\n y_max = y\n case direction\n when :across\n x_max = x + length\n when :down\n y_max = y + length\n end\n\n @x_range.cover?(x) && @y_range.cover?(y) && @x_range.cover?(x_max) && @y_range.cover?(y_max)\n end",
"def set( x, y, number=nil )\n correct = (0..@size_pow-1).to_a\n if ( correct.include? x ) && ( correct.include? y) then\n @board[x][y] = number\n return true\n else\n puts \"Set error, wrong coordinates!\"\n false\n end\n end",
"def _inbounds(index,matrix)\n if index[0] > matrix.row_size or index[0] < 0 or index[1] > matrix.column_size or index[1] < 0\n return false\n end\n return true\n end",
"def update!(**args)\n @bounds = args[:bounds] if args.key?(:bounds)\n end",
"def white_owned(x,y)\n if @b[x][y] == @WP || @b[x][y] == @WB || @b[x][y] == @WK || @b[x][y] == @WR || @b[x][y] == @WQ || @b[x][y] == @WKg\n return true\n else\n return false\n end\n end",
"def contains_mine?(row, col)\n grid[row][col].fill == 1\n end",
"def position(val)\n @inside = true\n return val if (low..high).cover? val\n @inside = false\n return constrain(val, low, high)\n end",
"def in_bounds?(side_a, side_b, side_c, perim, max_leg, max_hypot, max_perim)\n perim <= max_perim && side_a <= max_leg && side_b <= max_leg && side_c <= max_hypot\nend",
"def scan\n\t\t\t(1..MAX_Y_AXIS).each do |y|\n\t\t\t\treset_values\n\t\t\t\t(1..MAX_X_AXIS).each do |x|\n\n\t\t\t\t\timg_pixel_color = @image.pixel_color(x, y)\n\t\t\t\t\t\n\t\t\t\t\tif img_pixel_color.red <= COLOR_THRESHOLD\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t@left_eye_width = @left_eye_width + 1 if @glabella_width < 1\n\t\t\t\t\t\twrite_to_image(x, y, 'purple')\n\n\t\t\t\t\t\tif @left_eye_width >= MIN_EYE_WIDTH and @left_eye_width < MAX_EYE_WIDTH and @glabella_width > @left_eye_width and @glabella_width < (@left_eye_width * 2) and @left_eye_width >= MIN_EYE_WIDTH\n\t\t\t\t\t\t\treturn true if check_glabella(x, y)\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t@glabella_width = 0\t\t\t\t\t\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\t# we've encountered a white pixel but cannot assume that it is a glabella\n\t\t\t\t\t\t# so we do a count of white pixels across before it encounters another black pixel\n\t\t\t\t\t\t@glabella_start_x_position = x if @glabella_width == 0\n\t\t\t\t\t\t@glabella_start_y_position = y if @glabella_width == 0\n\t\t\t\t\t\t@glabella_width = @glabella_width + 1\n\t\t\t\t\t\twrite_to_image(x, y, '#eee')\n\t\t\t\t\tend\t\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn false\n\t\tend",
"def overPixel?(sprite)\n return false if !sprite.bitmap\n bitmap=sprite.bitmap\n return false if !self.over?(sprite)\n bx=@x-sprite.x\n by=@y-sprite.y\n if defined?(sprite.viewport) && sprite.viewport\n bx-=sprite.viewport.rect.x\n by-=sprite.viewport.rect.y\n end\n pixel=bitmap.get_pixel(bx,by)\n return true if pixel.alpha>0\n return false\n end",
"def check(x, y)\n calc(RADIUS, const, x + y * 1i)\n end",
"def insideScreen(delta)\n ((@x + @image.width + delta) < $windowW and (@x - delta) > 0)\n end",
"def map_passable_rect?(x, y, d, rect)\r\r\n $game_map.passable_rect?(x, y, d, rect)\r\r\n end",
"def inside_board?(r, c)\n (r >= 0) && (c >= 0) && (r <= @row_limit) && (c <= @column_limit)\n end",
"def point_in_canvas(x, y)\n [*1..canvas.size - 2].include?(y) && [*1..canvas.first.size - 2].include?(x)\n end",
"def coordinates_inside_box?(x_idx, y_idx)\n (x_idx >= 0 && x_idx < width) && (y_idx >= 0 && y_idx < height)\n end",
"def pixel_counter?(x, y)\n # no counter if map ID is invalid\n return false if @map_id == 0\n # get pixel movement rate and initialize result\n pix, result = $BlizzABS.pixel, false\n # iterate through all layers and check each modified tile (pixel movement)\n BlizzABS::Cache::MapLayers.each {|i| (0...pix).each {|j| (0...pix).each {|k|\n # if tile is not valid ID\n if data[(x+j)/pix, (y+k)/pix, i] == nil\n # no counter\n return false\n # if counter bit is set\n elsif @passages[data[(x+j)/pix, (y+k)/pix, i]] & 0x80 == 0x80\n # counter\n result = true\n else\n # no counter\n return false\n end}}\n # return the result\n return result}\n # no counter\n return false\n end",
"def center_origins\n return if !self.bitmap\n self.ox = self.bitmap.width / 2\n self.oy = self.bitmap.height / 2\n end",
"def hit_me? x, y\n if @orientation == 0\n if x != @rowStart || (y < @colStart && y > @colEnd)\n return false\n end\n elsif @orientation == 1\n if y != @colStart || ( x < @rowStart && x > @rowEnd)\n return false\n end\n end\n\n shrink_ship\n return true\n end"
] | [
"0.67354137",
"0.6292363",
"0.62778795",
"0.62744015",
"0.62700045",
"0.6262882",
"0.61338806",
"0.61217105",
"0.6086573",
"0.60591453",
"0.60400254",
"0.60179925",
"0.5917836",
"0.59105843",
"0.5884694",
"0.58763045",
"0.5857608",
"0.58433056",
"0.58242935",
"0.5818207",
"0.58136874",
"0.5812238",
"0.5800483",
"0.5789105",
"0.577884",
"0.5770032",
"0.57660735",
"0.57187426",
"0.5693373",
"0.5689723",
"0.56747586",
"0.5669078",
"0.5666979",
"0.56587726",
"0.56433696",
"0.5637814",
"0.5630739",
"0.56254494",
"0.56130457",
"0.559664",
"0.55934626",
"0.5588053",
"0.5561521",
"0.5561521",
"0.5556001",
"0.5555575",
"0.5555575",
"0.5549413",
"0.5549084",
"0.5544484",
"0.55433154",
"0.5541328",
"0.5535291",
"0.55255353",
"0.5511027",
"0.54917437",
"0.5484152",
"0.5481366",
"0.5471509",
"0.5467412",
"0.5460039",
"0.5450628",
"0.54498035",
"0.54487634",
"0.54485184",
"0.5442077",
"0.543944",
"0.5429213",
"0.5424392",
"0.54129815",
"0.54108924",
"0.53947335",
"0.5375914",
"0.5368053",
"0.53637147",
"0.5359552",
"0.5354857",
"0.53503513",
"0.5350176",
"0.53310925",
"0.5329646",
"0.53238124",
"0.53221244",
"0.53186053",
"0.5315864",
"0.5310799",
"0.5283716",
"0.5283607",
"0.5273658",
"0.5272817",
"0.5252191",
"0.5248053",
"0.5246224",
"0.5242699",
"0.5225789",
"0.5212473",
"0.5208174",
"0.520715",
"0.52033985",
"0.5202524"
] | 0.6581896 | 1 |
Flush the property hash once done. | def flush
debug("[flush]")
if @property_hash.delete(:needs_change)
notice("Properties changed - updating rule")
update
end
@property_hash.clear
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flush\n @property_hash.clear\n end",
"def flush\n @property_hash.clear\n end",
"def flush\n @property_hash.clear\n end",
"def flush\n flush_instance\n\n # Collect the resources again once they've been changed (that way `puppet\n # resource` will show the correct values after changes have been made).\n @property_hash = read_instance\n end",
"def flush\n self.wait_for_state_transitions\n self.flush_when_ready\n @property_flush = {}\n end",
"def flush\n return if @property_hash.empty?\n # clear this on properties, in case it's set from a previous\n # run of a different corosync type\n cmd = [command(:pcs), 'resource', 'defaults', \"#{@property_hash[:name]}=#{@property_hash[:value]}\"]\n self.class.run_command_in_cib(cmd, @resource[:cib])\n end",
"def flush\n @h.flush\n end",
"def flush\n to_be_processed = nil\n @hash_lock.synchronize do\n to_be_processed = @hash\n @hash = {}\n end\n process_hash(to_be_processed)\n end",
"def flush\n return if @property_hash.empty?\n\n updated = \"location #{@property_hash[:name]} #{@property_hash[:primitive]}\"\n\n if feature?(:discovery)\n updated << \" resource-discovery=#{@property_hash[:resource_discovery]}\" unless @property_hash[:resource_discovery].nil?\n end\n\n unless @property_hash[:node_name].nil?\n updated << \" #{@property_hash[:score]}: #{@property_hash[:node_name]}\"\n end\n\n unless @property_hash[:rules].nil?\n @property_hash[:rules].each do |rule_item|\n name = rule_item.keys.first\n rule = rule_item[name]\n\n score = rule['score-attribute'] || rule['score']\n\n boolean_op = rule['boolean-op'] || 'and'\n expression = self.class.rule_expression(name, rule['expression'], boolean_op)\n\n updated << \" rule $id=\\\"#{name}\\\"\"\n updated << \" $role=\\\"#{rule['role']}\\\"\" unless rule['role'].nil?\n updated << \" #{score}: #{expression.join(' ')}\"\n end\n end\n\n debug(\"Loading update: #{updated}\")\n Tempfile.open('puppet_crm_update') do |tmpfile|\n tmpfile.write(updated)\n tmpfile.flush\n self.class.run_command_in_cib(['crm', 'configure', 'load', 'update', tmpfile.path.to_s], @resource[:cib])\n end\n end",
"def flush\n unless @property_hash.empty?\n # Remove existing location\n cmd = ['pcs', 'constraint', 'resource', 'remove', @resource[:name]]\n PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource[:cib], false)\n cmd = ['pcs', 'constraint', 'location', 'add', @property_hash[:name], @property_hash[:primitive], @property_hash[:node_name], @property_hash[:score]]\n cmd << \"resource-discovery=#{@property_hash[:resource_discovery]}\" unless @property_hash[:resource_discovery].nil?\n PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource[:cib])\n end\n end",
"def flush\n data = {}\n end",
"def destroy\n @property_flush[:ensure] = :absent\n end",
"def sync\n return if @no_sync\n File.open( @filename, \"w\" ) do |f|\n Marshal.dump( @hash, f )\n end\n end",
"def flush\n return if @property_hash.empty?\n\n if @resource.should(:primitive)\n target = @resource.should(:primitive)\n elsif @resource.should(:group)\n target = @resource.should(:group)\n else\n raise Puppet::Error, 'No primitive or group'\n end\n updated = 'clone '\n updated << \"#{@resource.value(:name)} \"\n updated << \"#{target} \"\n meta = []\n {\n clone_max: 'clone-max',\n clone_node_max: 'clone-node-max',\n notify_clones: 'notify',\n globally_unique: 'globally-unique',\n ordered: 'ordered',\n interleave: 'interleave'\n }.each do |property, clone_property|\n meta << \"#{clone_property}=#{@resource.should(property)}\" unless @resource.should(property) == :absent\n end\n updated << 'meta ' << meta.join(' ') unless meta.empty?\n debug \"Update: #{updated}\"\n Tempfile.open('puppet_crm_update') do |tmpfile|\n tmpfile.write(updated)\n tmpfile.flush\n cmd = [command(:crm), 'configure', 'load', 'update', tmpfile.path.to_s]\n self.class.run_command_in_cib(cmd, @resource.value(:cib))\n end\n end",
"def also_flush(*properties)\n properties.each do |prop|\n @property_flush[prop] = resource[prop] if resource[prop]\n end\n end",
"def flush\n debug \"Call: flush on cs_resource '#{@resource[:name]}'\"\n return if @property_hash.empty?\n self.class.block_until_ready\n\n unless @property_hash[:operations].empty?\n operations = ''\n @property_hash[:operations].each do |o|\n op_namerole = o[0].to_s.split(':')\n if op_namerole[1]\n o[1]['role'] = o[1]['role'] || op_namerole[1] # Hash['role'] has more priority, than Name\n end\n operations << \"op #{op_namerole[0]} \"\n o[1].each_pair do |k,v|\n operations << \"#{k}=#{v} \"\n end\n end\n end\n\n unless @property_hash[:parameters].empty?\n parameters = 'params '\n @property_hash[:parameters].each_pair do |k,v|\n parameters << \"#{k}=#{v} \"\n end\n end\n\n unless @property_hash[:metadata].empty?\n metadatas = 'meta '\n @property_hash[:metadata].each_pair do |k,v|\n metadatas << \"#{k}=#{v} \"\n end\n end\n\n updated = 'primitive '\n updated << \"#{@property_hash[:name]} #{@property_hash[:primitive_class]}:\"\n updated << \"#{@property_hash[:provided_by]}:\" if @property_hash[:provided_by]\n updated << \"#{@property_hash[:primitive_type]} \"\n updated << \"#{operations} \" unless operations.nil?\n updated << \"#{parameters} \" unless parameters.nil?\n updated << \"#{metadatas} \" unless metadatas.nil?\n\n if @property_hash[:complex_type]\n complex_name = \"#{@property_hash[:complex_type]}_#{@property_hash[:name]}\"\n crm_cmd_type = @property_hash[:complex_type].to_s == 'master' ? 'ms' : 'clone'\n debug \"Creating '#{crm_cmd_type}' parent named '#{complex_name}' for #{@property_hash[:name]} resource\"\n updated << \"\\n\"\n updated << \" #{crm_cmd_type} #{complex_name} #{@property_hash[:name]} \"\n unless @property_hash[:ms_metadata].empty?\n updated << 'meta '\n @property_hash[:ms_metadata].each_pair do |k,v|\n updated << \"#{k}=#{v} \"\n end\n end\n end\n\n debug(\"Will update tmpfile with '#{updated}'\")\n Tempfile.open('puppet_crm_update') do |tmpfile|\n tmpfile.write(updated)\n tmpfile.flush\n apply_changes(@resource[:name], tmpfile, 'resource')\n end\n end",
"def flush\n unless @property_hash.empty?\n self.class.block_until_ready\n updated = \"location \"\n updated << \"#{@property_hash[:name]} #{@property_hash[:primitive]} \"\n if !@property_hash[:node_name].nil?\n updated << \"#{@property_hash[:node_score]}: \"\n updated << \"#{@property_hash[:node_name]}\"\n elsif !@property_hash[:rules].nil?\n debug(\"Evaluating #{@property_hash.inspect}\")\n @property_hash[:rules].each do |rule_hash|\n updated << \"rule \"\n #updated << \"$id-ref = #{rule_hash[:id_ref]}\"\n updated << \"$role = #{rule_hash[:role]} \" if !rule_hash[:role].nil?\n updated << \"#{rule_hash[:score]}: \"\n\n if !rule_hash[:expressions].nil?\n rule_hash[:expressions].each do |expr|\n updated << \"#{expr[:attribute]} \"\n updated << \"#{expr[:type]}:\" if !expr[:type].nil?\n updated << \"#{expr[:operation]} \"\n updated << \"#{expr[:value]} \" if !expr[:value].nil?\n end\n end\n if !rule_hash[:date_expressions].nil?\n rule_hash[:date_expressions].each do |date_expr|\n updated << \"date \"\n if !date_expr[:date_spec].nil?\n updated << \"date_spec \"\n date_expr[:date_spec].each{|key,value| updated << \"#{key}=#{value} \" }\n else\n updated << \"#{date_expr[:operation]} \"\n if date_expr[:operation] == 'in_range'\n updated << \"start=#{date_expr[:start]} \"\n if date_expr[:duration].nil?\n updated << \"end=#{date_expr[:end]} \"\n else\n date_expr[:duration].each{|key,value| updated << \"#{key}=#{value} \" }\n end\n elsif date_expr[:operation] == 'gt'\n updated << \"#{date_expr[:start]} \"\n elsif date_expr[:operation] == 'lt'\n updated << \"#{date_expr[:end]} \"\n end\n end\n end\n end\n rule_number = 0\n rule_number += rule_hash[:expressions].size if !rule_hash[:expressions].nil?\n rule_number += rule_hash[:date_expressions].size if !rule_hash[:date_expressions].nil?\n updated << \"#{rule_hash[:boolean].to_s} \" if rule_number > 1\n end\n end\n\n debug(\"creating location with command\\n #{updated}\\n\")\n\n Tempfile.open('puppet_crm_update') do |tmpfile|\n tmpfile.write(updated.rstrip)\n tmpfile.flush\n apply_changes(@resource[:name],tmpfile,'location')\n end\n end\n end",
"def reset_property_values\n write_attribute(:property_values, {})\n end",
"def flush\n write_cache if @dirty\n @dirty = false\n end",
"def flush\n @resolves.each(&:flush)\n @value = nil\n end",
"def flush!\n @_cache = {}\n end",
"def hash_end(_key)\n save_batch\n end",
"def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end",
"def flush\n unless @property_hash.empty?\n # Remove existing location\n cmd = ['pcs', 'constraint', 'resource', 'remove', @resource[:name]]\n Puppet::Provider::Pacemaker.run_command_in_cib(cmd, @resource[:cib], false)\n cmd = ['pcs', 'constraint', 'location', 'add', @property_hash[:name], @property_hash[:primitive], @property_hash[:node_name], @property_hash[:score]]\n cmd << \"resource-discovery=#{@property_hash[:resource_discovery]}\" unless @property_hash[:resource_discovery].nil?\n Puppet::Provider::Pacemaker.run_command_in_cib(cmd, @resource[:cib])\n\n unless @property_hash[:rule].nil?\n score_param = [] # default value: score=INFINITY\n rule_params = []\n @property_hash[:rule].each_pair do |k, v|\n if k == 'expression' # expression\n rule_params = [v['attribute'], v['operation'], v['value']]\n elsif k =~ /score/ # score or score-attribute\n score_param = \"#{k}=#{v}\"\n end\n end\n cmd_rule = [command(:pcs), 'constraint', 'location', @property_hash[:primitive], 'rule', score_param, rule_params]\n Puppet::Provider::Pacemaker.run_command_in_cib(cmd_rule, @resource[:cib])\n end\n end\n end",
"def flush\n manager.flush\n end",
"def flush\n remove!\n store!\n end",
"def flush # :nodoc:\n end",
"def __finalize__\n\t\t@__hash__.each { |k,v|\n\t\t\t@__hash__[k] = v.call if v.respond_to?(:call)\n\t\t}\n\tend",
"def reset_properties(hash)\n @table.keys.each{|key| remove_ostruct_member(key)}\n hash.each{|key,value| new_ostruct_member(key,value)}\n rest_reset_properties\n end",
"def flush\n @handle.flush\n end",
"def clear_cache\n property_cache.clear\n end",
"def flushall; end",
"def flush\n @resolves.each { |r| r.flush }\n @value = nil\n end",
"def flush\n @facts.each { |name, fact| fact.flush }\n end",
"def flush\n @queued = {}\n end",
"def flush\n @facts.each { |_name, fact| fact.flush }\n @external_facts_loaded = nil\n end",
"def destroy\n @property_hash[:ensure] = :absent\n end",
"def clear\n @hash.clear\n self\n end",
"def flush\n protect { @secondary.flush }\n end",
"def flush\n self.class.flush\n end",
"def flush\n flush_field\n flushed_fields = record_fields\n initialize\n flushed_fields\n end",
"def clear_properties\n Config::Collection.clear\n end",
"def properties\n if @property_hash.empty?\n @property_hash[:ensure] = :failed if @property_hash.empty?\n end\n @property_hash.dup\n end",
"def flush!\n @redis.flushdb\n end",
"def flush\n end",
"def flush\n end",
"def flush\n end",
"def flush\n end",
"def flush\n end",
"def update\n @p.transaction do\n @p['hash'] = @hash\n end\n end",
"def initialize(value={})\n super(value)\n @property_flush = {}\n end",
"def initialize(value={})\n super(value)\n @property_flush = {}\n end",
"def initialize(value={})\n super(value)\n @property_flush = {}\n end",
"def initialize(value={})\n super(value)\n @property_flush = {}\n end",
"def flush(ctx)\n ctx.last = nil\n end",
"def finalize!\n super\n keys.each { |key| set(key, resolve_value(key)) }\n end",
"def flush; end",
"def flush; end",
"def flush; end",
"def flush; end",
"def flush; end",
"def flush() end",
"def flush() end",
"def flush() end",
"def flush\n if @carry_over\n @contents['info']['pieces'] << Digest::SHA1.digest( @carry_over )\n end\n unless @contents['creation date']\n @contents['creation date'] = Time.now.tv_sec\n end\n @io << @contents.bencode\n @io.flush\n self\n end",
"def __flush\n @_undies_io.current.flush\n end",
"def save_hashes_for_write\n \n end",
"def flush\n return if @property_hash.empty?\n\n if @property_hash[:new] == false\n debug('Removing order directive')\n cmd = [command(:pcs), 'constraint', 'remove', @resource[:name]]\n self.class.run_command_in_cib(cmd, @resource[:cib])\n end\n\n cmd = [command(:pcs), 'constraint', 'order']\n items = @property_hash[:first].split(':')\n cmd << items[1]\n cmd << items[0]\n cmd << 'then'\n items = @property_hash[:second].split(':')\n cmd << items[1]\n cmd << items[0]\n cmd << \"kind=#{@property_hash[:kind]}\"\n cmd << \"id=#{@property_hash[:name]}\"\n cmd << \"symmetrical=#{@property_hash[:symmetrical]}\"\n self.class.run_command_in_cib(cmd, @resource[:cib])\n end",
"def save\n write_properties\n notify(EVENT_SAVE, self)\n end",
"def clear_changes!\n remove_instance_variable(:@original_hash) if defined?(@original_hash)\n end",
"def flush()\n #This is a stub, used for indexing\n end",
"def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end",
"def _refresh_set_values(hash)\n @associations.clear if @associations\n super\n end",
"def save_properties!(headers={})\n @service.save_blob_properties(self, headers)\n end",
"def flushing(*properties, &block)\n match_values = {}\n match_values = properties.pop if properties.last.is_a? Hash\n\n # IF BOTH:\n # 1) EITHER there are no properties to match -OR-, if there are\n # they should have at least one item in common with the actual @property_flush set\n # 2) all hash property matches matches the actual flush value\n if ((\n properties.empty? || (@property_flush.keys & properties).any?\n ) && match_values.all? {|p, v| @property_flush[p] == v })\n return_value = block.call(*properties.collect {|p| @property_flush[p]})\n\n if match_values[:ensure]\n goal = match_values[:ensure]\n if goal == :present and aws_item.nil?\n @property_hash[:aws_item] = return_value\n end\n wait_until do\n self.class.get_ensure_state(aws_item) == goal\n end\n self.wait_for_state_transitions\n end\n end\n end",
"def finalize!\n @finalized = true\n self\n end",
"def flush\n #\n end",
"def finalize!\n @_values.freeze\n end",
"def clear\n hashed.clear\n list.clear\n end",
"def flush\n end",
"def flush\n end",
"def flush\n end",
"def flush\n end",
"def local_flush\n end",
"def flush!\n keys, filename = save_keys\n push_to_s3!(filename) if @push_to_s3\n delete!(keys)\n end",
"def flush!\n @worker.flush!\n end",
"def finalize\n @buffer.each_key do |bucket|\n write_and_flush bucket\n end\n clear_buffer!\n nil\n end",
"def _refresh_set_values(hash)\n @deserialized_values.clear if @deserialized_values\n super\n end",
"def flush\n @head.flush\n @txns.flush\n end",
"def clear\n @hash.del\n @index.del\n end",
"def flush\n redis.del(bucket_key)\n end",
"def flush_buckets\n\n count = 0\n\n synchronize do\n\n @buckets.each do |k, v|\n v.flush\n count += 1\n end\n @buckets.clear\n end\n\n linfo { \"flush_buckets() flushed #{count} buckets\" } \\\n if count > 0\n end",
"def flush(store)\n open_db\n\n store.each do |k, v|\n write_key(store, k)\n end\n\n @file.close\n end",
"def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end",
"def reset\n @config = {}\n write_config\n end",
"def flush_writes\n sync(:@queued_for_write)\n\n @fog.flush_writes\n @filesystem.flush_writes\n\n @queued_for_write = {}\n end",
"def flush\n return if @cmds.nil? || @cmds.empty?\n str = (@cmds << 'commit' << 'exit').join(\"\\n\")\n @cmds = []\n @property_hash.clear\n\n command = \"#{command(:cfg)} -z #{@resource[:name]} -f -\"\n r = exec_cmd(cmd: command, input: str)\n raise ArgumentError, _('Failed to apply configuration') if r[:exit] != 0 || r[:out].include?('not allowed')\n end",
"def flush\n Puppet.debug(self.class.to_s.split('::').last + ': Calling flush method : ')\n if @property_hash != {}\n response, status_code, headers = Puppet::Provider::Cudawaf.put('SecurityPolicy', @resource[:name], message(resource), {})\n end\n\n [response, status_code, headers]\n end",
"def flush\n # NOOP\n end",
"def flush\n # NOOP\n end"
] | [
"0.8413692",
"0.8413692",
"0.8413692",
"0.71584415",
"0.70628494",
"0.67690057",
"0.6648237",
"0.65687156",
"0.65156287",
"0.6180863",
"0.6067176",
"0.60429865",
"0.60282236",
"0.5885799",
"0.58702165",
"0.5868587",
"0.5849365",
"0.58389866",
"0.5838821",
"0.5763673",
"0.57543254",
"0.5740707",
"0.57127064",
"0.5703458",
"0.57005167",
"0.56736386",
"0.5652583",
"0.56334955",
"0.5622395",
"0.5609104",
"0.56076825",
"0.5573176",
"0.55727893",
"0.55659795",
"0.5521797",
"0.5512126",
"0.54999936",
"0.5486316",
"0.54642785",
"0.54365635",
"0.5417549",
"0.5414808",
"0.54142034",
"0.5407284",
"0.5390365",
"0.5390365",
"0.5390365",
"0.5390365",
"0.5390365",
"0.5385121",
"0.5377565",
"0.5377565",
"0.5377565",
"0.5377565",
"0.5374249",
"0.53589064",
"0.53566796",
"0.53566796",
"0.53566796",
"0.53566796",
"0.53566796",
"0.53469056",
"0.53469056",
"0.53469056",
"0.5326017",
"0.5325721",
"0.5313817",
"0.5312424",
"0.53095883",
"0.5280004",
"0.5279485",
"0.5266848",
"0.52659076",
"0.52574205",
"0.52452403",
"0.5202451",
"0.51995695",
"0.5198908",
"0.5197895",
"0.5196559",
"0.5196559",
"0.5196559",
"0.5196559",
"0.5194007",
"0.519192",
"0.51844674",
"0.51723355",
"0.5171888",
"0.51709294",
"0.51630586",
"0.51586473",
"0.51550615",
"0.5151883",
"0.51511663",
"0.51497185",
"0.5147107",
"0.5144336",
"0.5130466",
"0.5127441",
"0.5127441"
] | 0.74039364 | 3 |
randomly generates an image from template (random values are normally distributed with mean = characetristic , deviation = sigma) | def create_sample_image_from_template(image_template, sigma)
random_characteristics = image_template.ideal_characteristics.map do |val|
deviated = RandomGaussian.new(val, sigma).rand
deviated = 0.0 if deviated < 0
deviated = 1 if deviated > 1
deviated
end
# values = image_template.ideal_characteristics.each { |val| values << val + 5*rand(sigma) }
ImageSample.new(image_template.image_class, random_characteristics)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate\n MiniMagick::Tool::Convert.new do |i|\n i.font random_font\n i.size image_size\n i.pointsize config[:font_size]\n i.fill config[:font_color]\n i.gravity \"center\"\n i.canvas config[:background]\n i.draw \"text 0,0 '#{text}'\"\n i.noise + \"Gaussian\"\n i << \"#{config[:format]}:-\"\n end\n end",
"def realistic_random(n, wmin, wmax, pmin, pmax, c, seed)\n str = \"# realistic random -- n: #{n}; wmin: #{wmin}; wmax: #{wmax}; pmin: #{pmin}; pmax: #{pmax}; c: #{c}; seed: #{seed}\\n\"\n str << \"n: #{n}\\nc: #{c}\\n\"\n str << \"begin data\\n\"\n\n rng = Random.new(seed)\n w = (wmin..wmax).to_a.sample(n, random: rng).sort!\n p = (pmin..pmax).to_a.sample(n, random: rng).sort!\n wp = []\n n.times { |i| wp << \"#{w[i]} #{p[i]}\" }\n str << wp.shuffle!(random: rng).join(\"\\n\") << \"\\n\"\n str << \"end data\\n\"\n\n str\nend",
"def gaussian(mean, stddev)\n theta = 2 * Math::PI * rand\n rho = Math.sqrt(-2 * Math.log(1 - rand))\n scale = stddev * rho\n [mean + scale * Math.cos(theta), mean + scale * Math.sin(theta)]\nend",
"def choose_image\n \"banners/#{ rand(35) + 1 }.jpg\"\n end",
"def generate_random_images\n file_path = @settings[\"image_path\"]\n\n #clear old cache\n if @settings[\"destroy_captcha_images\"]\n ScalableCaptchaData.connection.execute(\"TRUNCATE TABLE #{ScalableCaptchaData.table_name}\")\n\n #clear local directory for images\n FileUtils.rm_r(file_path) if File.exists? file_path\n end\n \n FileUtils.mkdir file_path unless File.exists? file_path\n \n #generate image accordingly to random number ... and this should be done only once.\n generated_image = Magick::Image.new(110, 30) \n\n @settings[\"image_pool\"].to_i.times do\n @image = generated_image.clone\n \n value = generate_scalable_captcha_data(@settings[\"image_options\"][\"code_type\"])\n key = Digest::SHA1.hexdigest(Time.now.to_s + rand.to_s)\n\n data = ScalableCaptchaData.find_by_key(key) || ScalableCaptchaData.new(:key => key)\n data.value = eval(value)\n data.save\n\n @scalable_captcha_image_options = {\n :scalable_captcha_key => key,\n :color => \"darkblue\",\n :distortion => ScalableCaptcha::ImageHelpers.distortion(@settings[\"image_options\"][\"distortion\"]),\n :image_style => ScalableCaptcha::ImageHelpers.image_style(@settings[\"image_options\"][\"image_style\"])\n }\n set_scalable_captcha_image_style(value)\n\n #save image to local file\n @image = @image.add_noise(Magick::ImpulseNoise)\n @image.write(\"#{@settings[\"image_path\"]}/#{data.id}.gif\")\n puts \"generated: #{@settings[\"image_path\"]}/#{data.id}.gif\"\n sleep(@settings[\"sleep_time\"].to_i)\n end\nend",
"def random_default_image\n Random.new.rand(1..6).to_s + '.jpg'\n end",
"def random_image(keyword)\n return { error: 'Please set KEY to environment variable.' } if key_is_ng?\n return { error: 'Please set CSE_ID to environment variable.' } if cse_id_is_ng?\n\n choice(keyword)\n end",
"def random_image(query = 'safe, cute', nsfw = false)\n img = get(url: 'search/images', query: \"q=#{query.present? ? query : 'safe, cute'}&sf=random&per_page=1\", nsfw: nsfw)\n\n if img\n img_data = img['images'][0]\n image img_data.id, nsfw if img_data\n end\n end",
"def new\n\n\n # @images = Image.all.sample(6)\n @sentence = Sentence.new\n end",
"def gaussian\n theta = 2 * Math::PI * rand\n rho = Math.sqrt(-2 * Math.log(1 - rand))\n x = rho * Math.cos(theta)\n y = rho * Math.sin(theta)\n return x\nend",
"def cover\n 'http://lorempixel.com/400/300/' + %W(abstract nightlife transport).sample + '?a=' + SecureRandom.uuid\n end",
"def generate_noise_gif_for_char(char)\n image = @reference_image_hash[char]\n\n #image = image.wave(10, 100)\n image = image.add_noise(Magick::PoissonNoise)\n #image = image.rotate(5)\n #image = image.resize_to_fit(@config.char_width, @config.char_height)\n\n image\n end",
"def standard_normal_sample\n rho = Math.sqrt(-2.0 * Math.log(rand.rand))\n theta = 2 * Math::PI * rand.rand\n tfn = rand.rand > 0.5 ? :cos : :sin\n rho * Math.send(tfn, theta)\n end",
"def gen_std_breqd_instance(n, c, wmax, pmax, seed)\n r = pmax/wmax # integer division\n r_2 = r**2\n pmax_2 = pmax**2\n rng = Random.new(seed)\n s = \"# bottom right ellipse quadrant distribution-- n: #{n}; c: #{c}; wmax: #{wmax}; pmax: #{pmax}; seed: #{seed}\\n\"\n s << \"n: #{n}\\nc: #{c}\\nbegin data\\n\"\n (1..wmax).to_a.sample(n, random: rng).each do | w |\n p = pmax - Math.sqrt(pmax_2 - (w**2 * r_2)).to_i\n s << \"#{w} #{p}\\n\"\n end\n s << \"end data\\n\"\n s\nend",
"def random(tg,faulty,replacements,n)\n get_mappings(faulty,replacements).sample\nend",
"def generate_tectonic_plates\n max_radius = (width / 10) * 2.0\n\n hill_resources = [ :coal, :iron, :uranium ]\n mountain_resources = [ :coal, :iron, :uranium ]\n\n (width/4).times do\n candidates = { }\n\n radius = (width / 10) * (1.0 + Kernel::rand)\n pos = [ Kernel::rand(@maxx), Kernel::rand(@maxy) ]\n cx,cy = pos\n\n tiles = { }\n\n 1.upto(radius) do |r|\n (cx-r).upto(cx+r) do |x|\n (cy-r).upto(cy+r) do |y|\n pos = [x,y]\n next if tiles[pos]\n next unless in_range?(pos)\n\n if Kernel::rand >= r.to_f/max_radius\n tiles[pos] = true\n tile = self[pos]\n if tile[:terrain] == :grass then\n tile[:terrain] = :hills\n tile[:resource] = nil\n tile[:resource] = hill_resources[Kernel::rand(hill_resources.length - 1)] if Kernel::rand < 0.20\n tile[:resource] = :arable if tile[:resource].nil? && Kernel::rand < 0.40\n elsif tile[:terrain] == :hills then\n tile[:terrain] = :mountains\n tile[:resource] = nil\n tile[:resource] = mountain_resources[Kernel::rand(mountain_resources.length - 1)] if Kernel::rand < 0.40\n else\n tile[:terrain] = :grass\n tile[:resource] = nil\n tile[:resource] = :arable if Kernel::rand < 0.10\n tile[:resource] = :oil if Kernel::rand < 0.03\n tile[:resource] = hill_resources[Kernel::rand(hill_resources.length - 1)] if tile[:resource].nil? && Kernel::rand < 0.05\n end\n end\n end\n end\n end\n end\n end",
"def image\n r = super\n if r.nil? and not @_generating\n generate\n return super\n end\n r\n end",
"def apply(template_image)\n self.scale\n\n image = Magick::ImageList.new(self.artwork.image.path)\n\n image[0].rotate!(rotation) unless rotation.nil?\n image.resize!(self.width, self.height)\n\n center_x = template_image.columns / 2\n crop_image!(image, center_x)\n\n self.image_x += template_image.columns / 2 if self.leg == 'right'\n\n # x_copies = (image[0].columns / template[0].columns).ceil\n # y_copies = (image[0].rows / template[0].rows).ceil\n\n # To be tiling, see http://www.imagemagick.org/RMagick/doc/ilist.html#mosaic\n # tiled = Magick::ImageList.new\n # page = Magick::Rectangle.new(0,0,0,0)\n # x_copies.times do |x|\n # y_copies.times do |y|\n\n # end\n # end\n\n design_image = template_image[0].composite(image, self.image_x, self.image_y, Magick::DstOverCompositeOp)\n\n if mirror\n design_image.flop!\n design_image.composite!(image, self.image_x, self.image_y, Magick::DstOverCompositeOp)\n design_image.flop!\n end\n\n intermediate_location = \"#{Dir.tmpdir}/#{SecureRandom.hex}.png\"\n design_image.write(intermediate_location)\n intermediate_location\n end",
"def rand\n return @location + @scale * rand_std_ratio_method\n end",
"def cover\n \"http://lorempixel.com/100/150/\" +\n %w(abstract nightlife transport).sample +\n \"?a=\" + SecureRandom.uuid\n end",
"def random(normal=false)\n p = new\n p.notename_i = NOTE_NAMES_TO_I.values.rand\n p.octave = 0\n\n accidentals = []\n if normal\n accidentals = case p.notename\n when 'c', 'f' \n [0, 1]\n when 'e', 'b'\n [-1, 0]\n else [-1, 0, 1]\n end\n else\n accidentals = [-1, 0, 1]\n end\n p.accidental = accidentals.rand\n p\n end",
"def create_basic\n ImageGeneratingService.new(self, 'Basic.jpg', 'image/jpeg', 100).generate_resized(600)\n end",
"def create_random_world\n randomize_terrain\n randomize_entities\n end",
"def gaussian_rand\n u1 = u2 = w = g1 = g2 = 0 # declare\n begin\n u1 = 2 * rand - 1\n u2 = 2 * rand - 1\n w = u1 * u1 + u2 * u2\n end while w >= 1\n\n w = Math::sqrt( ( -2 * Math::log(w)) / w )\n g2 = u1 * w;\n g1 = u2 * w;\n # g1 is returned\nend",
"def generate\n (0..30).sort{ rand() } .take(@conf)\n end",
"def generate_card\n\t suit = %w[s d h c]\n\t rank = %w[1 2 3 4 5 6 7 8 9 10 j q k]\n\t #(0...size).map{ charset.to_a[rand(charset.size)] }.join\n\t suit[rand(suit.size)] + rank[rand(rank.size)] + \".gif\"\n\tend",
"def rand\n\n # select which gaussian distribution to sample from at uniform\n point = @points[SecureRandom.random_number(@points.length)]\n\n\n return unless point\n # puts \"--> #{point}\"\n\n # Select a point on X that is within the distribution.\n # We don't care about Y, it only exists to weight overlapping regions.\n x, _ = gaussian(point, @bandwidth)\n\n return x\n end",
"def rand_banner_img\n [\n 'http://song-dev.qiniudn.com/g0.jpg',\n 'http://song-dev.qiniudn.com/g1.jpg',\n 'http://song-dev.qiniudn.com/g2.jpg',\n 'http://song-dev.qiniudn.com/g3.jpg',\n 'http://song-dev.qiniudn.com/g4.jpg',\n 'http://song-dev.qiniudn.com/g5.jpg',\n 'http://song-dev.qiniudn.com/g6.jpg'\n ].sample\n end",
"def gen_captcha\n\tcaptcha = \"\"\n\t5.times { captcha << (rand(26)+65).chr }\n\thashed = Digest::MD5.hexdigest(captcha)\n\t\n\tcanvas = Magick::Image.new(80,30, Magick::HatchFill.new('#ffffff','#0169e1'))\n\n\ttext = Magick::Draw.new\n\ttext.annotate(canvas,60,25,10,0,captcha) {\n\t\t self.fill = \"#000000\"\n\t\t self.stroke = \"transparent\"\n\t\t self.pointsize = 22\n\t\t self.font_weight = Magick::BoldWeight\n\t\t self.gravity = Magick::SouthGravity\n\t}\n\t\n\tcanvas = canvas.implode(-0.4)\n\tcanvas.write($captcha_folder+hashed+\".jpg\")\n\t\n\treturn hashed\nend",
"def nostalgia; return rand end",
"def rnormal(mean, sd)\n mean + (Math.sqrt(-2 * Math.log(rand)) * Math.cos(2 * Math::PI * rand)) * sd\nend",
"def save_random_captcha(text, dataset)\n image = Magick::Image.new(160, 80)\n image.format = \"jpg\"\n image.gravity = Magick::CenterGravity\n image.background_color = 'white'\n\n draw = Magick::Draw.new\n draw.annotate(image, image.columns, image.rows, 0, 0, text) {\n self.gravity = Magick::CenterGravity\n self.pointsize = 28\n self.fill = 'darkblue'\n self.stroke = 'transparent'\n self.rotation = rand(-20..20)\n }\n\n image = image.gaussian_blur(0.0, rand)\n image = image.implode((rand(1)) / 10.0)\n image = image.swirl(rand(15))\n image = image.radial_blur(rand(5))\n image = image.add_noise(Magick::ImpulseNoise)\n image = image.wave(2 + rand(1), 20 + rand(10))\n image = image.crop(0,0,160,80)\n\n File.write(\"./captcha_dataset/#{dataset}/#{text}.jpg\", image.to_blob)\nend",
"def gaussian(mean, stddev)\n theta = 2 * Math::PI * Kernel.rand\n rho = Math.sqrt(-2 * Math.log(1 - Kernel.rand))\n scale = stddev * rho\n x = mean + scale * Math.cos(theta)\n # y = mean + scale * Math.sin(theta)\n return x\n end",
"def get_rand_circuit(name=\"circvit\")\n \n name=name.upcase.scan(/[A-Z]/).join.scan(/[^U]/).join.split(//)\n \n \n family= %w{will belief desire}\n family=family.shuffle\n \n fill = Magick::HatchFill.new(\"Transparent\", \"LightGreen\")\n \n i = Magick::ImageList.new \n i.new_image(333, 333, fill){ self.background_color = \"Transparent\" }\n gc = Magick::Draw.new\n \n \n gc.gravity(Magick::CenterGravity)\n gc.stroke(\"#33cc33\")\n gc.fill(\"#222222\")\n gc.stroke_width(20)\n gc.circle(167, 167, 167, 20)\n gc.stroke(\"#3333cc\")\n gc.fill(\"transparent\")\n gc.stroke_width(2)\n gc.circle(167, 167, 167, 25)\n gc.circle(167, 167, 167, 15)\n gc.circle(167, 167, 167, 22)\n gc.circle(167, 167, 167, 17)\n gc.draw(i)\n\n (0..name.length-1).each do |n|\n i.new_image(333, 333){ self.background_color = \"Transparent\" }\n gc = Magick::Draw.new \n gc.stroke(\"transparent\")\n gc.fill(\"transparent\")\n \n gc.pointsize = (52 + (rand(23)) )\n \n gc.gravity(Magick::CenterGravity)\n f=rand(3)\n gc.font= \"#{Rails.root}/app/assets/fonts/akho#{family[f]}.ttf\" \n gc.text((-rand(72) + rand(72)), (-rand(72) + rand(72)), name[n]).rotate(rand(360))\n gc.fill('red')\n gc.text((-rand(72) + rand(72)), (-rand(72) + rand(72)), name[n]).rotate(rand(360))\n gc.draw(i)\n \n end\n \n \n @Circuit=i.flatten_images\n @Circuit.format = 'png'\n \n \n @circuit_file = \"#{Rails.root}/tmp/circuit-#{name.join}-#{Time.now.to_i}-#{Process.pid}.png\"\n \n \n @Circuit.write('png:'+ @circuit_file)\n \n \n \n \n\n @data_uri = Base64.encode64(@Circuit.to_blob).gsub(/\\n/, \"\") \n @image_tag = '<img alt=\"preview\" src=\"data:image/png;base64,%s\">' % @data_uri\n \n end",
"def random_photo\n if params[:city] && !params[:city][:name]\n city = City.find :first, :conditions => {:name => params[:city]}\n @photo = Photo.find :first, :conditions => {:city_id => city.id}\n end\n if !@photo\n @photo = Photo.find(:first, :offset => rand(Photo.all.size))\n end\n @photo['filename'] = \"#{@photo.city.name.gsub(' ','').downcase}.jpg\"\n end",
"def gen_data(parameters, x)\n mu = parameters[:mu]\n sig2 = parameters[:sig2]\n gamma = parameters[:gamma]\n size_i = x.shape[0]\n size_n = x.shape[1]\n\n sim_data_out = N.zeros_like(x)\n\n size_i.times do |i|\n size_n.times do |n|\n next if MLRatioSolve.skip_indices.include?([i,n])\n sim_data_out[i,n] = randnorm(mu[i]/gamma[n], sig2[i]/gamma[n]**2)\n end\n end\n\n sim_data_out\n end",
"def sample\n img :src => $imgHostURL + \"/\" + $sampleImg\n end",
"def generate_test_image(file, params = {})\n # Set default size for sample test image.\n line_size = 1\n box_size = 6\n width = (box_size * 6) + (line_size * 7)\n height = (box_size * 5) + (line_size * 6)\n\n # Set parameters for image creation options.\n image_type = params[:image_type] || File.extname(file)\n bands = params[:bands] || 3\n color = params[:color] || 'rgb'\n depth = params[:depth] || 8\n cg_type = params[:cg_type] || 'adobe_rgb'\n compression = params[:compression]\n profile = params[:profile]\n\n temp_array = color_gauge_values(cg_type)\n temp_image = Vips::Image.black(width, height, bands: temp_array.first.size)\n 5.times do |i|\n b = (box_size * i) + (line_size * (i + 1))\n # d = b + box_size - line_size\n 6.times do |j|\n a = (box_size * j) + (line_size * (j + 1))\n # c = a + box_size - line_size\n colors = temp_array.shift\n temp_image = temp_image.draw_rect(colors, a, b, box_size, box_size, fill: true)\n end\n end\n\n temp_image = color.eql?('cmyk') ? temp_image.copy(interpretation: :cmyk) : temp_image.copy(interpretation: :srgb)\n\n temp_image = if color.eql?('grey') && bands == 3\n mean = temp_image.bandmean\n Vips::Image.bandjoin([mean, mean, mean])\n elsif color.eql?('grey') && bands == 1\n temp_image.bandmean\n elsif color.eql?('bin') && bands == 3\n mean = temp_image.bandmean < 128\n Vips::Image.bandjoin([mean, mean, mean])\n elsif color.eql?('bin') && bands == 1\n temp_image.bandmean < 128\n else\n temp_image\n end\n\n options = {}\n unless profile.nil?\n profile_file = File.join(Assembly::PATH_TO_IMAGE_GEM, 'profiles', \"#{profile}.icc\")\n options.merge!(profile: profile_file)\n end\n\n case image_type\n when '.tiff', '.tif'\n options.merge!(compression: compression) unless compression.nil?\n options.merge!(squash: true) if depth.eql?(1)\n temp_image.tiffsave(file, **options)\n when '.jpeg', '.jpg'\n temp_image.jpegsave(file, **options)\n else\n raise \"unknown type: #{image_type}\"\n end\nend",
"def generate(options = {})\n options.reverse_merge!(\n :fontsize => 25,\n :padding => 20,\n :color => '#000',\n :background => '#fff',\n :fontweight => 'bold',\n :rotate => true,\n :font => config['font']\n ).symbolize_keys!\n\n options[:fontweight] = case options[:fontweight]\n when 'bold' then 700\n else 400\n end\n \n text = Magick::Draw.new\n text.pointsize = options[:fontsize]\n text.font_weight = options[:fontweight]\n text.fill = options[:color]\n text.gravity = Magick::CenterGravity\n text.font = options[:font] if options[:font]\n \n #rotate text 5 degrees left or right\n text.rotation = (rand(2)==1 ? 5 : -5) if options[:rotate]\n \n metric = text.get_type_metrics(self.string)\n\n #add bg\n canvas = Magick::ImageList.new\n canvas << Magick::Image.new(metric.width+options[:padding], metric.height+options[:padding]){\n self.background_color = options[:background]\n }\n\n #add text\n canvas << Magick::Image.new(metric.width+options[:padding], metric.height+options[:padding]){\n self.background_color = 'transparent'\n }.annotate(text, 0, 0, 0, 0, self.string).wave(1, 50)\n\n #add noise\n canvas << Magick::Image.new(metric.width+options[:padding], metric.height+options[:padding]){\n p = Magick::Pixel.from_color(options[:background])\n p.opacity = Magick::MaxRGB/2\n self.background_color = p\n }.add_noise(Magick::LaplacianNoise)\n\n self.image = canvas.flatten_images.blur_image(1)\n end",
"def random_pattern\n randomish_string = ('a'..'z').to_a.shuffle.join\n randomish_color = \"%06x\" % (rand * 0xffffff)\n return GeoPattern.generate(randomish_string, color: randomish_color )\n end",
"def logo\n rand_num = rand(1..13)\n \"https://pigment.github.io/fake-logos/logos/medium/color/#{rand_num}.png\"\n end",
"def random(background = T.unsafe(nil)); end",
"def random(background = T.unsafe(nil)); end",
"def generate\n (0..@horizontal_size-1).each do |column|\n (0..@vertical_size-1).each do |row|\n val = Settings.get_random.rand(0..10)\n @map[column][row] = val > 3 ? 1 : 2\n end\n end\n end",
"def normal(mean: 1, standard_deviation: 1)\n theta = 2 * Math::PI * rand\n rho = Math.sqrt(-2 * Math.log(1 - rand))\n scale = standard_deviation * rho\n mean + scale * Math.cos(theta)\n end",
"def generate()\n\t\t# first generate at least one star\n\t\t\n\t\tcx = centerX\n\t\tcy = centerY\n\t\tstarPos = randomLocation(cx, cy, SolarSystemRadius)\n\t\tstar = generateNewCelestialBody(starPos[0], starPos[1], 'star')\n\t\t\n\t\t# possibly another star\n\t\tif rand < ProbabilitySecondStar\n\t\t\tstarPos2 = randomDistantPosition\n\t\t\tstar2 = generateNewCelestialBody(starPos2[0], starPos2[1], 'star')\n\t\tend\n\t\t\n\t\tnumPlanets = Random.rand(MedianNumPlanets-NumPlanetsVariation...MedianNumPlanets+NumPlanetsVariation)\n\t\tnumPlanets.times do\n\t\t\tplanetPos = randomDistantPosition\n\t\t\tplanet = generateNewCelestialBody(planetPos[0], planetPos[1], 'planet')\n\t\tend\n\tend",
"def diswimage(image_text)\n image_options = image_text.gsub(/#/, '').gsub(/diswimage:/, '').split(':')\n image_title = image_options[0]\n image_extension = image_options[1]\n option_count = image_options[2]\n image_width = image_options[3]\n return \"!{width: #{image_width}px}http://doitidiot.s3.amazonaws.com/#{image_title}-#{rand(option_count)+1}.#{image_extension}!\"\n end",
"def get_random()\n \n end",
"def get_random()\n \n end",
"def random_tf\n\t[TRUE, FALSE].sample\nend",
"def generate(captcha_code)\n image_width = captcha_code.length * 20 + 10\n \n cmd = []\n cmd << \"convert -size #{image_width}x40 xc:grey84 -background grey84 -fill black \"\n \n captcha_code.split(//).each_with_index do |char, i|\n cmd << \" -pointsize #{rand(8) + 15} \"\n cmd << \" -weight #{rand(2) == 0 ? '4' : '8'}00 \"\n cmd << \" -draw 'text #{5 + 20 * i},#{rand(10) + 20} \\\"#{char}\\\"' \"\n end\n \n cmd << \" -rotate #{rand(2) == 0 ? '-' : ''}5 -fill grey40 \"\n \n captcha_code.size.times do\n cmd << \" -draw 'line #{rand(image_width)},0 #{rand(image_width)},60' \"\n end\n \n cmd << \" gif:-\"\n \n image_magick_command = cmd.join\n \n `#{image_magick_command}`\n end",
"def random_figures(x=0)\n x + Kernel.rand\n end",
"def random_element\n sample\n end",
"def makePetMakeNoise\n @pet.makeNoise(rand(10))\n end",
"def random_type; end",
"def random_product_image_filename\n [\"img_1.png\",\"img_2.png\", \"img_3.png\", \"img_4.jpg\", \"img_5.jpg\", \n \"img_6.jpg\", \"img_7.jpg\", \"img_8.jpg\", \"img_9.jpg\", \"img_10.jpg\" ].shuffle.first\nend",
"def generate( type, *args )\n puts \"==> generate >#{type}< - with #{args.size} part(s) #{args.inspect}\"\n\n character = @chars[ type ]\n\n img = nil ## (by default) auto-derive width x height dimension from first image\n\n character.each_with_index do |(part_key, part),i|\n num = args[i]\n\n ## todo/check - double check if part required set to false - why? why not?\n next if num == 0 ## note: skip part if index is 0!!!\n\n attributes = if part.is_a?( Hash )\n part[:attributes]\n else ## assume array - \"inline\" compact attribute format\n part\n end\n\n attribute = attributes[ num-1 ] ## note: num starts counting at 1 (sub 1 for zero-based array index)\n raise ArgumentError, \"no >#{part_key}< part found for index #{num}; sorry\" if attribute.nil?\n\n print \"#{i} #{part_key} => #{num}\"\n print \" - #{attribute[:name]}\" if attribute.is_a?( Hash ) && attribute.has_key?( :name )\n print \"\\n\"\n\n\n img_part = if attribute.is_a?( Integer ) ## assume filename with num (as .png)\n path = \"#{@rootdir}/#{type}/#{part_key}/#{part_key}#{num}.png\"\n img_part = Image.read( path )\n elsif attribute.is_a?( Hash )\n if attribute.has_key?( :design )\n path = \"#{@rootdir}/#{attribute[:design]}.txt\"\n txt = File.open( path, 'r:utf-8') {|f| f.read }\n img_part = Image.parse( txt, colors: attribute[:colors] )\n else ## assume for now has key :path\n path = \"#{@rootdir}/#{attribute[:path]}.png\"\n img_part = Image.read( path )\n end\n else\n puts \"!! ERROR:\"\n pp part\n raise ArgumentError, \"unknown part data type; expected Integer|Hash\"\n end\n ## note: if (very) first part - auto-create empty image with size/dimensions from part\n img = Image.new( img_part.width, img_part.height ) if i==0\n img.compose!( img_part )\n end\n\n img\nend",
"def rand_point()\n \n end",
"def create_advanced\n image_service = ImageGeneratingService.new(self, 'Advanced.jpg', 'image/jpeg', 69)\n output_path = image_service.generate\n original_size_mb = File.size(output_path).to_f / 2**20\n if original_size_mb > 1.0\n image_service.generate_resized(1200)\n end\n end",
"def random_plate\n [*('a'..'z'), *('A'..'Z')].sample(5).join\n end",
"def random_x args\n (args.grid.w.randomize :ratio) * -1\nend",
"def random_x args\n (args.grid.w.randomize :ratio) * -1\nend",
"def getRndImgFromDir(hash) \n\t\tsetImgDir()\n\t\tfolder_count = getFolderCount(hash[:folder_index]) #Get folder count of directory\n\t\toutput_array = []\n\t\ti = 0;\n\t\twhile i < hash[:count] do\n\t\t hash[:entry_path] = (rand(folder_count * folder_count) % folder_count) + 1\n\t\t file_path = Dir[\"#{DEFAULT_DIRECTORY}/#{hash[:folder_index]}/#{hash[:entry_path]}/#{getRndImgFromSubDir(hash)}*\"]\n\t\t output_array << (file_path.nil? ? \"\" : file_path[0])\n\t\t i +=1;\n\t\tend\n\t\toutput_array\n\t\t\n\t\t#get count of subfolders\n\t\t#Get random value\n\t\t#Call Subdir to get random image\n\tend",
"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 logo\n rand_num = Random.rand(76) + 1\n \"http://www.biz-logo.com/examples/#{ rand_num < 10 ? \"00\" : \"0\" }#{rand_num}.gif\"\n end",
"def rand\n warn \"STUB: rand in distribution.rb\"\n end",
"def gen\n (x=rand)>0.5 ? x : (x < rand/2.0) ? 1.0 - x : x\nend",
"def random_typhoon_generator\n\n #Normal Typhoon\n r = rand(50) #Currently: 1/50 chance\n if (r%49 == 0)\n sz = rand(3)\n sX = rand(40-12) + 12\n sY = rand(12-1) + 1\n dX = rand(10-3) + 3\n dY = rand(2-1) + 1\n typhoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n addObject(typhoon1)\n end\n #Strong Typhoon\n r = rand(90) #Currently: 1/90 chance\n if (r%89 == 0)\n sz = 3\n sX = rand(46-12) + 12\n sY = rand(12-1) + 1\n dX = rand(11-3) + 3\n dY = rand(2-1) + 1\n typhoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n addObject(typhoon1)\n end\n end",
"def sample(count=MaglevUndefined, options=MaglevUndefined)\n return at Kernel.rand(size)\n end",
"def randomize_terrain\n valid_terrains = @@data[:terrain].values.map { |i| i[:symbol] }\n\n (0...@width).each do |x|\n (0...@height).each do |y|\n @terrain_map[x][y] = valid_terrains[rand valid_terrains.length]\n end\n end\n end",
"def find_matching_image(image)\n hue = @histogram.set_hue image: image\n bucket = @cache[hue]\n index = rand(bucket.size) # 0 <= index < bucket.size\n random = bucket[index]\n\n if random.class.to_s == 'Picture'\n image = MiniMagick::Image.open(URI::encode(random.url))\n # TODO: Figure out better way to scale\n image.scale \"60x60!\"\n bucket[index] = random = image\n @cache[hue] = bucket\n end\n\n random\n end",
"def populate width=20,height=20,density=50,seed=nil\n if seed\n srand seed\n end\n\n @current_state=Array.new(height){Array.new(width){\n\t(rand(100)<density)?1:0\n }\n }\n end",
"def random_typhoon_generator\n\t\t\n\t\t#Normal Typhoon\n\t\tr = rand(50) #Currently: 1/50 chance\n\t\tif(r%49 == 0)\n\t\tsz = rand(3)\n\t\tsX = rand(40-12) + 12\n\t\tsY = rand(12-1) + 1\n\t\tdX = rand(10-3) + 3\n\t\tdY = rand(2-1) + 1\n\t\ttyphoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n\t\taddObject(typhoon1)\n\t\tend\n\t\t#Strong Typhoon\n\t\tr = rand(90) #Currently: 1/90 chance\n\t\tif(r%89 == 0)\n\t\tsz = 3\n\t\tsX = rand(46-12) + 12\n\t\tsY = rand(12-1) + 1\n\t\tdX = rand(11-3) + 3\n\t\tdY = rand(2-1) + 1\n\t\ttyphoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n\t\taddObject(typhoon1)\n\t\tend\n\tend",
"def generate(key, filename, seqid, range, style_obj, width, add_introns, \n style_override, return_image_info)\n \n log \"generating img/info #{key}\"\n log filename, 2\n log \"#{seqid}, #{range.inspect}\", 2\n \n info = \"\"\n \n time = Benchmark.measure do\n style_copy = style_obj.clone\n style_override.each do |gt_ruby_type, section, attribute, value|\n if value.nil?\n style_copy.unset(section, attribute)\n else\n style_copy.send(\"set_#{gt_ruby_type}\", section, attribute, value)\n end\n end\n mode = add_introns ? :on : :off\n fix = feature_index(filename, mode)\n gtrange = fix.get_range_for_seqid(seqid)\n gtrange.start = range.first\n gtrange.end = range.last\n diagram = GT::Diagram.from_index(fix, seqid, gtrange, style_copy)\n info = GT::ImageInfo.new\n layout = GT::Layout.new(diagram, width, style_copy)\n canvas = GT::CanvasCairoFile.new(style_copy, width, layout.get_height, info)\n layout.sketch(canvas)\n lock(:img) do\n @cache[:img][key] = canvas.to_stream\n end\n end\n log \"done (%.4fs)\" % time.real, 3\n return info if return_image_info\n end",
"def image_board\n\t\t(0...@width).map do |i|\n\t\t\t(0...@height).map do |j|\n\t\t\t\t# ([1]*3+[0]*7)[rand 10]\n\t\t\t\trand 2\n\n\n\t\t\t\t# rand 2\n\t\t\tend\n\t\tend\n\tend",
"def sample\n at(rand(size))\n end",
"def randomize\n (@grid_height * @grid_width / 5).times do\n @grid[rand(@grid_height)][rand(@grid_width)] = 1\n end\n end",
"def get_random_image( )\n\n print \"getting image... \"\n\n dest_file = \"#{File::SEPARATOR}tmp#{File::SEPARATOR}#{SecureRandom.hex( 5 )}.jpg\"\n Net::HTTP.start( \"lorempixel.com\" ) do |http|\n resp = http.get(\"/640/480/cats/\")\n open( dest_file, \"wb\" ) do |file|\n file.write( resp.body )\n end\n end\n puts \"done\"\n return dest_file\n\n end",
"def find_normal_image\n return \"Pictures/pcn%04d.png\" % (80 + id)\n end",
"def generate_compute(compute_instancetype, compute_imageid)\n compute_instancename = UUIDTools::UUID.random_create\n raw_template = \"\"\n File.open(COMPUTE_TEMPLATE) { |f| raw_template = f.readlines }\n template = ERB.new(raw_template.join(\"\\n\"))\n return [compute_instancename, template.result(binding)]\nend",
"def random_animal\n\t animals.sample\n end",
"def create_santa\n\t\t\nexample_genders = [\"agender\", \"female\", \"bigender\", \"male\", \"female\", \"gender fluid\", \"N/A\"]\nexample_ethnicities = [\"black\", \"Latino\", \"white\", \"Japanese-African\", \"prefer not to say\", \"Mystical Creature (unicorn)\", \"N/A\"]\n\t\n\tsantas = Santa.new(example_genders.sample, example_ethnicities.sample)\n\n\tsantas\nend",
"def rand\n Kernel.rand(self)\n end",
"def generate_random_hypothesis( size )\n hypothesis = Hypothesis.new\n size.times do\n hypothesis << generate_random_rule\n end\n hypothesis\nend",
"def generate_random_hypothesis( size )\n hypothesis = Hypothesis.new\n size.times do\n hypothesis << generate_random_rule\n end\n hypothesis\nend",
"def populate_map(map, n)\n ret = Array.new\n\n n.times do\n begin\n x, y = [rand(map.width), rand(map.height)]\n end while(not empty?(x,y,map)) \n \n creat = CreatureGenerator.create_random(self, x, y)\n ret << creat\n end\n \n return ret\n end",
"def rand\n return extract_number / (2**32 -1).to_f\n end",
"def random_block\n type = %w(p p p p ul ol dl).sample\n case type\n when 'p'\n self.random_p\n when 'ul'\n self.random_list( 'ul', (rand(2) == 1) )\n when 'ol'\n self.random_list( 'ol', (rand(2) == 1) )\n when 'dl'\n self.random_dl\n end\n end",
"def random(type: nil, tags: [], hidden: false, nsfw: false, file_type: nil)\n tags = tags.map { |t| t.name if t.is_a(Tag) }\n WeebImage.new(API::Toph.random(self, {\n type: type,\n tags: tags,\n hidden: hidden,\n nsfw: nsfw,\n file_type: file_type\n }), self)\n end",
"def generate\n #create random number generator\n rng = Random.new\n @points = Array.new\n\n #num_points times, make random value in ranges \n @num_points.times do\n @points << [rng.rand(@x_lims), rng.rand(@y_lims)]\n end\n end",
"def randomize *definitions\n result = self\n\n if definitions.include?(:sign)\n result = rand_sign\n end\n\n if definitions.include?(:ratio)\n result = rand * result\n elsif definitions.include?(:int)\n result = (rand result)\n end\n\n result\n end",
"def srand(seed)\n @prng = Mtwist.new(seed)\n end",
"def seed_image(filename, imageable_type, imageable_id)\n Picture.create!(\n :id => $image_id,\n :image => image(filename),\n :imageable_type => imageable_type,\n :imageable_id => imageable_id\n )\n $image_id += 1\nend",
"def rand\n if @use_last\n y1 = @last\n @use_last = false\n else\n w = 1\n until w < 1.0 do\n r1 = Kernel.rand\n r2 = Kernel.rand\n x1 = 2.0 * r1 - 1.0\n x2 = 2.0 * r2 - 1.0\n w = x1 * x1 + x2 * x2\n end\n w = Math.sqrt((-2.0 * Math.log(w)) / w)\n y1 = x1 * w\n @last = x2 * w\n @use_last = true\n end\n \n @mean + y1 * @sd\n end",
"def cover_url\n [\"condition_headache.jpeg\",\"condition_chair.jpeg\",\"condition_time.jpeg\",\"condition_med.jpeg\"][rand(4)] \n end",
"def compute_damage\n rand(1..6)\n end",
"def santa_maker(num)\n genders = [\"male\", \"female\", \"gender fluid\", \"trans*\", \"agender\", \"other\", \"prefer not to say\"]\n ethnicities = [\"black\", \"white\", \"Asian\", \"Native American\", \"Latino\", \"Arab\", \"Persian\", \"Aboriginal Australian\", \"other\"]\n santa_num = 1\n\n num.times do\n gender = genders.sample\n ethnicity = ethnicities.sample\n age = rand(0..140)\n puts \"\"\n puts \"Creating Santa no. #{santa_num}\"\n santa = Santa.new(gender, ethnicity, age)\n\n puts \"Gender: #{santa.gender}\"\n puts \"Ethnicity: #{santa.ethnicity}\"\n\n\n santa_num += 1\n end\nend",
"def index\n\n\n #@link_arr= []\n #(1..2).each do |i|\n # Five00px.new.five_px(i)\n # end\n @image = Unlimited.skip(rand(Unlimited.count)).first\n\n end",
"def make_rand\n Random.new_seed\n return Random.new\n end",
"def reset(window)\n\t\t# create a new image using a random one from the candyList\n @image = Gosu::Image.new(window, candyList.sample)\n # set w,h based on image size\n @w = @image.width\n @h = @image.height\n # a random Y value so it starts at a random place\n\t @y = Random.rand(window.height - @h)\n\t # velocity of Y is random from -5 to 5\n\t # this changes the angle of the candy\n\t @vy = rand(-5..5)\n\t # x is set to the full width of the window so it starts on the right side\n\t @x = window.width\n\tend"
] | [
"0.57630605",
"0.57064486",
"0.5657136",
"0.5654884",
"0.5636625",
"0.5624686",
"0.5582114",
"0.5519244",
"0.5509578",
"0.55075866",
"0.54679877",
"0.546257",
"0.54451126",
"0.5421123",
"0.53978896",
"0.53797156",
"0.5363218",
"0.5353453",
"0.5342196",
"0.53372324",
"0.53322554",
"0.52970606",
"0.5290308",
"0.52792716",
"0.52727973",
"0.5256784",
"0.525046",
"0.52454925",
"0.5231457",
"0.5228614",
"0.5224564",
"0.52237195",
"0.5216088",
"0.52114695",
"0.5209537",
"0.5195534",
"0.51879716",
"0.5175934",
"0.5172677",
"0.51589984",
"0.51555824",
"0.51543957",
"0.51543957",
"0.5154082",
"0.51503754",
"0.51444906",
"0.5141565",
"0.5137866",
"0.5137866",
"0.5123199",
"0.51176155",
"0.510924",
"0.5105307",
"0.51036733",
"0.50966614",
"0.5078889",
"0.5071998",
"0.5067345",
"0.50619614",
"0.50540495",
"0.5052653",
"0.5052653",
"0.5051285",
"0.5045016",
"0.50406265",
"0.5034119",
"0.5016134",
"0.50108844",
"0.500991",
"0.50054824",
"0.49977142",
"0.49963734",
"0.49875033",
"0.4976261",
"0.49712893",
"0.49627462",
"0.4959318",
"0.4959184",
"0.49566424",
"0.49540433",
"0.49536616",
"0.4941992",
"0.49380705",
"0.49358714",
"0.49358714",
"0.49349272",
"0.49328104",
"0.49243194",
"0.49229237",
"0.49220645",
"0.4918779",
"0.4915573",
"0.49123806",
"0.49000216",
"0.48918536",
"0.4889923",
"0.4880216",
"0.48703137",
"0.4862966",
"0.4861966"
] | 0.839465 | 0 |
pattern adjusted because removing the zeros from the front | def digit(i, input, pattern)
temp = input.dup
temp.shift(i-1) # this removes the first i-1 which will be multiplied by zero
result = temp.each_slice(i).each_with_index.map{|group,i| group.sum* pattern[ i % 4]}.sum.abs % 10
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simplified_pattern\n pattern\n end",
"def simplified_pattern\n pattern\n end",
"def pattern\n @nz.map { |nz_cell| nz_cell[0..1] }\n end",
"def update_anime_pattern\n @pattern = (@pattern + 1) % 8# not need to calculate because char takes all the patterns % 4\n end",
"def pattern_bits\n str = bits.to_s(2)\n str = str.rjust(self.step_count, '0')\n str.chars.collect{|x|x=='1'}\n end",
"def keep_leading_zeros(val = true)\n @leading_zeros = val\n end",
"def slow_build_pattern_prefix_function(pattern)\n prefix_fnc_array = []\n prefix_fnc_array[0] = -1\n prefix_fnc_array[1] = 0\n padded_pattern = \" \" + pattern # padded so that index 1 will point to the start of the pattern\n \n (2..pattern.size ).each do |q|\n k = 0\n (1..q-1).each do |index|\n #puts \"#{q} #{index} #{padded_pattern[1..index]} #{padded_pattern[ q - index + 1 .. q]} \"\n if padded_pattern[1..index] == padded_pattern[ q - index + 1 .. q] \n k = index \n end\n end\n prefix_fnc_array[q] = k\n \n end\n\n return prefix_fnc_array\nend",
"def remove_leading_zero(arg)\n arg.to_s.sub(\"0\", \"\")\n end",
"def cover_starred_zeroes!()\n num = 0 \n @matrix_size.times{|c|\n if col_has_star?(c)\n cover_col!(c)\n num += 1\n end\n }\n if num >= @matrix_size\n return :done\n else\n return 4\n end\n end",
"def redesign\n x = @mat[0].length\n y = @mat.size\n (1..y-2).each do |i|\n (1..x-2).each do |j|\n @mat[i][j] = \"0\"\n end\n end\n\n divide(1,x-2,1,y-2)\n end",
"def replace(p0) end",
"def replace(p0) end",
"def replace(p0) end",
"def matrix_convert_to_zero(matrix)\n placeholder_substitution(matrix, 0, -1)\n convert(matrix)\n placeholder_substitution(matrix, -1, 0)\nend",
"def pattern_indexes\n self.bits ||= 0\n array = bits.to_s(2).rjust(self.step_count, '0').chars.each_with_index.map do |value, index|\n index if value == '1'\n end\n array.compact\n end",
"def matrix_convert_to_0(matrix)\n current_matrix = 0\n current_loc = 0\n delta = 0\n\n while current_matrix <= (matrix.length - 1) do\n while current_loc <= matrix[current_matrix].length - 1 do\n if matrix[current_matrix][current_loc] == 0\n delta = current_loc\n delta_count = 0\n while delta_count <= matrix[current_matrix].length - 1 do\n matrix[current_matrix][delta_count] = 0\n delta_count += 1\n end\n delta_count = 0\n while delta_count <= matrix.length - 1 do\n matrix[delta_count][delta] = 0\n delta_count += 1\n end\n current_loc += 1\n else\n current_loc += 1\n end\n end\n current_matrix += 1\n current_loc = 0\n end\n\n return matrix\nend",
"def mask_with_gsub s\n s.gsub(/\\d[\\d\\s-]+\\d/) do |broad_match|\n masked = nil\n match_from = 0\n mi = 0\n broad_digits = broad_match.scan(/\\d/).map{|v| v.to_i }\n next broad_match if broad_digits.length < 14\n while true\n found, match_start, match_len = iterate(broad_digits, mi)\n if found\n mi += match_start + 1\n n = match_from\n masked = broad_match[0..-1] if not masked\n while match_start > 0\n match_start -= 1 if DIGITS[broad_match[n]]\n n += 1\n end\n match_from = -1\n while match_len > 0\n if DIGITS[broad_match[n]]\n match_from = n + 1 if match_from < 0\n masked[n] = 'X'\n match_len -= 1\n end\n n += 1\n end\n else\n break\n end\n end\n masked || broad_match\n end\n end",
"def str_zero(n)\n n.to_s.sub(/\\.?0+$/, '')\nend",
"def create_pattern(piece)\n Array.new(4,piece).join\n end",
"def unpad_1_9()\n new_arr = []\n @value.each do |string|\n string = string.dup # to avoid changing the original\n while (string.getbyte(-1) == 0) \n string.chop!\n end\n new_arr.push string\n end\n new_arr\n end",
"def pattern=(_arg0); end",
"def five_digit_pattern()\r\n\treturn [\r\n\t\t\t[1, 0, 0, 0, 1],\r\n\t\t\t[0, 1, 0, 0, 1],\r\n\t\t\t[0, 0, 1, 0, 1],\r\n\t\t\t[0, 0, 0, 1, 1]\r\n\t\t ]\r\nend",
"def move_zeros(array)\n count = 0\n index = 0\n array.each do |el|\n if el == 0\n count += 1\n else\n array[index] = el\n index += 1\n end\n end\n (index...array.length).each do |i|\n array[i] = 0\n end\n\n array\nend",
"def pattern(neck = \"\", digits = nil)\n if digits\n if parent\n parent.pattern(@atlas + neck, digits)\n else\n Pattern.new(neck, digits).to_s\n end\n else\n digits = if gethead then gethead else [0] * (depth + 1) end\n pattern('', digits)\n end\n end",
"def ensurezero(prefix)\n prefix < 10 ? prefix.to_s.rjust(2, \"0\") : prefix\n end",
"def blanket_patterns(colors, lines)\n lines.times do |i|\n first = colors[0]\n rest = colors[1..-1]\n colors = rest + first\n puts colors\n end\nend",
"def remove_double_zero\n @number[2..-1]\n end",
"def matrix_convert_to_0(matrix)\n\nend",
"def matrix_convert_to_zero(matrix)\n rows = matrix.length\n cols = matrix[0].length\n\n rows.times do |row|\n cols.times do |col|\n matrix[row][col] = \"x\" if matrix[row][col] == 0\n end\n end\n\n rows.times do |row|\n cols.times do |col|\n if matrix[row][col] == \"x\"\n cols.times do |i|\n matrix[row][i] = 0 if matrix[row][i] != \"x\"\n end\n\n rows.times do |i|\n matrix[i][col] = 0 if matrix[i][col] != \"x\"\n end\n\n matrix[row][col] = 0\n end\n end\n end\n\n return matrix\nend",
"def get_fraction( pattern )\n r = nil\n pattern.reverse.each_with_index do |n, i|\n r = (i == 0 ? n : n + Rational(1, r))\n end\n return r\nend",
"def matrix_convert_to_0(matrix)\n matrix.each do |row|\n index = 0\n row.each do |element|\n if element == 0\n row.length.times do |i|\n row[i] = 0\n end\n matrix.length.times do |i|\n matrix[i][index] = 0\n end\n end\n\n index += 1\n end\n end\nend",
"def matrix_convert_to_0(matrix)\n\n rows = matrix.length\n columns = matrix[0].length\n track_zeros = []\n\n rows.times do |row|\n columns.times do |column|\n if matrix[row][column] == 0\n track_zeros << [row, column]\n end\n end\n end\n\n track_zeros.length.times do |index|\n columns.times do |column|\n matrix[track_zeros[index][0]][column] = 0\n end\n\n rows.times do |row|\n matrix[row][track_zeros[index][1]] = 0\n end\n end\n\nend",
"def update_pattern\r\n pattern = @character.pattern\r\n if @pattern != pattern\r\n src_rect.x = pattern * @cw\r\n @pattern = pattern\r\n end\r\n direction = @character.direction\r\n if @direction != direction\r\n src_rect.y = (direction - 2) / 2 * @ch\r\n @direction = direction\r\n end\r\n end",
"def zero_matrix2(matrix)\n (0...matrix.length).each do |row|\n (0...matrix[0].length).each do |col|\n if matrix[row][col] == 0\n matrix[0][col] = 0\n matrix[row][0] = 0\n end\n end\n end\n\n (1...matrix.length).each do |row|\n (1...matrix[0].length).each do |col|\n matrix[row][col] = 0 if matrix[0][col] == 0 || matrix[row][0] == 0\n end\n end\n\n matrix\nend",
"def maskify(cc)\n puts cc.gsub(/.(?=....)/, '#')\nend",
"def make_pattern(array = [], number) # Define a method with two paremeter one array which will be the output and another one which is the given number.\r\n if number <= 0 # This is our base case it will stop if the number is 0 or less than that.\r\n array << number #Then we will push the number in to the array.\r\n\t\tarray << array.reverse #Now we will push the array in to it self, But in reverse order.\r\n\t\tarray.flatten! # At this two point we have a nested array it should be turn to one array.\r\n array.delete_at(array.length / 2) # Now there is a problem in our array the middle element of the array is repeated twice.So we delete one.\r\n return array # The array is ready to be called.\r\n end\r\n array << number # It pushes the number in to array \r\n make_pattern(array , number - 5) # This will make our method recursive.It will deduct 5 from our number at each time the method execute.\r\nend",
"def pattern; end",
"def pattern; end",
"def pattern; end",
"def zeros_like\n return self.class.zeros_like(self)\n end",
"def move_zeros(array)\n current_index = 0\n num_zeros = 0\n\n while current_index < (array.length - num_zeros)\n current_value = array[current_index]\n\n if current_value != 0\n current_index += 1\n next\n end\n\n back = array.length - 1 - num_zeros\n array[current_index], array[back] =\n array[back], array[current_index]\n num_zeros += 1\n\n # we can't add one to current_index since `back` may have contained a zero and we don't know it\n end\n\n array\nend",
"def matrix_convert_to_zero(matrix)\n return nil if matrix.empty?\n\n rows = matrix.size\n columns = matrix[0].size\n\n rows.times do |row|\n columns.times do |column|\n matrix[row][column] = \"ZERO\" if matrix[row][column] == 0\n end\n end\n\n rows.times do |row|\n columns.times do |column|\n next unless matrix[row][column] == \"ZERO\"\n\n columns.times { |i| matrix[row][i] = 0 unless matrix[row][i] == \"ZERO\" }\n rows.times { |i| matrix[i][column] = 0 unless matrix[i][column] == \"ZERO\" }\n matrix[row][column] = 0\n end\n end\nend",
"def maskify(cc)\n cc.size < 5 ? cc : cc[-4..-1].rjust(cc.size, '#')\nend",
"def move_zeros(array)\n current_index = 0\n num_zeros = 0\n\n while current_index < (array.length - num_zeros)\n current_value = array[current_index]\n\n if current_value != 0\n current_index += 1\n next\n end\n\n back = array.length - 1 - num_zeros\n array[current_index], array[back] =\n array[back], array[current_index]\n num_zeros += 1\n\n # we can't add one to current_index since `back` may have\n # contained a zero and we don't know it.\n end\n\n # Return the array\n array\nend",
"def matrix_convert_to_0(matrix)\n\n rows = matrix.length\n columns = matrix[0].length\n\n row_array = []\n column_array = []\n\n r = 0\n while r < rows do\n\n c = 0\n while c < columns do\n\n if matrix[r][c] == 0\n row_array << r\n column_array << c\n end\n\n c += 1\n end\n\n r += 1\n end\n\n row_array.each do |r|\n columns.times do |c|\n matrix[r][c] = 0\n end\n end\n\n\n column_array.each do |c|\n rows.times do |r|\n matrix[r][c] = 0\n end\n end\n\n\n return matrix\nend",
"def gb_remove_trailing_zero (value)\n (value == value.to_i) ? value.to_i : value\n end",
"def drop_trailing_zero(num)\n i, f = num.to_i, num.to_f\n i == f ? i : f\n end",
"def drop_trailing_zero(num)\n i, f = num.to_i, num.to_f\n i == f ? i : f\n end",
"def add_zero_to_1_to_9(str)\n str.sub(/(?<=\\D)\\d\\D?$/, '0\\0' )\n end",
"def make_valid\n pattern = Array.new(size){|i| i+1}.shuffle\n size.times do |y|\n size.times do |x|\n set x, y, pattern[x]\n end\n base.times{|i| pattern.push pattern.shift}\n pattern.push pattern.shift if base - (y%base) == 1\n end\n self\n end",
"def make_valid\n pattern = Array.new(size){|i| i+1}.shuffle\n size.times do |y|\n size.times do |x|\n set x, y, pattern[x]\n end\n base.times{|i| pattern.push pattern.shift}\n pattern.push pattern.shift if base - (y%base) == 1\n end\n self\n end",
"def pattern(component)\n Parser::CurrentRuby.parse(component)\n .to_s\n .gsub(\"nil\", \"nil?\")\n .delete(\"\\n\")\n .gsub(\" \", \" \")\n end",
"def matrix_convert_to_0(matrix)\n count_row = matrix.length\n count_column = matrix[0].length\n\n h_row = Array.new(count_row)\n h_column = Array.new(count_column)\n\n count_column.times do |j|\n count_row.times do |i|\n if matrix[i][j] == 0\n if !h_row[i]\n h_row[i] = 0\n end\n if !h_column[j]\n h_column[j] = 0\n end\n end\n end\n end\n\n count_row.times do |i|\n if h_row[i] == 0\n count_column.times do |j|\n matrix[i][j] = 0\n end\n end\n end\n\n count_column.times do |j|\n if h_column[j] == 0\n count_row.times do |i|\n matrix[i][j] = 0\n end\n end\n end\nend",
"def state_to_pattern(state)\r\n start = state.min\r\n finish = state.max\r\n pattern = ''\r\n (start..finish).each do |i|\r\n if state.include?(i)\r\n pattern += '#'\r\n else\r\n pattern += '.'\r\n end\r\n end\r\n return pattern\r\nend",
"def matrix_convert_to_0(matrix)\n matrix_helper(matrix, 0, 0)\nend",
"def moves_zeros(array)\n i = 0\n count = 0\n new_array = []\n while i < array.length\n if array[i] != 0\n new_array << array[i]\n else\n count += 1\n end\n i += 1\n end\n count.times { new_array << 0}\n new_array\nend",
"def maskify(cc)\n # your beautiful code goes here\n cc.length <= 4 ? cc : \"#\" * (cc.length-4) + cc[-4..-1]\nend",
"def matrix_convert_to_0(matrix)\n\n# arrays to store the values of the indices in the matrix that have zeros\n rows = []\n cols = []\n\n matrix.length.times do |row_index|\n matrix[0].length.times do |col_index|\n if matrix[row_index][col_index] == 0\n rows << row_index\n cols << col_index\n end\n end\n end\n\n rows.each do |r_index|\n matrix[0].length.times do |c_index|\n matrix[r_index][c_index] = 0\n end\n end\n\n cols.each do |c_index|\n matrix.length.times do |r_index|\n matrix[r_index][c_index] = 0\n end\n end\n\n return matrix\n\nend",
"def noise_pattern() abstract_method\n\tend",
"def removewalls \n\t\t@drawnmaze.chars.each_index do |index|\n\t\t\tif @arg[index] == \"0\" \n\t\t\t\t@drawnmaze[index] = \" \"\n\t\t\tend\n\t\tend\n\tend",
"def move_zeroes(nums)\n count = nums.select { |i| i.zero? }.count\n\n new = []\n nums.each do |value|\n if value != 0\n new.push(value)\n end\n end\n\n count.times { new.push(0) }\n\n nums.each_with_index do |value, index|\n nums[index] = new[index]\n end\n\n nums\nend",
"def prepare_pattern(pattern)\n pattern.scan(/(\\<[^\\>]+\\>[^\\<]?)/).flatten.map { |x| TagPattern.new(x) }.reverse\n end",
"def changing_sequence(arr)\n pattern = arr[1] - arr[0]\n arr.each_cons(2).with_index do |(num1, num2), idx|\n return idx if (num2 - num1) * pattern < 0\n end\n -1\nend",
"def move_zeros(array)\n\nend",
"def pattern(value_=nil)\n if value_\n @pattern = value_\n else\n @pattern\n end\n end",
"def matrix_convert_to_zero(matrix)\n rows = matrix.length\n cols = matrix[0].length\n row_zero = []\n col_zero = []\n\n rows.times do |row|\n cols.times do |col|\n if matrix[row][col] == 0\n row_zero << row\n col_zero << col\n end\n end\n end\n\n row_zero.uniq.each do |row|\n cols.times do |col|\n matrix[row][col] = 0\n end\n end\n\n col_zero.uniq.each do |col|\n rows.times do |row|\n matrix[row][col] = 0\n end\n end\n\n return matrix\nend",
"def pattern_indexes=(indexes)\n p_bits = ('0' * step_count)\n indexes.each do |index|\n p_bits[index] = '1'\n end\n self.bits = p_bits.rjust(self.step_count, '0').to_i(2)\n end",
"def zero_ord_arr(arr)\n z = 0\n i = 1\n while i < arr.length\n if arr[z] != 0 && arr[i] == 0\n z = i\n end\n if arr[z] == 0 && arr[i] != 0\n arr[z], arr[i] = arr[i], arr[z]\n z += 1\n end\n i += 1\n end\n arr\nend",
"def leading_zeroes(max_num_length)\n 101.times do |i|\n num_of_zeroes = max_num_length - i.digits.length\n puts \"0\" * num_of_zeroes + i.to_s\n end\nend",
"def compute_skips(pattern)\n \n end",
"def make_array min,sec\n (\"%d%02d*\" % [min,sec]).gsub(/^0+([^*])/,'\\1').split(//)\nend",
"def move_zeroes(nums)\n len = nums.length\n count = 0\n for i in 0...len\n if nums[i] != 0\n nums[count] = nums[i]\n count += 1\n end\n end\n# # Loop from count to len-1 and fill it with zeros \n while count < len\n nums[count] = 0\n count += 1\n end\n return nums\nend",
"def matrix_convert_to_0(matrix)\n rows = matrix.length\n columns = matrix[0].length\n\n row_zero = []\n column_zero = []\n rows.times do |row|\n columns.times do |column|\n if matrix[row][column] == 0\n row_zero << row\n column_zero << column\n end\n end\n end\n\n row_zero.each do |r|\n columns.times do |c|\n matrix[r][c] = 0\n end\n end\n\n column_zero.each do |c|\n rows.times do |r|\n matrix[r][c] = 0\n end\n end\n print matrix\nend",
"def matrix_convert_to_0(matrix)\n\n rows = matrix.length\n columns = matrix[0].length\n\n\n zeros = []\n rows.times do |row|\n columns.times do |column|\n if matrix[row][column] == 0\n zeros << {:row => row, :col => column}\n break\n end\n end\n end\n\n zeros.each do |zero_locations|\n rows.times do |row|\n matrix[row][zero_locations[:col]] = 0\n end\n\n columns.times do |column|\n matrix[zero_locations[:row]][column] = 0\n end\n end\n\n\nend",
"def matrix_convert_to_0(matrix)\n zeros_array = []\n\n matrix.each.with_index do |row, i|\n # print \"before #{row} \\n\"\n row.each.with_index do |num, index|\n if num == 0\n zeros_array << index\n matrix[i] = Array.new(row.length, 0)\n\n end\n\n end\n # print \"after #{row} \\n\"\n end\n zeros_array.each do |ele|\n matrix.each do |row|\n row[ele] = 0\n\n end\n end\n return matrix\nend",
"def matrix_convert_to_0(matrix)\n\n columns = matrix[0].length #number of columns\n rows = matrix.length #number of rows\n\n to_be_zeroed = []\n\n rows.times do |row|\n columns.times do |column|\n if matrix[row][column] == 0\n to_be_zeroed << [row, column]\n end\n end\n end\n\n to_be_zeroed.each do |r, c|\n columns.times do |column|\n matrix[r][column] = 0\n end\n\n rows.times do |row|\n matrix[row][c] = 0\n end\n end\n return matrix\nend",
"def build_pattern()\n picking_pattern = { \"repetitions\" => @repetitions }\n\n pattern = \"\"\n (1..@sixteenths_per_measure).each { pattern.concat(\"0,\")}\n picking_pattern[:pattern] = pattern.slice(0..pattern.length - 2)\n\n picking_pattern\n\n end",
"def matrix_convert_to_0(matrix)\n # store coordinates of the 0s here like: [[r1, c1], [r2,c2]]\n targets = []\n\n matrix.length.times do |row|\n matrix[row].each_with_index do |value, col|\n if value == 0\n coordinate = [row, col]\n targets << coordinate\n end\n end\n end\n\n # do we have any 0s?\n if targets[0]\n targets.each do |coordinate|\n row = coordinate[0]\n col = coordinate[1]\n\n # zero out the row\n matrix[row].length.times do |each_col|\n matrix[row][each_col] = 0\n end\n\n # zero out the column\n matrix.length.times do |each_row|\n matrix[each_row][col] = 0\n end\n end\n end\n return matrix\nend",
"def _reduce_478(val, _values, result)\n @pattern_hash_keys.pop\n pattern = @builder.array_pattern(nil, val[2], nil)\n result = @builder.const_pattern(val[0], val[1], pattern, val[3])\n \n result\nend",
"def createPrefixTable(pattern)\n if (!pattern) then\n return\n end\n\n prefix = Array.new((pattern.length),0)\n j = 0\n prefix[0] = 0\n\n for i in 1...(pattern.length)\n if pattern[i] == pattern[j]\n prefix[i] = j\n j = j+1\n else\n while true\n j = prefix[j]\n if j == 0 then\n break\n end\n if pattern[i] == pattern[j]\n prefix[i] = prefix[j]\n break\n end\n end\n end\n end\n return prefix\nend",
"def move_zeros_left_failure(array)\n zero_indexes = Array.new\n\n array.each_with_index do |value, index|\n if value == 0\n zero_indexes << index\n end\n end\n\n zeros_cursor = 0\n zero_indexes.each do |index|\n\n #This does not work, because we're swapping.. NOT maintaining order.\n #If this index is not in a place that will eventually be a zero.\n unless index < zero_indexes.size - 1\n tmp = array[index]\n array[index] = array[zeros_cursor]\n array[zeros_cursor] = 0\n zeros_cursor += 1\n end\n\n end\n\n return array\nend",
"def sharpflat\n @data[0] > 7 ? @data[0] - 256 : @data[0]\n end",
"def _reduce_466(val, _values, result)\n @pattern_hash_keys.pop\n pattern = @builder.array_pattern(nil, val[2], nil)\n result = @builder.const_pattern(val[0], val[1], pattern, val[3])\n \n result\nend",
"def decolorize\r\n self.gsub(/\\[0;\\d\\d;\\d\\dm([^\\[]*)\\[0m/) { $1 }\r\n end",
"def decolorize\r\n self.gsub(/\\[0;\\d\\d;\\d\\dm([^\\[]*)\\[0m/) { $1 }\r\n end",
"def fix_common_typos!\n # well, I don't know what kind of typos people do!\n @pattern.squish!\n end",
"def prepad_zeros(length)\n str = self\n str.insert(0, '0') while str.length < length\n str\n end",
"def bmAltGoodSuffixTable(pattern)\n pattern = pattern.unpack('U*')\n goodSuffix = []\n pattern.length.times do |i| \n value=0 \n while (value < pattern.length && !suffixmatch(pattern, i, value)) do \n value+=1 \n end \n goodSuffix[pattern.length-i-1] = value \n end \n return goodSuffix\nend",
"def star_pattern(stars_num)\n stars_num == 1 ? '*' : \"*#{' ' * (stars_num - 2)}*\"\nend",
"def pad(value)\r\n return value unless @padding == :zero\r\n matcher = @alignment == :right ? /^ +/ : / +$/\r\n space = value.match(matcher)\r\n return value unless space\r\n value.gsub(space[0], '0' * space[0].size)\r\n end",
"def rjust(p0, padstr=\"\") end",
"def expand!(original)\n from = original.size\n original.map! {|row|\n row.unshift 0\n row << 0\n }\n original.unshift(Array.new(from+2) {0})\n original << Array.new(from+2) {0}\nend",
"def swe_line_pattern(val)\n swe_line_pattern_hash[numeric_or_downcase(val)] || 'solid'\n end",
"def _reduce_478(val, _values, result)\n @pattern_hash_keys.pop\n pattern = @builder.array_pattern(nil, val[2], nil)\n result = @builder.const_pattern(val[0], val[1], pattern, val[3])\n\n result\nend",
"def matrix_convert_to_0(matrix)\n (matrix.length).times do |i| #number of rows times do runs 3 times\n (matrix[i].length).times do |j| #number of columns this runs 4 times\n if matrix[i][j] == 0 #if something in this row/column is 0\n row = i\n column = j #select the column\n (matrix[row].length).times do |j| #change the whole row to 0\n matrix[row][j] = 0\n end\n (matrix.length).times do |i|\n matrix[i][column] = 0\n end\n end\n end\n end\n return matrix\nend",
"def matrix_convert_to_zero(matrix)\n raise NotImplementedError\nend",
"def trailing_zeroes(n)\n if n == 0\n return 0\n else\n return (n / 5 + trailing_zeroes(n / 5))\n end\nend",
"def generatePattern(numRepeats, theSize)\n\n\t# Generate the pattern\n\tbasePattern = [0, 1, 0, -1];\n\tthePattern = Array.new();\n\t\n\tbasePattern.each do |x|\n\t\tthePattern.concat(Array.new(numRepeats).fill(x));\n\tend\n\n\n\n\t# Repeat for size\n\twhile (thePattern.size < (theSize + 1))\n\t\tthePattern = thePattern.concat(thePattern);\n\tend\n\t\n\treturn thePattern.slice(1, theSize);\n\nend",
"def build_regex_pattern index, pattern_element\n \"^\" + @phone_number[index..(index + pattern_element - 1)].map { |c| \"(#{NUMBER_LETTERS[c].join('|')})\" }.join + \"$\"\n end",
"def _t(str)\n _f(str).gsub(/([0]+\\z)/, '')\n end"
] | [
"0.6137649",
"0.6137649",
"0.5982036",
"0.58614016",
"0.5802679",
"0.5708617",
"0.56372696",
"0.5508636",
"0.5459506",
"0.545827",
"0.5450568",
"0.54478693",
"0.54478693",
"0.5424999",
"0.53882015",
"0.5375077",
"0.5353378",
"0.53281593",
"0.5320903",
"0.53133154",
"0.5295863",
"0.52740824",
"0.5260599",
"0.52525616",
"0.52341753",
"0.5215206",
"0.52147627",
"0.5194068",
"0.5182898",
"0.5173457",
"0.5169242",
"0.5135061",
"0.5129715",
"0.51175773",
"0.51069176",
"0.5104863",
"0.51009166",
"0.51009166",
"0.51009166",
"0.5091663",
"0.508084",
"0.50673544",
"0.5038263",
"0.503221",
"0.50285584",
"0.50274724",
"0.5022471",
"0.5022471",
"0.5019392",
"0.50186807",
"0.50186807",
"0.5017794",
"0.5011157",
"0.5007626",
"0.49964017",
"0.49958104",
"0.49855745",
"0.4984969",
"0.49847203",
"0.49773017",
"0.49737114",
"0.49653238",
"0.49613523",
"0.4949774",
"0.49481994",
"0.49395582",
"0.49371147",
"0.49328876",
"0.49255097",
"0.4917233",
"0.49170974",
"0.49135494",
"0.49101472",
"0.490609",
"0.49056396",
"0.4890523",
"0.48854187",
"0.4884749",
"0.48830488",
"0.48781705",
"0.48730713",
"0.48686787",
"0.48516876",
"0.4844503",
"0.4844503",
"0.48402777",
"0.4832865",
"0.48313683",
"0.48311797",
"0.48277748",
"0.481917",
"0.48168182",
"0.48150304",
"0.48070228",
"0.48058727",
"0.47906366",
"0.47861144",
"0.4778836",
"0.47699493",
"0.47685158"
] | 0.485959 | 82 |
Largest prime factor The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? | def problem3(num)
prime = num
while num%2==0 do num/=2 end
(3..Math.sqrt(num).to_i).step(2).each { |pf|
break if num < pf
while num%pf==0 do
num/=pf
prime = pf
end
}
prime
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def largest_prime_factor\n number = 600851475143\n n = 2\n while n < number\n if number % n == 0\n factor = number / n\n return factor if is_prime?(factor)\n end\n n += 1\n end\nend",
"def largestPrimeFactor\n\tn = 600851475143\n\tfactor = 2\n\tlastFactor = 1\n\n\twhile n > 1\n\t\tif n % factor == 0\n\t\t\tlastFactor = factor\n\t\t\tn /= factor\n\t\t\twhile n % factor == 0\n\t\t\t\tn /= factor\n\t\t\tend\n\t\tend\n\n\t\tfactor += 1\n\tend\n\n\tputs(lastFactor)\nend",
"def prime_factor\n max = 600851475143**0.5\n\n for i in (1..max).step(2)\n if 600851475143 % i == 0\n if is_prime(i)\n ans = i\n end\n end\n end\n ans\nend",
"def largest_prime_factor num\n divisors = []\n max = 0\n\n (1..num).each { |el| divisors << el if num % el === 0 && isPrime(el)}\n\n max = divisors[0]\n\n divisors.each do |el|\n max = el if el > max \n end\n\n max\nend",
"def largest_prime_factor(num)\n num.prime_division.last[0]\n end",
"def largest_prime_factor(num)\n factors = []\n half_of_num = num / 2\n\n (2..half_of_num).each do |factor|\n if num % factor == 0\n factors << factor\n num = num / factor\n end\n end\n factors.max\nend",
"def prime_factors(num)\n factors = num.prime_division\n factors.to_a\n largest_factor = factors[-1][0]\n p largest_factor\nend",
"def euler003\n 600851475143.prime_factors.last\nend",
"def largest_prime_factor(num)\n (1..num).reverse_each do |factor|\n if num % factor == 0 && prime?(factor)\n return factor\n end\n end\nend",
"def largest_prime_factor(num)\n counter = 2\n biggestFactor = 0\n while (counter * counter) <=num\n if num % counter == 0\n num = num / counter\n biggestFactor = counter\n else\n counter+=1\n end\n end\n\n if (num > biggestFactor)\n biggestFactor = num\n end\n biggestFactor\nend",
"def largest_prime_factor(num)\n (2..num).reverse_each do |factor|\n if (num % factor == 0 && Prime.prime?(factor))\n return factor\n end\n end\nend",
"def largest_prime_factor(num)\n factors = []\n\n (1..num).each do |i|\n if num % i == 0\n factors << i \n end\n end\n\n primes = []\n factors.each do |num|\n if is_prime?(num)\n primes << num \n end\n end\n\n primes.max\nend",
"def max_prime_factor(num)\n return num if num == 1 || num < 1\n max_num = (num ** 0.5 + 1).to_i\n f = (2..max_num).find { |x| num % x == 0 } || num\n [f, max_prime_factor(num / f)].max\nend",
"def largest_prime_factor(num)\n track = 0\n (num).downto(2).each do |factor|\n \n if num % factor == 0 && prime?(factor)\n return factor\n end\n end\n \nend",
"def largest_prime_factor(num)\n num.downto(1).each do |divisor|\n if num % divisor == 0 && isprime?(divisor)\n return divisor\n end\n end\n return 1\nend",
"def largest_prime_factor(number)\n\tlargest_pfactor = number\n\tfactor = 2\n\twhile(factor <= (largest_pfactor / 2)) do\n\t\tif(largest_pfactor % factor == 0)\n\t\t\tlargest_pfactor = largest_pfactor / factor\n\t\telse\n\t\t\tfactor = factor + 1\n\t\tend\n\tend\n\tlargest_pfactor\nend",
"def largest_prime_factor(num)\n primes = []\n (1..num).each do |n|\n primes << n if num % n == 0 && is_prime?(n)\n end\n primes.max\nend",
"def largest_prime_factor(input)\n\n prime = input\n (2..Math.sqrt(input).to_i).each do |i|\n break if prime <= 1\n prime /= i while (prime > i && prime % i == 0)\n end\n prime\nend",
"def largest_prime_factor(num) \n num.downto(2).each do |factor|\n if num % factor == 0 && isPrime(factor)\n return factor\n end\n end\nend",
"def largest_prime_factor(num)\n divisor = 1\n\n (2..num).each do |i|\n if num % i == 0 && is_prime?(i)\n divisor = i\n end\n end\n\n divisor\nend",
"def largest_prime_factor(num)\n return num if prime?(num)\n\n prime_factors(num).max\nend",
"def largest_prime_factor(num)\n\ti=2 \n\tquotient = 0\n\twhile(quotient != 1) do\n\t\ti +=1\n\t\tif(is_prime?(i) && (num % i == 0))\n\t\t\tdivisor = quotient == 0 ? num : quotient\n\t\t\tquotient = divisor / i\n\t\tend\t\n\tend\n\treturn i \nend",
"def largest_prime_factor(number)\n prime = 2\n max = 1\n while (prime <= number)\n if(number % prime == 0)\n max = prime\n number = number/prime\n else\n prime += 1\n end\n end\n max\nend",
"def largest_prime_factor (num)\n largest = 1\n (2..num).each do |ele|\n if num % ele == 0 && prime?(ele) && largest < ele\n largest = ele\n end\n end\n return largest\nend",
"def largest_prime_factor(num)\n factors = (1..num).select { |factor| num % factor == 0}\n large_prime = factors.reverse.select { |i| return i if prime?(i)}\nend",
"def largest_prime_factor(num)\n (0..num).reduce { |acc, n| prime?(n) && (num % n).zero? ? n : acc }\nend",
"def largest_prime(n) #600851475143\r\n p = 0\r\n i = 5\r\n nums = []\r\n while i*i < n\r\n if n % i == 0\r\n nums << i\r\n end\r\n\r\n i += 1\r\n end\r\n\r\n nums.reverse_each do |num|\r\n if prime?(num)\r\n return num\r\n end\r\n end\r\n\r\nend",
"def largest_prime_factor(number)\n # divide by the smallest prime number (2) until\n # number is no longer divisble by the given prime number\n\n # iterate to the next (prime) number\n # divide and repeat\n # the forumula will return the largest prime factor\n\n prime_number = 2\n counter = 0\n\n while prime_number != number\n if number % prime_number == 0\n number /= prime_number\n else\n prime_number += 1\n end\n \n end\n prime_number\nend",
"def largest_prime_factor(num)\n prime_factors = []\n (2..num).each do |n|\n prime_factors << n if prime?(n) && num % n == 0\n end\n prime_factors[-1]\nend",
"def largest_prime_factor(num)\n\n def prime?(num)\n return false if num < 2\n\n (2...num).each do |n|\n if num % n == 0\n return false\n end\n end\n\n true\n end\n\n if prime?(num)\n return num\n end\n\n (num.downto(2)).each do |i|\n if prime?(i) && num % i == 0\n return i\n end\n end\nend",
"def largest_prime_factor(num)\n divisors = []\n (2..num).each do |divisor|\n if num % divisor == 0\n if prime?(divisor)\n divisors << divisor\n end\n end\n end\n divisors[-1]\nend",
"def largest_prime_factor(number)\n\tfactors = []\n\n\t(1...number).each do |i| \n\t\tif number % i == 0 && Prime.prime?(i)\n\t\t\tfactors.push(i)\n\t\tend\n\tend\n\tfactors.last\nend",
"def largest_prime_factor(num)\n num.downto(1) do |n|\n if num % n == 0 && prime?(n)\n return n\n end\n end\nend",
"def largest_prime_factor(num)\n \n (1..num).inject do |largest_factor, factor|\n if num % factor == 0 && prime?(factor)\n largest_factor = factor\n else\n largest_factor\n end\n end\nend",
"def largest_prime_factor(num)\n return nil if num <= 1\n (2..num).reverse_each do |n|\n return n if prime?(n) && num%n == 0\n end\nend",
"def largestPrimeFactor(num)\n\t(2..num).each do |n|\n\t\treturn num if num <= n\n\t\tnum /= n if (num > n && num % n == 0)\n\tend\nend",
"def largest_prime_factor(num)\n num.downto(2) do |i|\n return i if (num % i).zero? && prime(i)\n end\nend",
"def largest_prime_factor(n)\n i = 2\n largest = 0\n while i <= n\n if n % i == 0\n while n % i == 0\n n = n / i\n largest = i\n i += 1\n end\n end\n i += 1\n end\n return largest\nend",
"def highest_prime_of(factors)\n factors.each do |factor|\n if check_prime(factor)\n return factor\n end\n end\nend",
"def largest_prime_factor(num)\n lnum = nil\n (2..num).each do |factor|\n if num % factor == 0 && prime?(factor)\n lnum = factor\n end\n end\n lnum\nend",
"def largest_prime_factor(num)\n big = 0\n prime = 0\n \n return false if num < 2\n\n # num is the only prime\n return num if prime?(num)\n \n # loops in reverse and returns the largest and first divisible prime\n j = num - 1\n while j > 1\n if num % j == 0 && prime?(j)\n return j\n end\n j -= 1\n end\nend",
"def largest_prime_factor_of(num)\n max = num\n test = 3\n best = 1\n\n while (max >= test) do\n if max % test == 0\n best = test\n max = max / test\n else\n test += 2\n end\n end\n best\nend",
"def largest_prime_factor n\n max_prime = -1\n i = 3\n # check if n is product of 2's. then the max prime is 2. and n will be 1 at the end.\n while n % 2 == 0\n max_prime = 2\n n /= 2\n end\n\n #if n is produc of 3's , then the max prime is 3, and n will be 1 at the end.\n #if n is not product of 3's, it contains other prime factors. these factors must be greater\n #than 3 because we alreay excluded 2's in the previous step. and we have excluded 2's multiples in the\n #previous steps, so only need to check the odd numbers for possible factors.\n while i*i <= n\n while n % i == 0\n max_prime = i\n n /= i\n end\n i += 2\n end\n\n if n > 2\n max_prime = n\n end\n max_prime\nend",
"def get_largest_prime_factor num\n get_largest_number(prime_factor_numbers(num))\nend",
"def largest_prime_factor(num)\n return nil if num < 2\n (1..num).inject do |acc, fact|\n if num % fact == 0 && prime?(fact) && fact >= acc\n fact\n else\n acc\n end\n end\nend",
"def largest_prime_factor(input)\n factors = []\n (1..input).each do |x|\n if input % x == 0\n factors << x\n x += 1\n else\n x == input\n break\n end\n end\nend",
"def largest_prime_factor(number)\n factor = 1\n\n while factor <= number\n if number % factor == 0\n return number / factor if is_prime?(number / factor)\n end\n factor += 1\n end\nend",
"def largest_factor(number)\n result = prime_factors(number).sort\n result[-1]\nend",
"def largest_prime_factor(input)\n prime = input\n (2..Math.sqrt(input).to_i).each do |i|\n # Here we use the square root function to cut our range down drastically\n break if prime <= 1\n while (prime > i && prime % i == 0) do\n prime /= i\n puts \"prime - #{prime}, i - #{i}\"\n end\n end\n prime\nend",
"def largest_prime_factor( x ) \n require 'mathjb'\n primes = primes_below(x)\n i = 0\n \n until primes.include?(x)\n div = primes[i]\n if x % div == 0 then\n x /= div #if div is a factor of x, set x to x / div\n i = 0\n else\n i += 1\n end\n end\n return x\nend",
"def largest_prime_factor(num)\n i = num - 1\n\n while i > 1 \n if is_prime?(i) && num % i == 0\n return i \n end\n i -= 1\n end\n \n num\nend",
"def largest_prime_factor(n)\n divisor = 2\n while(divisor <= n)\n n%divisor == 0 ? n = n/divisor : divisor += 1\n end\n divisor\nend",
"def largest_prime_factor(num)\n i = num\n while i > 0\n if num%i == 0 && prime?(i)\n return i\n end\n i -= 1\n end\nend",
"def largest_prime_factor(num)\n largest = num\n variable_num = 2\n\n while variable_num < largest\n while largest % variable_num == 0 && largest != variable_num\n largest = largest / variable_num\n end\n variable_num += 1\n end\n return largest\nend",
"def largest_prime_factor(n)\n recursive_prime_factors(n)\n PRIMES.keys.sort().last\nend",
"def largest_prime_factor(num)\n i = num - 1\n while i >= 2\n if num % i == 0 && is_prime?(i) == true\n return i\n end\n i -= 1\n end\n num\nend",
"def largest_prime_factor(current_number)\n\tprime_factors = []\n\ti = 2\n\twhile current_number > 1\n\t\twhile current_number % i == 0\n\t\t\tprime_factors << i\n\t\t\tcurrent_number /= i\n\t\tend\n\t\ti += 1\n\tend\n\treturn prime_factors.last\nend",
"def largest_prime_factor(num,prime_factors,recursive)\n candidate = 2\n until candidate >= Math.sqrt(num)\n recursive = false\n if num % candidate == 0\n num = num / candidate\n recursive = true\n prime_factors << candidate\n largest_prime_factor(num,prime_factors,recursive)\n end\n break if recursive\n candidate == 2 ? candidate += 1 : candidate += 2\n end\n prime_factors << num unless recursive\n prime_factors.last\nend",
"def find_highest_prime_factor(n)\n # Read http://joezack.com/index.php/2009/01/15/project-euler-problem-3-in-ruby/ - which points out you can\n # stop searching at the square root of a number. Speedup!\n (Math.sqrt(n).ceil).downto 2 do |i|\n if n % i == 0 && find_highest_prime_factor(i) == 1\n return i\n end\n end\n 1\nend",
"def primeFactors(x)\n\tlargestFactor = 1\n\tcurrentFactor = 1\n\twhile currentFactor <= x # limit of the problem\n\t\tif x % currentFactor == 0 \n\t\t\tx = x / currentFactor\n\t\t\tif currentFactor > largestFactor\n\t\t\t\tlargestFactor = currentFactor\n\t\t\t\tcurrentFactor = 0\n\t\t\tend\n\t\tend\n\t\tcurrentFactor += 1\n\tend\n\treturn largestFactor\nend",
"def larget_prime_factor(n)\n temp = n\n largest = 0\n div = 2\n\n while temp >= div * div\n if temp % div == 0\n temp /= div\n else\n div += 1\n end\n end\n\n largest = temp if temp > largest\n return largest\nend",
"def largest_prime(int)\n def is_prime?(int)\n div = 2\n until div >= int\n return false if int % div == 0\n div += 1\n end\n true\n end\n remainder = int\n divider = 2\n prime_factors = []\n while divider < remainder\n if remainder % divider == 0 && is_prime?(divider)\n prime_factors << divider\n remainder /= divider\n end\n divider += 1\n end\n prime_factors << remainder\n puts prime_factors\n prime_factors.max\nend",
"def highest_possible_factor\n Math.sqrt(number)\n end",
"def highest_possible_factor\n Math.sqrt(number)\n end",
"def compute\n n = 600851475143\n\n while true\n p = smallest_prime_factor(n)\n\n if p < n\n n /= p\n else\n return n\n end\n end\nend",
"def largest_prime_factor(num)\n #prime_division returns an array of 2 element arrays containing prime factorization - [[2, 1], [5, 2]]\n #flat_map contatenates the 2 element arrays into a single array [2, 5, 5]\n array = Prime.prime_division(num).flat_map { |factor, power| [factor] * power }\n\n largest = 0\n array.each do |i|\n if i > largest\n largest = i\n end\n end\n return largest\nend",
"def largest_prime_factor(n, r = [])\n prime = Prime.lazy\n r = r || []\n if n.prime?\n r << n\n return r\n else\n factor = prime.find { |j| n % j == 0 } # 用find,找到第一个就结束\n r << factor\n prime.rewind\n largest_prime_factor (n / factor), r\n end\n r.max\nend",
"def largest_prime_factor(input)\n lpf = 2\n\n while lpf < input\n\n if input % lpf == 0\n\n input = input / lpf\n lpf = 2\n else\n lpf += 1\n end\n end\n\n return lpf\nend",
"def greatest_prime_factor(n)\n return false if n < 1\n divisor = Math.sqrt(n).floor\n\n while divisor>=2\n return divisor if prime?(divisor) && n%divisor==0\n divisor-=1\n end\n return false\nend",
"def three num\n max = 0\n acc = 1\n for i in 2..num\n if num % i == 0 #first check if i divides the number\n if isPrime?(i) #then check if it is prime (part of the prime factorization)\n max = i #keep the max so far\n temp = num #this loop is for numbers made up of many of the same prime i.e. 2^32\n while (temp % i == 0)\n temp = temp / i\n acc = acc * i\n if acc == num\n return max\n end\n end\n end\n end\n end\n return max\nend",
"def find_largest_prime(integer)\n factor_array = []\n potential_factor_array = (2..integer).to_a\n potential_factor_array.each do |factor|\n if integer % factor == 0\n factor_array << factor\n end\n end\n largest_factor = factor_array.last\n potential_factor_array = (2..largest_factor).to_a\n potential_factor_array.each do |potential_factor|\n factor_array.each do |factor|\n if factor != potential_factor && factor % potential_factor == 0\n factor_array.delete(factor)\n end\n end\n end\n p factor_array.last\nend",
"def largest_prime(number)\r\n limit = Math.sqrt(number).floor \r\n (2..limit).select { |n| number % n == 0 && Prime.prime?(n) }.max\r\nend",
"def largest_prime_factor(num)\n puts \"num = #{num}\"\n Prime.first(num).select {|i| i}\nend",
"def largest_factor(n)\n\n result = nil\n (1 .. n/2).each do |d|\n if n % d == 0\n result = d\n end\n end\n\n result\nend",
"def largest_prime(num)\n largest_prime = 0\n i = 2\n while i * i <= num\n if num % i == 0\n num /= i\n largest_prime = i\n else\n i += 1\n end\n end\n\n if num > largest_prime\n largest_prime = num\n end\n\n largest_prime\nend",
"def problem_three\n find_factors(600_851_475_143).max\n end",
"def primo_factor(number)\t\n\n\tresult =[]\n\n\twhile number != 1\n\t\tfor i in 2..10000\n\t\t\tif number % i == 0 && number > 1\n\t\t\t\tresult << i\n\t\t\t\tnumber = number/i\t\t\t\n\t\n\t \t\tend\n\t\tend\n\tend\n\tputs \"The largest prime factor of #{number} is #{result.inspect}. Congrats!\"\n\nend",
"def prob_three\n max = 600851475143**0.5\n\n for i in (1..max).step(2)\n if 600851475143 % i == 0\n if is_prime(i)\n ans = i\n end\n end\n end\n ans\nend",
"def largest_prime(number)\n is_prime = false\n current_num = number\n divisor = 2\n max_prime = 1\n\n while is_prime != true && divisor <= current_num\n if current_num % divisor === 0\n current_num /= divisor\n if divisor > max_prime\n max_prime = divisor\n end\n divisor = 2\n else\n divisor += 1\n end\n\n if divisor > current_num\n is_prime = true\n end\n end\n\n puts max_prime\n return max_prime\nend",
"def my_largest_prime(num)\n counter = 2\n until num == 1\n if num % counter == 0\n sol = counter\n num /= counter\n else\n counter += 1\n end\n end\n return sol\nend",
"def getMaxPrime(numb)\n def isPrime(n)\n return false if n <= 1\n 2.upto(Math.sqrt(n).to_i) do |x|\n return false if n%x == 0\n end\n true\n end\n\n primes = []\n (2..10000).each { |x| primes << x if isPrime(x) }\n \n max = 0\n primes.each do |i|\n if numb % i == 0\n max = i\n end\n end\n puts max\nend",
"def largest_prime_factor(number)\n # start with the number and go backwards\n while number > 0\n numb_split = number.to_s.split('')\n numb_split_length = numb_split.length\n #p numb_split[numb_split_length - 1]\n if numb_split[numb_split_length - 1] == \"5\" || numb_split[numb_split_length - 1] == \"0\" \n\n \n elsif number%2 == 0 && number > 2 \n # definitely not prime\n elsif number%2 == 0 && number%3 == 0\n \n \n else\n # test if number is prime\n # if number is prime\n \n\n p number.to_s\n end\n number -= 1 \n end\n\nend",
"def largest_number_digit\n (@primes.last ** 2).to_s.length\n end",
"def prime?(integer)\nn = integer\nif n < 1 then raise ArgumentError.new(\"Positive integers only\")\nend\nlargest_factor = nil\nfor i in 2..(n/2)\n\tif (n % i) == 0\n\t\tlargest_factor = i\n\tend\nend\n\nlargest_factor ||= n \nend",
"def largest_prime_number(upper)\n answer = 2\n point = 3\n divisor = upper\n\n divisor /= 2 while divisor.even?\n\n while divisor != 1\n while (divisor % point) == 0\n answer = point\n divisor /= point\n end\n point += 2\n end\n answer\nend",
"def greatest_factor(num)\n (2...num).reverse_each { |i| return i if num % i == 0}\nend",
"def smallest_multiple(n)\n def get_prime_factors(n, factors=[])\n return n if n.prime?\n \n Prime.first(n).each do |prime|\n if n % prime == 0\n factors << prime\n n /= prime\n break\n end\n end\n \n \n factors + [get_prime_factors(n)].flatten\n end\n \n def get_highest_exponents(n, factors=[])\n (2..n).each do |m|\n if get_prime_factors(m).is_a? Array\n factors << get_prime_factors(m)\n else\n factors << [m]\n end\n end\n \n highest = []\n Prime.first(n).select { |p| p < n }.each do |factor|\n highest << factors.sort_by { |f| f.count(factor) }[-1].select { |num| num == factor }\n end\n \n \n highest.flatten\n end\n\n\n get_highest_exponents(n).reduce(:*)\nend",
"def anti_prime?(num)\n max_f = 0\n (1...num).each do |n|\n tmp = n_factors(n)\n if tmp > max_f\n max_f = tmp\n end\n end\n if n_factors(num)>max_f\n return true\n else\n return false\n end\nend",
"def euler038\n (9213..9876)\n .map{ |x| x.to_s + (x*2).to_s }\n .select{ |f| f.chars.sort.join == \"123456789\" }\n .map{ |f| f.to_i }\n .max\nend",
"def max_factor(n)\n\tfactors = [1, n]\n\tidx = 2\n\twhile idx < factors[-1]\n\t\tif factors[-1] % idx == 0\n\t\t\tnew = factors[-1] / idx\n\t\t\tfactors.pop\n\t\t\tfactors.push(idx)\n\t\t\tfactors.push(new)\n\t\t\tidx = 1\n\t\tend\n\t\tidx += 1\n\tend\n\treturn factors[-1]\nend",
"def euler(num)\n thousand = 7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450\n largest = 0\n working_ary = []\n thousand.to_s.split(\"\").each_cons(num) { |ary| working_ary << ary }\n working_ary.uniq!\n working_ary.each do |ary|\n if ary.reduce { |product, n| (product.to_i) * (n.to_i) } > largest\n largest = ary.reduce { |product, n| (product.to_i) * (n.to_i) }\n end\n end\n largest\nend",
"def print_primes(num)\r\n\tlargest_div = 2;\t\t\t\r\n\twhile num > 1\r\n\t\tdiv = 2;\r\n\t\twhile num % div != 0\r\n\t\t\t\tdiv += 1\r\n\t\tend\r\n\t\tnum = num / div\r\n\t\tlargest_div = div\r\n\tend\r\n\treturn largest_div\r\nend",
"def largest_factor(n)\n arr = []\n num = 1\n while num < n \n if n % num == 0\n arr << num \n end\n num+=1\n end\n arr[-1]\nend",
"def factor(number)\n val = Math.sqrt(number).floor\n while number%val != 0\n val -= 1\n end\n return val\n end",
"def highest_prime_number_under(number)\n highest_prime = 0\n for num in 1..number\n if is_prime?(num) && num > highest_prime\n highest_prime = num\n end\n end\n return highest_prime\nend",
"def problem3 ( )\n n = 600851475143\n i = 1\n while (i < n)\n if n % i == 0\n n /= i\n i -= 2\n end\n i += 2\n end\n n\nend",
"def Division(num1,num2)\n factors = []\n (1..10**3).each {|idx| factors << idx if (num1 % idx == 0 && num2 % idx == 0)}\n factors.max\nend",
"def check_factor(factor, max_divisor)\n is_factor = true\n \n # Start looping high, since higher numbers are less likely to be factors, so\n # the loop can bail out early if the highest number isn't a factor\n # Only loop down to 2, since everything is divisible by 1\n max_divisor.downto(2).each { |i|\n # Determine factor is evenly divisble by 1\n is_factor = is_factor && (factor % i == 0)\n\n # If factor is not evenly divisible by i, don't bother checking lower nums\n break if !is_factor\n }\n\n # Return whether or not it's a factor\n is_factor\nend",
"def highest_prime_number_under(number)\n highest_prime_number_under = 0\n ary = (number-1).downto(2).to_a\n ary.each do |x|\n counter = 0 \n (2..(x-1)).each do |num|\n if ( x % num ) == 0\n counter += 1\n else\n counter = counter\n end \n end \n \n if counter > 0 \n highest_prime_number_under = 0\n else \n highest_prime_number_under = x\n p \"The highest prime number under #{number} is \" + x.to_s\n break\n end\n end \nend",
"def consecutive_prime_below_one_million\n @max_limit = 1000_000\n generate_prime_numbers()\n # number_of_primes = 0\n result = 0\n\n count_prime_sum = @prime_numbers_sum.length\n number_of_primes = 1\n # i_index = 0\n count_prime_sum.times do |i_index|\n for j in (count_prime_sum - 1).downto(i_index + number_of_primes ) do\n difference = @prime_numbers_sum[j] - @prime_numbers_sum[i_index]\n if (j - i_index > number_of_primes) && difference < @max_limit && ( @prime_numbers.include? difference) #\n number_of_primes, result = j - i_index, difference\n break\n end\n end ## end of j\n end ## end of i\n\n puts '=============================================================================================='\n puts 'Q2: Which prime, below one million, can be written as the sum of the most consecutive primes?'\n puts \"Sol: Result For Finding consecutive prime below #{@max_limit} : #{result}, and \\n Number of primes in those are #{number_of_primes}\"\n puts '=============================================================================================='\n\n end",
"def smallest_multiple(min, max)\n factors_hash = {}\n\n (min..max).each do |n|\n factor_hash = {}\n prime_factors(n).each do |factor|\n factor_hash[factor] = factor_hash[factor] ? factor_hash[factor] + 1 : 1\n end\n factor_hash.each do |factor, exponent|\n if factors_hash[factor] == nil || exponent > factors_hash[factor]\n factors_hash[factor] = exponent\n end\n end\n end\n factors_hash.inject(1) do |product, (factor, exponent)|\n product *= factor**exponent\n end\nend"
] | [
"0.8555166",
"0.844039",
"0.8025793",
"0.7937887",
"0.7920968",
"0.7901872",
"0.7878956",
"0.78620994",
"0.78613913",
"0.78487843",
"0.784481",
"0.78425133",
"0.7822209",
"0.7820768",
"0.7819627",
"0.77966636",
"0.77774906",
"0.77731633",
"0.77730536",
"0.77686644",
"0.7768292",
"0.7746884",
"0.77424335",
"0.7737697",
"0.77085096",
"0.7691877",
"0.7690487",
"0.766727",
"0.76414776",
"0.7621763",
"0.7608139",
"0.75899607",
"0.75854677",
"0.7581708",
"0.7579514",
"0.7575789",
"0.7573058",
"0.7564438",
"0.7559431",
"0.7556221",
"0.75479007",
"0.7537759",
"0.7531677",
"0.75223225",
"0.75011265",
"0.7497161",
"0.7482803",
"0.746416",
"0.7457129",
"0.7447777",
"0.74476725",
"0.74385536",
"0.7437376",
"0.74343",
"0.74053365",
"0.73941576",
"0.73927325",
"0.73599035",
"0.73417133",
"0.7330204",
"0.727882",
"0.72667307",
"0.725433",
"0.725433",
"0.72301066",
"0.7223065",
"0.72092485",
"0.71299547",
"0.71102065",
"0.7107816",
"0.709028",
"0.7076184",
"0.70723605",
"0.701589",
"0.69889486",
"0.6966381",
"0.6950232",
"0.69391125",
"0.6936624",
"0.6864051",
"0.6847339",
"0.67578423",
"0.67446977",
"0.67385083",
"0.6729874",
"0.6713752",
"0.669764",
"0.668841",
"0.6632246",
"0.6627231",
"0.66172373",
"0.6602697",
"0.6588859",
"0.6586274",
"0.65722984",
"0.6529146",
"0.6522493",
"0.6511938",
"0.64719003",
"0.64707774",
"0.6410177"
] | 0.0 | -1 |
Restarts the SSH service | def ssh_service_restart
exec(Beaker::Command.new("stopsrc -g ssh"))
exec(Beaker::Command.new("startsrc -g ssh"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ssh_service_restart\n case self['platform']\n when /debian|ubuntu|cumulus|huaweios/\n exec(Beaker::Command.new(\"service ssh restart\"))\n when /(el|centos|redhat|oracle|scientific)-[7-9]|eos-7|fedora-(1[4-9]|2[0-9]|3[0-9])|archlinux-/\n exec(Beaker::Command.new(\"systemctl restart sshd.service\"))\n when /el-|centos|fedora|redhat|oracle|scientific|eos/\n exec(Beaker::Command.new(\"/sbin/service sshd restart\"))\n when /opensuse|sles/\n exec(Beaker::Command.new(\"/usr/sbin/rcsshd restart\"))\n when /solaris/\n exec(Beaker::Command.new(\"svcadm restart svc:/network/ssh:default\"))\n when /(free|open)bsd/\n exec(Beaker::Command.new(\"sudo /etc/rc.d/sshd restart\"))\n else\n raise ArgumentError, \"Unsupported Platform: '#{self['platform']}'\"\n end\n end",
"def restart()\n shutdown()\n start()\n end",
"def restart\n raise _(\"Server restart is only supported on Linux\") unless MiqEnvironment::Command.is_linux?\n\n _log.info(\"Server restart initiating...\")\n update_attribute(:status, \"restarting\")\n\n shutdown_and_exit(RESTART_EXIT_STATUS)\n end",
"def restart\n request('restart')\n end",
"def restart\n client.restart\n end",
"def restart # :nodoc:\n put :restart\n end",
"def restart\n if @restart_command\n run_command(@restart_command)\n else\n stop\n start\n end\n end",
"def restart_soon\n @restart = true\n @shutdown = true\n end",
"def restart!\n # Permissions are handled by the script, use: :sudo => false\n run_script! :restart, :sudo => false\n end",
"def restart\n # Permissions are handled by the script, use: :sudo => false\n run_script :stop, :sudo => false\n end",
"def restart\n raw \"RESTART\\r\\n\"\n end",
"def restart\n\t\t# puts \"Restarting #{@ip} ...\"\n\t\tsystem ipmi_command + \" chassis power cycle\"\n\tend",
"def restart_linux_service(service)\n message = \"Information:\\tRestarting Service \"+service\n command = \"service #{service} restart\"\n output = execute_command(message,command)\n return output\nend",
"def restart_atd(vp)\n system \"ssh uw_revtr2@#{vp} 'sudo /etc/init.d/atd restart > /dev/null 2>&1'\"\n end",
"def restart!\n start!\n end",
"def restart_command(cmd); end",
"def restart\n\trequire_relative '../../lib/falcon/command/supervisor'\n\t\n\tFalcon::Command::Supervisor[\"restart\"].call\nend",
"def restart\n if booted then\n kill\n end\n start\n end",
"def restart\n stop\n start\nend",
"def restart(*services) = execute(services: services)",
"def restart\n stop\n start\n end",
"def restart!\n IbmCloudRest.post \"#{@uri}/_restart\"\n end",
"def restart!\n stop!\n start!\n end",
"def restart\n stop\n sleep 2\n start\n end",
"def restart_service\n service 'consul-haproxy' do\n action :restart\n end\nend",
"def restart(params)\n services = services_from_params(params)\n if @environment.in_dry_run_mode\n services.each do |agent|\n notify(:msg => \"[#{@name}] Would restart #{agent.host} (#{agent.type})\",\n :tags => [:galaxy, :dryrun])\n end\n services\n else\n command = ::Galaxy::Commands::RestartCommand.new([], @galaxy_options)\n command.report = GalaxyGatheringReport.new(@environment,\n '[' + @name + '] Restarted #{agent.host} (#{agent.type})',\n [:galaxy, :trace])\n execute(command, services)\n command.report.results\n end\n end",
"def restart_running_instances_services\n nodes.each do |node|\n node.restart_with_monit\n end\n end",
"def reboot\r\n raise Shells::NotRunning unless running?\r\n raise Shells::PfSenseCommon::RestartNow\r\n end",
"def cmd_restart argv\n setup argv\n response = @api.restart\n msg response\n return response\n end",
"def refresh \n if (@parameters[:ensure].value == :running)\n provider.restart\n else\n debug \"Skipping restart; service is not running\"\n end\n end",
"def restart\n debug \"Call 'restart' for Pacemaker service '#{name}' on node '#{hostname}'\"\n if pacemaker_options[:restart_only_if_local] and not primitive_is_running? name, hostname\n info \"Pacemaker service '#{name}' is not running on node '#{hostname}'. Skipping restart!\"\n return\n end\n\n begin\n stop\n rescue\n debug 'The service have failed to stop! Trying to start it anyway...'\n ensure\n start\n end\n end",
"def restart_server\n stop_server\n sleep 1\n start_server\n end",
"def hot_restart\n system \"kill -s USR2 #{pid} > /dev/null 2>&1\"\n end",
"def restart\n if config.managed? && started?\n stop\n start\n end\n end",
"def restart\n stop\n sleep(1)\n start\n end",
"def restart\n stop\n sleep(1)\n start\n end",
"def restart\n stop; start\n end",
"def restart\n self.stop\n self.start\n end",
"def config_root_ssh(vim, vm, auth, state)\n clear_line\n print '[ ' + 'INFO'.green + \" ] Configuring root ssh access. Setting to state #{state}.\"\n if state == 'enabled'\n programpath = '/bin/sed'\n arguments = '-i \\'s/\\(^PermitRootLogin no\\)/PermitRootLogin yes/g\\' /etc/ssh/sshd_config'\n elsif state == 'disabled'\n programpath = '/bin/sed'\n arguments = '-i \\'s/\\(^PermitRootLogin yes\\)/PermitRootLogin no/g\\' /etc/ssh/sshd_config'\n else\n clear_line\n puts '[ ' + 'ERROR'.red + \" ] Invalid state set for configure_root_ssh. State: #{state}\"\n raise 'ERROR'\n end\n spec = { :programPath => programpath, :arguments => arguments }\n\n #run command through GuestOps\n pid = vim.serviceContent.guestOperationsManager.processManager.StartProgramInGuest(:vm => vm, :auth => auth, :spec => spec) \n\n #list process of command and get exit code\n process = vim.serviceContent.guestOperationsManager.processManager.ListProcessesInGuest(:vm => vm, :auth => auth, :pids => [pid]).first\n\n exit_code = vim_wait(vim, vm, auth, process)\n\n #restart sshd\n print '[ ' + 'INFO'.green + \" ] Restarting the sshd service\"\n spec = { :programPath => '/sbin/service', :arguments => 'sshd restart' }\n\n #run command through GuestOps\n pid = vim.serviceContent.guestOperationsManager.processManager.StartProgramInGuest(:vm => vm, :auth => auth, :spec => spec) \n\n #list process of command and get exit code\n process = vim.serviceContent.guestOperationsManager.processManager.ListProcessesInGuest(:vm => vm, :auth => auth, :pids => [pid]).first\n\n exit_code = vim_wait(vim, vm, auth, process)\n\n if exit_code == 0\n clear_line\n print '[ ' + 'INFO'.green + \" ] Succesfully restart SSHD\"\n return 'SUCCESS'\n else\n clear_line\n puts '[ ' + 'ERROR'.red + \" ] Failed to succesfully restart sshd on #{vm}.\"\n raise 'ERROR'\n end\nend",
"def run_restart(options={}, &block)\n with_each_host { stop(options); start(options) }\n end",
"def restart config={}\n stop\n start(config)\n end",
"def restart; end",
"def restart\n\t\treturn nil unless self.running?\n\t\tProcess.kill 'SIGHUP', @pid\n\tend",
"def restart_vm(vmname)\r\n current = {:errormsg => \"\", :status => \"\", :time => \"\", :vmstatus => \"\"}\r\n\r\n conn_opts=get_cli_connection\r\n Chef::Log.debug(\"#{conn_opts[:host]}...show vm name=#{vmname}\")\r\n Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|\r\n output = ssh.exec!(\"restart vm name=#{vmname}\")\r\n output.each_line do |line|\r\n if line.match(/Status:/)\r\n current[:status]=line.split[1].strip\r\n elsif line.match(/Time:/)\r\n line[\"Time: \"]=\"\"\r\n current[:time]=line.strip\r\n elsif line.match(/Error Msg:/)\r\n line[\"Error Msg: \"]=\"\"\r\n current[:errormsg]=line.strip\r\n end\r\n end\r\n end\r\n return current\r\n end",
"def refresh_linux_service(service_name)\n restart_service(service_name)\n return\nend",
"def restart\n stop\n start\n end",
"def restart\n stop\n start\n end",
"def restart\n stop\n start\n end",
"def restart_container\n do_service_action :restart_container\n end",
"def restart(*args)\n stop\n start\n end",
"def Restart\n RunSystemCtl(\"network\", \"stop\")\n EnableDisableNow()\n RunSystemCtl(\"network\", \"start\")\n\n nil\n end",
"def restart\n stop\n start\n end",
"def restart\n stop\n start\n end",
"def restart; stop; start; end",
"def restart_monit_service(service_name, options = {})\n options = options.clone\n host = options.delete(:host) || 'localhost',\n port = options.delete(:port)\n timeout_sec = options.delete(:timeout_sec) || DEFAULT_MONIT_SERVICE_HOST_PORT_TIMEOUT_SEC\n raise \"Invalid options: #{options}\" unless options.empty?\n\n get_stable_monit_service_status(service_name)\n shell_out!(\"monit restart #{service_name}\")\n\n # Wait for service status to stabilize once again.\n get_stable_monit_service_status(service_name)\n if host && port\n require 'waitutil' # Only require this when necessary, so that the gem is installed.\n Chef::Log.info(\n \"Waiting for service #{service_name} to become available on host #{host}, port #{port}\")\n WaitUtil.wait_for_service(service_name, host, port, delay_sec: 1,\n timeout_sec: timeout_sec)\n end\n end",
"def restart\n ensure_session\n ensure_cli\n IRB.irb_at_exit\n str = \"Restarting: `#{ENV['IRT_COMMAND']}`\"\n puts\n puts IRT.dye(\" #{str} \", \"*** #{str} ***\", :error_color, :bold, :reversed)\n puts\n exec ENV[\"IRT_COMMAND\"]\n end",
"def restart\n puts \"\\n\\n project:\"\n puts ' command: restart'\n puts \" name: #{File.basename(root_dir)}\"\n puts \"\\n docker-machine:\"\n puts \" name: #{project_config['docker-machine']['name']}\"\n unless vm_running?\n puts ' status: NOT running '\n puts \"\\n\\n docker-machine not even running - thus do regular start\\n\\n\"\n start\n else\n puts ' status: running '\n puts \"\\n docker-compose:\"\n puts \" service: #{project_config['docker-compose']['service']}\"\n unless service_running?\n puts ' status: NOT running '\n puts \"\\n\\n service not even running - thus do regular start\\n\\n\"\n start\n else\n puts \" status: restarting... \\n\\n\"\n exec(\"#{setup_docker_env_vars_str} docker-compose restart\")\n end\n end\nend",
"def restart\n stop if is_running?\n start\n\n is_running?\n end",
"def restart(wait=nil, expected_exitcodes = [0])\n @logger.debug('restart()')\n\n if self.is_passthrough? and self.passthrough[:type].eql?(:local)\n @logger.warn(sprintf('intercepted [restart] sent to a local passthrough, no op'))\n return nil\n end\n\n if @vagrant_reboot\n # leading vagrant handle this through 'reload --no-provision'\n self.reload\n else\n # trying to do it ourselves\n case os_type\n when :osx\n self.run('shutdown -r now', expected_exitcodes)\n when :rhel, :ubuntu\n if os_type.eql?(:rhel) and os_version(os_type).match(/7/)\n self.run('shutdown --halt --reboot now', expected_exitcodes << 256)\n else\n self.run('shutdown -rf now')\n end\n when :solaris\n self.run('shutdown -y -i5 -g0', expected_exitcodes)\n else\n raise InternalError.new(sprintf('unsupported OS[%s]', @ostype))\n end\n end\n\n @ssh, @ssh_info = nil # severing the SSH tunnel, getting ready in case this box is brought back up on a different port\n\n if wait\n inc = wait.to_i / 10\n 0.upto(9) do |e|\n @logger.debug(sprintf('waiting for reboot: round[%s], step[%s], total[%s]', e, inc, wait))\n return true if self.is_available_via_ssh?()\n sleep inc\n end\n\n return false\n end\n\n return true\n end",
"def restart \n log \"Restarting\"\n puts config.inspect if config[:debug]\n \n @svns = (YAML.load_file config[:svns] rescue {})\n @atoms = (YAML.load_file config[:atoms] rescue {})\n\n @socket.close if @socket\n connect\n listen\n end",
"def action_restart\n proxy_action(:restart)\n end",
"def reboot\n node.update!(alive: false)\n run(\"reboot\")\n end",
"def on_restart(&block); end",
"def restart\n stop if is_running?\n start\n \n is_running?\n end",
"def restart(inode)\n logger.info(\"machine.restart\")\n raise Exceptions::NotImplemented\n end",
"def restart(services)\n generate_config if stale_config\n update_platform_env\n services.each do |service|\n kubectl(\"rollout restart deploy #{clean_kubernetes_name(service)}\")\n end\n # down(services)\n # up(services)\n # status\n end",
"def action_restart\n return if options['never_restart']\n action_stop\n action_start\n end",
"def drb_restart!\n Vedeu.bind(:_drb_restart_) { Vedeu::Distributed::Server.restart }\n end",
"def restart(pid=nil)\n `cp #{APP_ROOT}/services/drb.log #{APP_ROOT}/services/drb.bak`\n `cp #{APP_ROOT}/services/dico.log #{APP_ROOT}/services/dico.bak`\n if !pid.nil?\n pid.each {|x| `kill -1 #{x}`}\n sleep(1)\n end\n `cd #{APP_ROOT};#{WHICH_RAKE} #{RAKE_FILE}[#{SHARD_ID},#{MAX_SHARD}] >#{APP_ROOT}/services/drb.log 2>&1 &`\n puts \"## Restarted\"\nend",
"def relaunch!\n requires :id\n body = [ \"FORCE\", {}]\n body[1][:sshKeyIds] = key_pairs.map {|kp| kp.id} unless key_pairs.empty?\n type = bare_metal? ? :hardware_server : :virtual_guest\n status = service.request(type, \"#{id}/reloadOperatingSystem\", :body => body, :http_method => :post).status\n wait_for { not ready? } # block until the relaunch has begun\n [200, 201].include?(status)\n end",
"def restart!(&block)\n stop! if running?\n start!(&block)\n end",
"def restart(config = nil)\n config ||= agent&.config\n stop if running?\n start(config)\n end",
"def soft_reboot(host_ip)\n run('reboot', host_ip)\n end",
"def restart\n\tcall 'falcon:supervisor:restart'\nend",
"def restart\n\tcall 'falcon:supervisor:restart'\nend",
"def restart\n\tcall 'falcon:supervisor:restart'\nend",
"def restart( timeout = 5 )\n stop( timeout )\n start\n end",
"def restart(pid)\n `kill -s USR2 #{pid}`\n end",
"def ssh\n tries = 1\n @ssh ||= begin\n Net::SSH.start(self, self['user'], self['ssh'])\n rescue\n tries += 1\n if tries < 4\n puts \"Try #{tries} -- Host Unreachable\"\n puts 'Trying again in 20 seconds'\n sleep 20\n retry\n end\n end\n end",
"def restart\n invoke :stop, :all => input[:all], :apps => input[:apps]\n\n line unless quiet?\n\n input[:apps].each do |app|\n unless input[:command].nil?\n app.command = input[:command]\n end\n app.update!\n end\n\n invoke :start, :all => input[:all], :apps => input[:apps],\n :debug_mode => input[:debug_mode]\n end",
"def restart_node\n stop_node\n sleep 1\n start_node\n end",
"def create_ssh_service_action_restart(opts = {})\n data, _status_code, _headers = create_ssh_service_action_restart_with_http_info(opts)\n return data\n end",
"def restart!\n CouchRest.post \"#{@uri}/_restart\"\n end",
"def restart_server(type, date)\n stop_server(type, date)\n start_server(type, date)\n end",
"def refresh\n # Only restart if we're actually running\n if (@parameters[:ensure] || newattr(:ensure)).retrieve == :running\n provider.restart\n else\n debug 'Skipping restart; service is not running'\n end\n end",
"def restart(wait = true)\n stop(wait)\n start(wait)\n end",
"def restart_game_cmd\n msg_details = \"#{@ix_current_game}\"\n cmd_to_send = build_cmd(:restart_game, msg_details)\n send_data_to_server(cmd_to_send)\n end",
"def reload\n run \"#{try_sudo} /sbin/service puppet reload\"\n end",
"def restart(filename)\n start (filename) if shutdown(filename) == true\n end",
"def reboot!\n self.reboot(\"HARD\")\n end",
"def restart\n log('Attempting to restart')\n\n return not_enabled unless Vedeu.config.drb?\n\n if drb_running?\n log('Restarting')\n\n stop\n\n else\n log('Not running')\n\n end\n\n start\n end",
"def refresh\n # Only restart if we're actually running\n if (@parameters[:ensure] || newattr(:ensure)).retrieve == :running\n provider.restart\n else\n debug \"Skipping restart; service is not running\"\n end\n end",
"def restart(vmname, action = 'restart')\n uri = @uri + \"/#{vmname}/#{action}?api-version=#{api_version}\"\n uri\n end",
"def restart!\n lock\n\n begin\n if config.core_base\n @config.state = \"started\"\n write_config current_deployment_number, @config\n @logger.debug \"Restarting core\"\n @starter.restart! config.core_base\n @config.last_start_time = time\n end\n\n announce\n return status\n rescue Exception => e\n error_reason = \"Unable to restart: #{e}\"\n error_reason += \"\\n#{e.message}\" if e.class == Galaxy::HostUtils::CommandFailedError\n @logger.error error_reason\n raise error_reason\n ensure\n unlock\n end\n end",
"def restart!\n JobRestarter.restart(self)\n end",
"def restart(timeout=nil)\n stop(timeout)\n start!\n end",
"def restart_apache\n FileUtils.touch \"#{config.get(:current_path)}/tmp/restart.txt\"\n monit_command \"restart apache2\"\n end",
"def restart_kubelet\n cmd = ['systemctl', 'restart', 'kubelet.service']\n stdout, stderr, status = Open3.capture3(*cmd)\n raise Puppet::Error, _(\"stderr: '%{stderr}'\" % { stderr: stderr }) if status != 0\n { status: stdout.strip }\nend",
"def restart_process\n puts 'restarting'\n exec RbConfig.ruby, File.expand_path(__FILE__), *ARGV\nend",
"def run\n `#{@apachectl} restart`\n end"
] | [
"0.7639621",
"0.72693604",
"0.72511095",
"0.7150708",
"0.7125923",
"0.71143454",
"0.70740026",
"0.70478565",
"0.7003857",
"0.6952376",
"0.69177526",
"0.6909844",
"0.6908254",
"0.68483293",
"0.6836116",
"0.6815306",
"0.6783975",
"0.67428356",
"0.6728189",
"0.6716245",
"0.6711015",
"0.66926056",
"0.6684774",
"0.6664007",
"0.66518915",
"0.66451544",
"0.6633885",
"0.6584191",
"0.6574383",
"0.65650475",
"0.65533143",
"0.65422213",
"0.65294665",
"0.65234166",
"0.6512135",
"0.6512135",
"0.65112203",
"0.64983785",
"0.64983207",
"0.649651",
"0.64959484",
"0.64947385",
"0.6477371",
"0.64718324",
"0.64537126",
"0.64465845",
"0.64465845",
"0.64465845",
"0.64374965",
"0.64349884",
"0.6425731",
"0.6393017",
"0.6393017",
"0.63892496",
"0.63884336",
"0.6386316",
"0.6385175",
"0.6360671",
"0.6352541",
"0.6346526",
"0.63394785",
"0.6339467",
"0.6339367",
"0.6328341",
"0.6312615",
"0.6307341",
"0.6293226",
"0.6290093",
"0.6259274",
"0.6238524",
"0.6225499",
"0.62213486",
"0.62192774",
"0.62086946",
"0.62086946",
"0.62086946",
"0.6197999",
"0.6194232",
"0.6191441",
"0.6190246",
"0.61665416",
"0.61583054",
"0.6155503",
"0.61363995",
"0.6135641",
"0.61275697",
"0.61018574",
"0.60861295",
"0.6064757",
"0.6058203",
"0.60173166",
"0.5994122",
"0.5991863",
"0.5975889",
"0.5975507",
"0.5973309",
"0.5969874",
"0.59480685",
"0.59384763",
"0.593707"
] | 0.8223676 | 0 |
Override in child class | def properties
{}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inherited(base); end",
"def overrides; end",
"def proxy\n super\n end",
"def special\n override\n end",
"def inherited(subclass); end",
"def super_method; end",
"def superclass() end",
"def inherited(klass); end",
"def inherited(klass); end",
"def tag; raise 'Override this method'; end",
"def super_class; end",
"def super_class; end",
"def process_hook\n fail 'child class to implement'\n end",
"def modify\n super\n end",
"def override()\n puts \"CHILD override()\"\n end",
"def initialize()\n # override parent\n end",
"def virtual; end",
"def source(override); end",
"def override() # Note that despite the module.override, this still overrides\r\n puts \"CHILD override()\"\r\n end",
"def inherited(subclass)\n super\n subclass.instance_variable_set(:@_ext, @_ext.dup)\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def type; super; end",
"def protocol\n super\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end"
] | [
"0.76180625",
"0.75793505",
"0.7573107",
"0.7354282",
"0.7263426",
"0.7262659",
"0.72217387",
"0.72018504",
"0.72018504",
"0.7142683",
"0.70852363",
"0.70852363",
"0.70607585",
"0.69983846",
"0.6961868",
"0.6924328",
"0.68898886",
"0.6792732",
"0.6756192",
"0.67481977",
"0.6704421",
"0.6704421",
"0.6677693",
"0.6670778",
"0.6634375",
"0.6634375",
"0.6634375",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025",
"0.6598025"
] | 0.0 | -1 |
0, 1, 1, 2, 3, 5, 8... p fib(7) | def fib(n)
return nil if n < 1
return [0] if n == 1
return [0, 1] if n == 2
result = fib(n - 1)
result.push(result[-1] + result[-2])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fib (x)\n y = x-2\nfib_sequence = y.times.inject(%5B0,1%5D) do |a, idx|\n a << a[-2] + a[-1]\nend",
"def fib(n)\n n.times.each_with_object([0,1]) { |_, results| results << results[-2] + results[-1] }\nend",
"def fib(n)\n n.times.each_with_object([0,1]) { |num, obj| obj << obj[-2]+obj[-1]}\nend",
"def fibs(n)\nend",
"def cool_fib(number)\n (0..number).inject([1,0]) {|i_arr| [i_arr.last, i_arr.first + i_arr.last]}.first\nend",
"def fib(n)\n n.times.each_with_object([0,1]) { |num, obj| obj << obj[-2] + obj[-1] }\nend",
"def fib \n arr = [0, 1]\n\n while arr[-1] + arr[-2] <= 4_000_000\n arr << arr[-1] + arr[-2]\n end\n arr.select(&:even?).inject(:+)\nend",
"def fib(number)\n sequence = [0,1]\n number.times {sequence << sequence[-1] + sequence[-2]}\n sequence[-1]\n return sequence\nend",
"def fib(x)\n fib_nums = [0,1]\n number = x - 2\n number.times do\n fib_nums << fib_nums[-2] + fib_nums[-1]\n end\n p fib_nums\nend",
"def fib(n)\n \nend",
"def fib(n)\n return n if n < 2\n arr = [0, 1]\n (n-1).times { arr << arr.last(2).inject(:+) }\n arr.last\nend",
"def fibs(num)\n array = []\n 0.upto(num) do |i|\n array << i if i.zero? || i == 1\n array << array[i - 1] + array[i - 2] if i > 1\n end\n array\nend",
"def fibs_sum(n)\n\nend",
"def fibs_sum(n)\n\nend",
"def fibs_sum(n)\n\nend",
"def fibs_sum(n)\n\nend",
"def fibs_sum(n)\n\nend",
"def fibs(n) ; PHI**n - PHA**n ; end",
"def fibo(n)\n (1..n).inject([]) { |memo, i| [1, 2].include?(i) ? memo << i : memo << (memo.last + i) }\nend",
"def fibs(num)\n arr = [0, 1]\n\n (2..num).each do |_i|\n arr << arr[-1] + arr[-2]\n end\n\n arr.last\nend",
"def fib(n)\n\nend",
"def fibb(i)\n if i==0 \n return 0\n elsif i==1\n return 1\n else\n prev1=0\n prev2=1\n curr = 0\n #(2..i).each do |x|\n (2..i).each do #so it works w/o x as well\n #2.upto(i) do\n curr = prev1 + prev2 #3 = 1 + 2\n prev1 = prev2 # 1 := 2\n prev2 = curr # 2 := 3\n end\n end\n return curr\nend",
"def fibs(num)\n arry = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]\n arry[num]\nend",
"def fib(number)\n\narr = [0, 1]\n\n\ti = 0\n\t\n\twhile i < number - 2\t\t\n\t\tarr.push(arr[i] + arr[i+1])\n\t\ti += 1\n\tend\n\t\narr\t\nend",
"def fib(n)\nend",
"def fib(n)\nend",
"def fibonaci(n)\n\tfi= [1, 1]\n\t(n-1).times do\n\t\tfi << fi[1]+fi.shift\n\tend\n\treturn fi[0]\nend",
"def fib(num)\n fib_seq_arr = []\n\n (0..num).each do |number|\n fib_seq_arr << number if number <= 1\n fib_seq_arr << fib_seq_arr[-1] + fib_seq_arr[-2] if fib_seq_arr.length > 1\n end\n return fib_seq_arr\nend",
"def fib(int)\r\n\r\n\tif int == 1\r\n\t return [0]\r\n\tend\r\n\r\n\tfibb = [0,1]\r\n\ti=2\r\n\r\n\tuntil i >= int\r\n\t\tfibb << (fibb[-1]+fibb[-2])\r\n\t\ti+=1\r\n\tend\r\n\r\n\tfibb\r\nend",
"def fibs(n)\n arr = [0, 1]\n (n-1).times do\n arr << arr[-1] + arr[-2]\n end\n return arr\nend",
"def fib(n)\n if n == 1\n return [0]\n elsif n == 2\n return [0, 1]\n else\n one_less = fib(n-1)\n one_less << one_less[-1] + one_less[-2]\n return one_less\n end\n\nend",
"def nth_fib(x)\n arr = [0,1]\n count = 1\n while count < x\n next_val = arr[-1] + arr[-2]\n arr = [arr[-1], next_val]\n count += 1\n end\n puts next_val\n # puts \"The weird algorithm from Hackerank comes to: #{next_val % (10**8 + 7)}\"\n end",
"def fib(n)\n return [0, 1, 1][0...n] if n <= 3\n last = fib(n-1)\n last << last[-1] + last[-2]\nend",
"def fibs(n, ary = [0,1])\n n.times { ary << ary[-2] + ary[-1] until ary.length == n }\n return ary\nend",
"def fib_it(n)\n fib_array = [1, 1]\n return fib_array if n == 2\n return [1] if n == 1\n\n (3..n).count { fib_array << fib_array[-2] + fib_array[-1] }\n\n fib_array\nend",
"def fib( max_val )\n x = [ 1, 2 ]\n while\n next_val = ( x[ -2 ] + x[ -1 ] )\n return x if next_val > max_val\n x << next_val \n end\nend",
"def fib(n)\n return fib_num[n] if fib_num[n]\n\n fib_num[n - 2] = fib(n - 2) unless fib_num[n - 2]\n fib_num[n - 1] = fib(n - 1) unless fib_num[n - 1]\n\n return (fib_num[n - 2] + fib_num[n - 1])\n end",
"def fib(x)\n fibo_number = [0, 1]\n (x - 2).times do\n n = fibo_number[-1] + fibo_number[-2]\n fibo_number << n\n end\n puts fibo_number\nend",
"def fibs(n)\r\n\r\n fibs = [0, 1]\r\n until n == fibs.length\r\n fibs << fibs[-1] + fibs[-2]\r\n end\r\n fibs\r\n\r\nend",
"def fibs(n)\r\n\r\n fibs = [0, 1]\r\n until n == fibs.length\r\n fibs << fibs[-1] + fibs[-2]\r\n end\r\n fibs\r\n\r\nend",
"def fib(n)\n return [0,1].take(n) if n <= 2\n prev = fib(n-1)\n prev << prev[-1] + prev[-2]\nend",
"def fib(n)\n #if n > 4000000\n #\treturn puts n\n #end\n return n if (0..1).include? n\n fib(n-1) + fib(n-2) if n > 1\nend",
"def fib (places)\n\n a = 0\n b = 1\n arr = 1..places\n arr = arr.to_a\n arr.each { |num|\n puts b\n a,b = b,a+b\n }\n\nend",
"def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n \n\n fib(n - 1) + fib(n - 2)\nend",
"def fib_it count\n prev = 0\n curr = 1\n for i in 0...count do\n tmp = curr\n curr += prev\n prev = tmp\n end\n prev\nend",
"def fib(x)\n fib = [0,1]\n index_count = 0\n until index_count == x - 2\n fib << (fib[index_count] + fib[index_count + 1])\n index_count += 1\n end\n p fib\nend",
"def fibs(n)\n return [0] if n == 1\n return [0, 1] if n == 2\n fibs = fibs(n - 1)\n fibs << fibs[-2] + fibs[-1]\nend",
"def nthFibonacci (n)\r\n # Your code here\r\n f = [0, 1, 1, 2, 3, 5, 8]\r\n if n < 7\r\n return f[n]\r\n end\r\n\r\n t = 6\r\n fn = 8\r\n\r\n while t < n\r\n fn = (fn * PHI).round(0)\r\n t += 1\r\n end\r\n\r\n return fn\r\nend",
"def iter_fib(n)\n arr=[0,1]\n while arr.length < n\n arr << arr[-1] + arr[-2]\n end\n arr\nend",
"def fib_i(n)\n fin_fib = [0,1]\n until n == fin_fib.length\n fin_fib.push(fin_fib[-2] + fin_fib[-1])\n end\n fin_fib\nend",
"def sum_of_fib(n)\n return fib(n+2)-1;\nend",
"def fibs(num)\n fibs = [0,1]\n until fibs.size == num\n fibs << (fibs[-1] + fibs[-2])\n end\n fibs\nend",
"def fib(n)\n if n == 0 || n == 1\n return n\n end\n\n number1 = 0\n number2 = 1\n number3 = 0\n\n (2..n).each do |index|\n number3 = number1 + number2\n number1 = number2\n number2 = number3\n end\n\n return number3\nend",
"def fib_test(num)\n\n return 1 if num == 1\n return 1 if num == 2\n arr = [1, 1]\n (3..num).map {|n| arr << fib_num(n-1) + fib_num(n-2) }\n # next_num = fib_num(num-1) + fib_num(num-2)\n # fib_test(num-1) + [next_num]\nend",
"def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n\n [fib(n-1),fib(n-2)].reduce(:+)\n\t\nend",
"def iterative_fib (num)\n fib_arr = []\n (1..num).each do |i|\n if i == 1 || i == 2\n fib_arr << 1\n else\n fib_arr << fib_arr[-1] + fib_arr[-2]\n end\n end\n fib_arr\nend",
"def fib(n)\n if n <= 2\n return [0, 1].take(n)\n end\n previous_fib = fib(n-1)\n next_ele = previous_fib[-1] + previous_fib[-2]\n previous_fib << next_ele\nend",
"def fib(n)\n a = 0\n b = 1\n\n while n > 0\n old_b = b\n b = a + b\n a = old_b\n n -= 1\n end\n\n b\n end",
"def fib(n) #n indicates # of elements we want in array\r\n a = 0\r\n b = 1\r\n fib_arr = []\r\n #loop starts iff n >= 1, but x starts from 0 (when n=1, x=0; n=2, x=0,1)\r\n n.times do |x| \r\n if x == 0\r\n fib_arr << a\r\n elsif x == 1\r\n fib_arr << b\r\n else\r\n c = a+b #c is the new fib # we are generating\r\n fib_arr << c\r\n a = b\r\n b = c\r\n end\r\n end\r\n return fib_arr\r\nend",
"def fib(n)\n fib_0 = 0\n fib_1 = 1\n (0...n).each do \n temp = fib_0\n fib_0 = fib_1\n fib_1 = temp + fib_1\n end\n return fib_1\nend",
"def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n return 1 if n == 2\n # return 2 if n == 3\n fib(n - 1) + fib(n - 2)\nend",
"def fib(i)\n return 0 if i == 0\n return 1 if i <= 2\n return fib(i-1) + fib(i-2)\nend",
"def fib(n) \n if n == 0\n return 0\n else\n\tfib_0 = 0\n\tfib_1 = 1\n\t(1..(n-1)).each do \n\t\ttemp = fib_0\n\t\tfib_0 = fib_1\n\t\tfib_1 = temp + fib_1\n\t\t\n\tend\n\treturn fib_1\n end\nend",
"def fibo_finder(n)\n fib_array = [0, 1]\n (2..n).each do |i|\n fib_array << fib_array[i-1] + fib_array[i-2]\n end\n fib_array[n]\nend",
"def gen_fibs3\n fibs = [0,1]\n n = 10\n a,b = 0,1\n (n-1).times do\n a,b = b,a+b\n fibs << b\n end\n fibs\nend",
"def fib(n)\n return 1 if n <= 2\n \n fib_index = 3\n a, b = 1, 1\n \n while fib_index <= n\n c = a + b\n a = b\n b = c\n fib_index += 1\n end\n \n c\nend",
"def fib\n first, second, i = 1, 1, 2\n while second.to_s.size < 1000\n first, second = second, first + second\n i = i + 1\n end \n puts \"#{i}\"\nend",
"def fib(n)\n array = [0, 1]\n (n-2).times { array.push(array[-1] + array[-2])}\n array\nend",
"def fib(n)\n if n == 0\n return [0]\n elsif n == 1\n return [0, 1]\n else\n fib(n-1) << fib(n-1)[-2] + fib(n-1)[-1]\n end\nend",
"def fib(i)\n fib_array = []\n index = 0\n if i <= 0\n puts \"Please use numbers greater than 0.\"\n elsif i == 1\n fib_array << 0\n elsif i == 2\n fib_array << 0\n fib_array << 1\n else\n fib_array << 0\n fib_array << 1\n until fib_array.length >= i\n fib_array << (fib_array[-1] + fib_array[-2])\n end\n p fib_array\n end\nend",
"def fib(number)\n fib_array = [0,1]\n i = 2\n while i < number\n fibNum = fib_array[-1] + fib_array[-2]\n fib_array << fibNum\n i +=1\n end\n return fib_array[number-1]\nend",
"def fib(n)\n # your work here\nend",
"def fibs(num)\n return [] if num == 0\n return [0] if num == 1\n return [0, 1] if num == 2\n\n prev_fibs = fibs(num - 1)\n prev_fibs << prev_fibs[-1] + prev_fibs[-2]\n\n prev_fibs\nend",
"def fibonaci(i)\r\n fib = [0,1]\r\n while fib.length < i \r\n fib << fib[-2] + fib[-1] \r\n end\r\n fib\r\nend",
"def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n\n return fib(n-1) + fib(n-2)\nend",
"def fib(n)\n return [0] if n == 1\n return [0, 1] if n == 2\n return [] if n == 0\n\n previous_fib = fib(n - 1)\n last_fib = previous_fib[-1] + previous_fib[-2]\n previous_fib << last_fib\nend",
"def fib (x)\r\n \t\tinit = [0,1]\r\n \t\tcount = 1\r\n \t\ti = x - 1\r\n \t\tuntil count == i\r\n \t\t\tinit << init[count - 1] + init[count]\r\n \t\t\tcount += 1\r\n \t\tend\r\n \t\tp init\r\n \tend",
"def iter_fib(number)\n v1 = 0\n v2 = 1\n (number-1).times.each do\n temp = v2\n v2 = v2 + v1\n v1 = temp\n end\n v2\nend",
"def fibs(n)\n return [] if n == 0\n return [0] if n == 1\n return [0, 1] if n == 2\n prev_fibs = fibs(n - 1)\n prev_fibs << (prev_fibs[-1] + prev_fibs[-2])\nend",
"def fib(n)\n return [] if n == 0\n return [0] if n == 1\n return [0,1] if n == 2\n \n fibs = fib(n-1)\n fibs << fib(n-1)[-1] + fib(n-1)[-2] \nend",
"def fibs(n)\n # return [] if n == 0\n # return [0] if n == 1\n # return [0, 1] if n == 2\n return [0, 1].take(n) if n <= 2\n\n # fibs(2) #=> [0, 1]\n prev_fibs = fibs(n - 1)\n last_num = (prev_fibs[-1] + prev_fibs[-2])\n prev_fibs << last_num\nend",
"def fibs(n)\n # return [] if n == 0\n # return [0] if n == 1\n # return [0, 1] if n == 2\n return [0, 1].take(n) if n <= 2\n\n # fibs(2) #=> [0, 1]\n prev_fibs = fibs(n - 1)\n last_num = (prev_fibs[-1] + prev_fibs[-2])\n prev_fibs << last_num\nend",
"def fib(n)\n current_value = 0\n next_value = 1\n\n n.times do |i|\n current_value, next_value = next_value, current_value + next_value\n end\n\n return current_value\nend",
"def fibs(n)\n return n if n <= 1\n fibs(n - 1) + fibs(n - 2)\nend",
"def fib(num)\n sequence = [1,2]\n if num < 2\n num\n else\n 0.upto(num) do\n sequence << sequence[-1] + sequence[-2]\n end\n end\n sequence\nend",
"def fibonacci(num)\n fib_nums = []\n (0...num).each do |i|\n if i == 0 || i == 1\n fib_nums << 1\n next\n end\n fib_nums << fib_nums[i-2] + fib_nums[i-1]\n end\n return fib_nums\nend",
"def fib(n)\n return 1 if n == 2\n return 0 if n == 1\n\n fib(n-1) + fib(n-2)\nend",
"def even_fib\n x=[0,1]\n i = 0\n a = []\n\n while x.last < 4000000\n x.push(x[i] + x[i+1])\n i += 1\n end\n\n x.pop\n\n x.each do |blah|\n if blah.even?\n a.push(blah)\n end\n \n end\n\n a.reduce(:+)\n\nend",
"def fibo(n)\n a, b, c = 0, 0, 0\n for i in 1..n\n c, b = b, a\n a = i== 1 ? 1 : b + c\n end\n return a\nend",
"def iterative_nth_fib(n)\n return 1 if n <= 2\n a = 1\n b = 1\n i = 3\n while i <= n\n new_a = b\n b = a + b\n a = new_a\n i += 1\n end\n b\nend",
"def fib(arg)\n\tansw = []\n\tif arg == 0\n\t\tansw << 0\n\telsif arg == 1\n\t\tansw = [0,1]\n\telse\n\t\tansw = [0,1]\n\t\t(arg-1).times do\n\t\t\tansw << answ[-1] + answ[-2]\n\t\tend\n\tend\n\tprint answ\n\tputs \"\"\nend",
"def fibo_finder(n)\n start = [0,1]\n n.times {|i| start[i + 2] = start[i] + start[i + 1]}\n start[n]\nend",
"def fib(int)\n\tarr = Array.new\n\n\tif int > 0\n\t\tarr.push(0)\n\tend\n\n\tif int > 1\n\t\tarr.push(1)\n\tend\n\n\tif int > 2\n\t\ti = 2\n\t\tuntil i == int\n\t\t\tnext_num = arr[i - 2] + arr[i - 1]\n\t\t\tarr.push(next_num)\n\t\t\ti += 1\n\t\tend\t\t\n\tend\n\n\treturn arr\n\nend",
"def fib(n)\n return [] if n < 1\n return [1] if n == 1\n return [1, 1] if n == 2\n\n prev_fib = fib(n - 1)\n num1 = prev_fib[-1]\n num2 = prev_fib[-2]\n prev_fib << num1 + num2\n prev_fib\nend",
"def fib(nth)\n return 1 if nth == 1 || nth == 2\n fib(nth - 2) + fib(nth - 1)\nend",
"def fibs (n) #Non-recursive\n\n\t# n = number of Fibonacci sequence members.\n\t# 0, 1, 1, 2, 3, 5, 8, 13, ..\t\n\tfib_seq = []\n\t(0..n).each do |i|\n\t\tif i == 0\n\t\t\tfib_seq << 0\n\t\telsif i == 1\n\t\t\tfib_seq << 1\n\t\telse\n\t\t\tfib_seq << fib_seq[i-2] + fib_seq[i-1]\n\t\tend\n\tend\n\tfib_seq\nend",
"def fib(n)\n\n fib_seq = [0, 1]\n\n while n > 2\n fib_seq << fib_seq[fib_seq.length - 1] + fib_seq[fib_seq.length - 2]\n n -= 1\n end\n\n return fib_seq\n\nend",
"def fibs(n)\n fib_array = [0, 1]\n\n (2..n).each do |i|\n fib_array << fib_array[i - 1] + fib_array[i - 2]\n end\n fib_array[0..n]\nend",
"def fibonacci(int)\n range_array = (1..int).to_a\n final_array = [1,1]\n range_array.each do |num|\n p num > 2 ? final_array << final_array[num-3] + final_array[num-2] : nil\n end\n final_array[-1]\nend",
"def fibonacci\n @sequence = [1,1]\n x = 0\n while (@sequence[x+1] < 4e+6)\n @sequence << @sequence[x] + @sequence[x+1]\n x += 1\n end\n even? x\nend",
"def fibs(i, f = [])\n for n in 0...i + 1\n n < 2? f << n : f << f[n-1] + f[n-2]\n end\n return f\nend"
] | [
"0.82837903",
"0.8271113",
"0.8182883",
"0.8158846",
"0.8139834",
"0.8118301",
"0.8103211",
"0.8073873",
"0.8012003",
"0.8005307",
"0.79900986",
"0.7981789",
"0.7980134",
"0.7980134",
"0.7980134",
"0.7980134",
"0.7980134",
"0.79609305",
"0.7926039",
"0.792596",
"0.79142034",
"0.79026115",
"0.789456",
"0.78839767",
"0.78835225",
"0.78835225",
"0.78663564",
"0.7863694",
"0.78587824",
"0.785006",
"0.7849523",
"0.78427005",
"0.78401184",
"0.7829081",
"0.7824023",
"0.7820716",
"0.7812288",
"0.780862",
"0.78080505",
"0.78080505",
"0.77935994",
"0.77897394",
"0.7779355",
"0.77665484",
"0.77634585",
"0.7761146",
"0.7757444",
"0.7756193",
"0.7755644",
"0.7749213",
"0.7748812",
"0.7738406",
"0.77366734",
"0.77312577",
"0.7730188",
"0.77271825",
"0.7724734",
"0.7722143",
"0.7715511",
"0.77145374",
"0.7714213",
"0.7712363",
"0.7707633",
"0.7699497",
"0.7698702",
"0.7690073",
"0.7688706",
"0.76847637",
"0.7683904",
"0.76834464",
"0.76815397",
"0.7678979",
"0.76781696",
"0.7673429",
"0.7673187",
"0.7673052",
"0.7671344",
"0.76680875",
"0.7665815",
"0.76648086",
"0.7661946",
"0.7661946",
"0.76596904",
"0.7659596",
"0.7654723",
"0.76543146",
"0.76533175",
"0.7653221",
"0.765194",
"0.7650547",
"0.76414835",
"0.76407707",
"0.7640211",
"0.76399726",
"0.763948",
"0.7637721",
"0.7637568",
"0.7636695",
"0.76343995",
"0.76326",
"0.76300293"
] | 0.0 | -1 |
The maximum slack_before such that there is no collision with (the slack of) another reservation before the begins_at time This value could be negative, indicating that the begins_at value always collides with (the slack of) another reservation | def max_slack_before(begins_at)
previous_reservation = Reservation.new(entity: self, begins_at: begins_at).previous
(begins_at - previous_reservation.ends_at - previous_reservation.slack_after.minutes) / 1.minute if previous_reservation.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_slack_after(ends_at)\n next_reservation = Reservation.new(entity: self, ends_at: ends_at).next\n (next_reservation.begins_at - next_reservation.slack_before.minutes - ends_at) / 1.minute if next_reservation.present?\n end",
"def prev_max() self.scheduling.prev_max end",
"def down_boundary\n Time.new - down_interval\n end",
"def oldest_meaningful_end_time(top_event, max_event)\n\n #if they're the same, then no reason to do complicated math\n if top_event == max_event\n return top_event.end_time\n end\n \n min_ratio = top_event.score.to_f / max_event.score.to_f\n time_between = Math.log(min_ratio, 0.5) * Event::SCORE_HALF_LIFE\n min_end_time = [top_event.end_time - time_between, max_event.end_time.to_f].max\n\n return min_end_time\n end",
"def time\n [self.game_begins, [self.game_ends, Time.now].min].max\n end",
"def expected\n (@terminated_at - @started_at).to_i * @schedule.pill_times.size\n end",
"def findMinimumTimeDiff()\n pre = nil ;\n diff = nil ;\n @timeNameTable.values.sort.each{|time|\n if(pre.nil?) then\n pre = time ;\n else\n d = time - pre ;\n if(diff.nil? || diff > d) then\n diff = d ;\n end\n end\n }\n return diff ;\n end",
"def hurdleRace(k, height)\n if height.max < k\n 0\n else\n height.max - k\n end\nend",
"def start_end_time\n errors[:start_time] << _('errors.invalid_shift_time') if start_time.to_i > end_time.to_i\n end",
"def attempting_times_left\n @times_left ||= begin\n return MAX_ATTEMPTING_TIMES unless question.actable.attempt_limit\n\n times = question.actable.attempt_limit - submission.evaluated_or_graded_answers(question).size\n times = 0 if times < 0\n times\n end\n end",
"def matching_start_time(finish_time)\n start_times.select { |t| t < finish_time }.sort.max\n end",
"def minimum_lead_time\n return @minimum_lead_time\n end",
"def remaining\n return Float::INFINITY if unbounded?\n template.max - seq\n end",
"def calc_locked_out_till\n ends_on.since locked_out_duration\n end",
"def max_minutes_guard(sleep_times)\n minutes_guard = minutes_per_guard(sleep_times)\n guard, _ = minutes_guard.max_by{ |guard, min| min}\n guard\nend",
"def time_survived\n return 0 if self.is_oz\n tag = self.killing_tag\n real_begins = self.game.game_begins - self.game.utc_offset\n return [0, tag.datetime - real_begins].max unless tag.nil?\n return [0, Game.now(self.game) - real_begins].max\n end",
"def max_reserved_time\n @max_reserved_time_s && ( @max_reserved_time_s * 1000.0 ).round\n end",
"def smallest_team\n self.teams.min{|t1,t2| t1.runners.size <=> t2.runners.size }\n end",
"def min_attendance_days\n [1, time_constraint(:min_days)].compact.max\n end",
"def time_left\n return 0.0 if free?\n return end_time - Time.now.to_f\n end",
"def frog_jump(x, a)\n d = {}\n (1..x).each {|i| d[i] = true }\n\n min_time = -1\n len = a.length - 1\n\n (0..len).each do |sec|\n n = a[sec]\n d.delete(n) if d[n]\n if d.length == 0\n min_time = sec\n break\n end\n end\n\n return min_time\nend",
"def time_constraint\n return @time_constraint\n end",
"def continuous_overstay_days\n days = continuous_overstay_days\n days > 90 ? days - 90 : 0\n end",
"def min() time[1] end",
"def guesses_left\n @guesses_allowed - @current_guess_count\n end",
"def remaining\n max - used\n end",
"def minmax_score(board)\n if won?(board)\n if winner(board) == self.token\n 1\n else\n -1\n end\n elsif draw?(board)\n 0\n end\n end",
"def next_closest_time(time)\n store = Array.new(9)\n past = []\n\n time.split('').each do |num| \n if (num.ord >= 48 && num.ord <= 57)\n store[num.to_i] = true \n past.push(num.to_i)\n end\n end\n\n future = past\n place = 3\n until (place == -1)\n limit = find_limit(place, past[place])\n if next_greatest(store, past[place], limit)\n if place == 1 && next_greatest(store, past[place], limit) >= 5 && future[0] == 2\n next_num = next_greatest(store, 0, 2)\n future[0] = next_num\n future[1] = next_num\n else \n future[place] = next_greatest(store, past[place], limit)\n end\n break\n else\n future[place] = lowest(store)\n place -= 1\n end\n end\n\n future[0..1].join(\"\").to_s + \":\" + future[2..3].join(\"\").to_s\nend",
"def calculate_overtime_hours_from(from_time, grouping)\n overtime_hours = (from_time - grouping.due_date) / 1.hour\n # If the overtime is less than 0, that means it was submitted early, so\n # just return 0 - otherwise, return overtime_hours.\n [0, overtime_hours].max\n end",
"def time_required\n @time_required ||= distribution.map(&:sum).max\n end",
"def ending_at_after_starting_at\n return if ending_at.blank? || starting_at.blank? || starting_at <= ending_at\n\n errors.add(:ending_at, s_(\"MetricsDashboardAnnotation|can't be before starting_at time\"))\n end",
"def time_tolerance_seconds\n 600\n end",
"def min\n @min ||= time_parts[1]\n end",
"def time_shift(current_course, target_course)\n shift = target_course.start_at - current_course.start_at\n shift >= 0 ? shift : 0\n end",
"def compute_min_work(base_work, time)\n max_target = Bitcoin.decode_compact_bits(Bitcoin.network[:proof_of_work_limit]).to_i(16)\n\n # Testnet has min-difficulty blocks after nTargetSpacing*2 time between blocks:\n target_spacing = (Bitcoin.network[:retarget_time] / Bitcoin.network[:retarget_interval])\n if is_testnet? && time > target_spacing*2\n return max_target\n end\n\n result = base_work\n while time > 0 && result < max_target\n # Maximum 400% adjustment...\n result *= 4\n # ... in best-case exactly 4-times-normal target time\n time -= Bitcoin.network[:retarget_time]*4\n end\n if result > max_target\n result = max_target\n end\n return result\n end",
"def guesses_left(int, max_guesses)\n max_guesses - int\nend",
"def collision_tollerance\n 0.0\n end",
"def bounded?\n @timestamps[-2] + 2.0 <= video_length\n end",
"def find_guard_with_most_sleep\n @guard_map.max_by { |_k, v| v[:total_sleep] }[0]\n end",
"def longestStreak\n\t\t\t# Set an initial value for the streak\n\t\t\tstreak = 0\n\t\t\t# Set an empty array to hold the streak values\n\t\t\tstreakArray = []\n\t\t\t# Loop through the raw data\n\t\t\t@rawData.each do |day|\n\t\t\t\t# Check if a day is \"prefect\"\n\t\t\t\tif perfectDayChecker day\n\t\t\t\t\tstreak += 1 \t\t\t\t\t\t\t# Add one to the previous streak value\n\t\t\t\t# If the day is not prefect\n\t\t\t\telse\n\t\t\t\t\tstreakArray << streak if streak > 0\t\t# If the previous streak count was not zero\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# That means that there were consecutive perfect days\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# Push the value of the streak in the array\n\t\t\t\t\tstreak = 0\t\t\t\t\t\t\t\t# Reset the streak\n\t\t\t\tend\n\t\t\tend\n\t\t\t# Push in the last value of the streak since the loop ends before adding it.\n\t\t\tstreakArray << streak\n\t\t\tstreakArray.max \t\t\t\t\t\t\t\t# Return the max value in the array\n\t\tend",
"def end_time_after_start_time\n if start_time && end_time && end_time < start_time\n errors.add :end_time, \"must be after the start of shift\"\n errors.add :start_time, \"must be before the end of shift\"\n end\n end",
"def next_clean_time(addr) \n #Figure out side of the street\n side = self.get_side(addr) \n \n #Find all blocks that match Street Address \n all_blocks = self.blocks\n blocks = all_blocks.where(\"side = ? AND bottom <= ? AND top >= ?\", side, addr, addr)\n if blocks == []\n return nil\n else \n #Compute the next cleaning times for the block and pick the smallest(i.e. the soonest) time\n cts = Array.new\n blocks.each{|x|cts << x.ct.next_time}\n best = cts.min\n return best, blocks[0].id\n end\n end",
"def number_of_compatible_time_blocks_with(schedule)\n compatibilities = 0\n \n # does user have a schedule and does <tt>schedule</tt> exist\n if self.schedule != nil and schedule != nil\n self_days = self.schedule.days\n schedule_days = schedule.days\n \n # are there days in each schedule\n if self_days != nil and schedule_days != nil\n self_days.each do |self_day|\n schedule_days.each do |schedule_day|\n if self_day.name == schedule_day.name\n # are there time blocks in each day\n if self_day.time_blocks != nil and schedule_day.time_blocks != nil\n self_day.time_blocks.each do |self_block|\n schedule_day.time_blocks.each do |schedule_block|\n if self_block.chunk_of_time == schedule_block.chunk_of_time\n compatibilities += 1\n end\n end\n end\n end\n end\n end\n end\n end\n end\n \n compatibilities\n end",
"def longest_build_part\n build_parts.max_by { |part| part.elapsed_time || 0 }.elapsed_time\n end",
"def criminal_checks_run_at\n if sex_offender_check_run_at && background_check_run_at\n [sex_offender_check_run_at, background_check_run_at].max\n else\n nil\n end\n end",
"def face_time_blocked\n return @face_time_blocked\n end",
"def time_cannot_be_in_the_past\n time1 = DateTime.now - 300.minutes\n time2 = self.time \n if time1 > time2 \n errors.add(:time, \"can't be in the past \")\n end\n end",
"def spots_left\n return nil if capacity.nil?\n spots_left = capacity - mentor_terms_count\n spots_left < 0 ? 0 : spots_left\n end",
"def tau\n [current_time - last_updated, 1].max\n end",
"def guesses_left()\n \treturn ((@guesses_allowed - @current_guess_count)) \n end",
"def value\n min_stay = [prop_min_stay.to_i, cal_min_stay.to_i].max\n\n min_stay.zero? ? nil : min_stay\n end",
"def offset\n max_range = 2*@wobble + 1\n min_offset = @current.to_i/60 - @actual.to_i/60\n if @current.nil? || min_offset < -@wobble\n range = max_range\n else\n range = @wobble - min_offset + 1\n end\n range = max_range if range > max_range\n\n if range == 0\n new_offset = 0\n else\n if @method == 1\n # pick a new offset within the legal range of offsets.\n new_offset = @wobble - rand(range)\n elsif @method == 2\n # pick a new offset within the range of allowable errors.\n # if it would require the time to regress, don't change the reported time.\n new_offset = @wobble - rand(max_range)\n new_offset = min_offset if new_offset < min_offset\n else\n new_offset = @current_offset + 1 - rand(3)\n new_offset = @wobble if new_offset > @wobble\n new_offset = -@wobble if new_offset < -@wobble\n new_offset = min_offset if new_offset < min_offset\n end\n end\n return 60 * new_offset\n end",
"def min_meeting_rooms(intervals)\n s, e = [], []\n intervals.each do |i|\n s << i.start\n e << i.end\n end\n s.sort!\n e.sort!\n i = j = 0\n x = ans = 0\n while i < intervals.size\n if s[i] < e[j]\n x += 1\n ans = [ans, x].max\n i += 1\n else\n x -= 1\n j += 1\n end\n end\n ans\nend",
"def effective_start_at\n start_at - course&.advance_start_at_duration\n end",
"def shortest_time_remaining\n return 0 if finished_at\n backup_source_jobs.map(&:time_remaining).reject! {|t| t == 0}.min rescue 0\n end",
"def get_gravity(hour_time_range, previous_sets_to_compare)\n t_score = self.get_t_score(hour_time_range, previous_sets_to_compare)\n current_c = Word.where(\"name = ? and story_date > ?\", self.name, Time.now-24.hours).count\n if current_c > 3\n return t_score\n else\n return 0\n end\n end",
"def max_time\n @max_time ||= 0.2\n end",
"def biggest_bust(season)\n season = season.to_i\n @teams.min_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end",
"def validate_time_blocks(time_blocks)\n b = time_blocks.select(&:collision_free?)\n\n # Test environment has unreliable data entry for start times.\n b = b.select(&:in_future?) unless Rails.env.test?\n\n b\n end",
"def guesses_left\n @guesses_left = @guesses_allowed - @current_guess_count\n end",
"def lowest_fit(shape, x)\n (@board.num_rows-1).downto(0).each do |y|\n if leads_up?([x,y], fits?(shape), 5) #prevent the program from teleporting shapes to impossible positions\n then return y\n end\n end\n 0\n end",
"def before_midnight(time)\n total_minutes = after_midnight(time)\n total_minutes == 0 ? 0 : 1440 - total_minutes\nend",
"def minmax_position(passes)\n # It's somewhere in the positions\n all_positions = positions(passes)\n\n # between the minimum and maximum seat\n min_pos, max_pos = all_positions.minmax\n\n # So we just eliminate any seat that's taken. Whatever is left over\n # is ours\n (min_pos..max_pos).to_a - all_positions\nend",
"def time_limit\n [2, problem.time_limit].min\n end",
"def cutoff\n Time.now - (60 * 60 * HOURS)\n end",
"def find_failed_temporal_constraint(time)\n each_backward_temporal_constraint do |parent|\n next if block_given? && !yield(parent)\n\n disjoint_set = parent[self, TemporalConstraints]\n next if disjoint_set.intervals.empty?\n\n if disjoint_set.boundaries[0] < 0\n # It might be fullfilled in the future\n next\n end\n\n max_diff = disjoint_set.boundaries[1]\n parent.history.each do |parent_event|\n diff = time - parent_event.time\n if diff > max_diff || !disjoint_set.include?(diff)\n return parent, disjoint_set\n end\n\n disjoint_set.include?(diff)\n end\n end\n nil\n end",
"def dyhead_max\n return @dyhead_max if @dyhead_max\n\n yheads = @camera.rectangle.map { |h| h[1] }\n yhead_min = (yheads.sort)[0]\n @dyhead_max = (@camera.position[1] - yhead_min)\n end",
"def max_lead_time\n self.standing_line_items.includes(:variant).map{|li| li.variant.lead_time}.max || 0\n end",
"def restriction\r\n states.collect {|state| state.restriction }.push(0).max\r\n end",
"def effective_ending_on_gt_effective_starting_on\n\n return if effective_ending_on.nil?\n return if effective_starting_on.nil?\n\n if effective_ending_on < effective_starting_on\n self.errors.add(:base, \"The effective end date should be earlier or equal to effective start date\")\n end\n end",
"def is_correct_time? #:doc:\n if(self.endTime && self.startTime && (self.endTime<=>self.startTime)==-1)\n errors.add([:starTime,:endTime],\"Attenzione l'ora di inizio è piu grande dell'ora di fine\")\n end\n end",
"def most_likely_asleep(sleep_times, guard)\n minutes_hash = most_asleep_minutes_for(sleep_times, guard)\n time, num_times = minutes_hash.max_by { |min, times| times}\nend",
"def before( time )\n\t\treturn time - self\n\tend",
"def before( time )\n\t\treturn time - self\n\tend",
"def slot_time\n 0\n end",
"def min_out\n @min_out ||= time_out.min\n end",
"def min_sets_to_play\n max = max_sets_to_play\n raise Exceptions::ApplicationError, 'Unexpected game count' if max.even?\n (max + 1) / 2\n end",
"def last_defined_frame\n last_f = @segments[-1].start_frame\n return 100 if last_f == POS_INF\n return last_f\n end",
"def place\n if !self.start_time\n self.move(self.start_bound)\n self.save\n end\n conflicts = users_events.select{|e| e.start_time < self.end_bound && e.end_time > self.start_bound}.sort{|a,b| a.start_time <=> b.start_time}\n conflicts -= [self]\n if conflicts.empty?\n return move(self.start_bound)\n end\n if to_min(conflicts.first.start_time) - to_min(self.start_bound) >= to_min(self.duration)\n return move(self.start_bound)\n end\n\n (0...conflicts.length).each do |i|\n if i != conflicts.length - 1\n if to_min(conflicts[i+1].start_time) - to_min(conflicts[i].end_time) >= to_min(self.duration)\n return move(conflicts[i].end_time)\n end\n else\n if to_min(self.end_bound) - to_min(conflicts[i].end_time) >= to_min(self.duration)\n return move(conflicts[i].end_time)\n end\n end\n end\n return move(self.start_bound)\n end",
"def compute_best_distance sec\n min_improper,sec_improper=(min_proper,sec_proper=sec.divmod(60))\n if min_improper>0 and sec_improper<40\n min_improper-=1\n sec_improper+=60\n else\n #the improper time will be the same as the proper time, which\n #isn't a problem\n end\n proper=make_array(min_proper,sec_proper)\n improper=make_array(min_improper,sec_improper)\n [[\n compute_dist(proper,Primary),\n compute_dist(proper,Tiebreaker),\n proper\n ],[\n compute_dist(improper,Primary),\n compute_dist(improper,Tiebreaker),\n improper\n ]].sort[0][-1].join\nend",
"def get_time_required\n 0 # number of minutes\n end",
"def validate_negative_times\n return true if (time_type != \"penalty\" && time_type != \"gift_given\") || start.nil? || finish.nil?\n if r = start <= finish\n errors.add(:start, \"must come after finish, for penalties\")\n end\n r\n end",
"def time_left\n end_time = created_at + test.time_for_test\n time_left_seconds = end_time - Time.now\n \n return 0 if time_left_seconds < 0\n\n time_left_seconds.round\n end",
"def unavailable_threshold\n if organization.has_monitor_params?\n organization.monitor_param.unavailable_threshold.minutes\n else\n 3.minutes\n end\n end",
"def max_score\n return score if @state != STATE_OK\n\n next_boards.map(&:min_score).min\n end",
"def max_win_points_validation\n if play_condition.win_points.blank?\n self.errors.add(:base, \"Количество очков за победу должно быть больше 0\")\n elsif play_condition.difficulty_level.present? && play_condition.difficulty_level.difficulty_level_setting.send(\"#{self.class.to_s.underscore}_max_win_points\").to_f < play_condition.win_points.to_f\n self.errors.add(:base, \"Количество очков за победу должно быть не больше #{play_condition.difficulty_level.difficulty_level_setting.send(\"#{self.class.to_s.underscore}_max_win_points\")}\")\n elsif play_condition.win_points.to_f <= play_condition.participation_points.to_f\n self.errors.add(:base, \"Количество очков за победу должно быть больше, чем количество очков за участие.\")\n end\n end",
"def random_spawn_countdown minimum\n 10.randomize(:ratio, :sign).to_i + 60\n end",
"def minimum_rounds(teams_count)\n Math.log2(teams_count).ceil\n end",
"def before(time)\n time - self\n end",
"def has_left\n super || time_left_at&.past?\n end",
"def find_max_hop_times!(hop_times, type, divider)\n raise ArgumentError.new(\n \"Divider for #{type} must be >= 1, but #{divider} was given!\"\n ) if divider < 1\n\n type = type.underscore\n [:solar_system, :galaxy].each do |space|\n hop_time = CONFIG.evalproperty(\"units.#{type}.move.#{space}.hop_time\")\n raise \"CONFIG[units.#{type}.move.#{space}.hop_time] is nil!\" \\\n if hop_time.nil?\n hop_time = (hop_time.to_f / divider).round\n hop_times[space] = hop_time if hop_time > hop_times[space]\n end\n end",
"def before(time = ::Time.now)\n time - self\n end",
"def past?\n begins.to_time < Time.now\n end",
"def get_upper_limit_of(range)\n range.max\nend",
"def time_until_hungry\n time_since_recent_action = if time_since_last_burrito < time_since_active\n time_since_last_burrito\n else\n time_since_active\n end\n\n x = greedy_time - time_since_recent_action.to_i\n x > 0 ? x : 0\n end",
"def minimum_lead_time=(value)\n @minimum_lead_time = value\n end",
"def set_max_min_times(movie_time)\n\n if self.min_time.nil? || (self.min_time > movie_time[0].time)\n self.min_time = movie_time[0].time\n end\n\n if self.max_time.nil? || (self.max_time < movie_time[-1].time)\n self.max_time = movie_time[-1].time + \n movie_time[-1].duration.minutes + TIME_BUF.minutes\n end\n\n\n end",
"def last_possible_defense_semester\n study_length * 2\n end",
"def guesses_left(current_guess_count)\n\t3 - current_guess_count\nend",
"def display_time_at\n gm = self.good_memories.count\n bm = self.bad_memories.count\n lifespan = (Time.now.to_i - self.created_at.to_i)\n unless gm == 0\n shift = (lifespan * (bm + 1)) / gm\n return (Time.now.to_i - shift)\n else\n shift = lifespan * (bm + 1)\n return (Time.now.to_i - shift)\n end\n end"
] | [
"0.6944257",
"0.5714198",
"0.5533224",
"0.5465341",
"0.5334713",
"0.530633",
"0.5301486",
"0.52935106",
"0.5217383",
"0.5196414",
"0.5178257",
"0.51396817",
"0.51160175",
"0.5105772",
"0.5103186",
"0.50833255",
"0.5077038",
"0.50707185",
"0.506407",
"0.50526756",
"0.5044178",
"0.5038766",
"0.5032725",
"0.5013259",
"0.5007378",
"0.5006826",
"0.49788165",
"0.49785122",
"0.49665126",
"0.49615586",
"0.4949762",
"0.4945338",
"0.49398622",
"0.4934353",
"0.49308214",
"0.49246374",
"0.49204367",
"0.4917136",
"0.49075016",
"0.48933807",
"0.48846254",
"0.48803475",
"0.48669675",
"0.48668927",
"0.486332",
"0.4850918",
"0.48496577",
"0.4847857",
"0.48394114",
"0.48355412",
"0.48345622",
"0.48298946",
"0.48286232",
"0.48266754",
"0.48237145",
"0.4823584",
"0.48208794",
"0.48192373",
"0.48172945",
"0.48095",
"0.48032832",
"0.4798217",
"0.479012",
"0.4775547",
"0.47726175",
"0.47685567",
"0.4759326",
"0.4751785",
"0.47500518",
"0.47496077",
"0.47446683",
"0.47412",
"0.47403607",
"0.47403607",
"0.4739106",
"0.47384742",
"0.47333786",
"0.47332588",
"0.4733178",
"0.47311342",
"0.4727322",
"0.4724436",
"0.47240263",
"0.47187963",
"0.47138768",
"0.471206",
"0.47095343",
"0.47072867",
"0.4703741",
"0.47033942",
"0.4688061",
"0.46867102",
"0.46863994",
"0.46846735",
"0.46786368",
"0.46780512",
"0.4671649",
"0.46684265",
"0.46662602",
"0.4663386"
] | 0.79211324 | 0 |
The maximum slack_after such that there is no collision with (the slack of) another reservation after the ends_at time This value could be negative, indicating that the ends_at value always collides with (the slack of) another reservation | def max_slack_after(ends_at)
next_reservation = Reservation.new(entity: self, ends_at: ends_at).next
(next_reservation.begins_at - next_reservation.slack_before.minutes - ends_at) / 1.minute if next_reservation.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_slack_before(begins_at)\n previous_reservation = Reservation.new(entity: self, begins_at: begins_at).previous\n (begins_at - previous_reservation.ends_at - previous_reservation.slack_after.minutes) / 1.minute if previous_reservation.present?\n end",
"def down_boundary\n Time.new - down_interval\n end",
"def calc_locked_out_till\n ends_on.since locked_out_duration\n end",
"def max_reserved_time\n @max_reserved_time_s && ( @max_reserved_time_s * 1000.0 ).round\n end",
"def max_minutes_guard(sleep_times)\n minutes_guard = minutes_per_guard(sleep_times)\n guard, _ = minutes_guard.max_by{ |guard, min| min}\n guard\nend",
"def max_time\n @max_time ||= 0.2\n end",
"def oldest_meaningful_end_time(top_event, max_event)\n\n #if they're the same, then no reason to do complicated math\n if top_event == max_event\n return top_event.end_time\n end\n \n min_ratio = top_event.score.to_f / max_event.score.to_f\n time_between = Math.log(min_ratio, 0.5) * Event::SCORE_HALF_LIFE\n min_end_time = [top_event.end_time - time_between, max_event.end_time.to_f].max\n\n return min_end_time\n end",
"def prev_max() self.scheduling.prev_max end",
"def time\n [self.game_begins, [self.game_ends, Time.now].min].max\n end",
"def hurdleRace(k, height)\n if height.max < k\n 0\n else\n height.max - k\n end\nend",
"def max_time\n @max_time ||= defaults[:max_time]\n end",
"def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end",
"def max_usage_time(current_time, max_usage)\n statuses = Reservation.statuses\n start_time = (current_time.to_time - max_usage.hours).to_datetime\n active_reservations = equipment.reservations\n .where('start_time >= ? AND start_time < ?', start_time, current_time)\n .where('status = ?', statuses[:confirmed])\n used_time = active_reservations.sum { |res| ((res.end_time - res.start_time) / 3600) }\n used_time\n end",
"def schedule_to_close_timeout; Float::INFINITY; end",
"def matching_start_time(finish_time)\n start_times.select { |t| t < finish_time }.sort.max\n end",
"def most_likely_asleep(sleep_times, guard)\n minutes_hash = most_asleep_minutes_for(sleep_times, guard)\n time, num_times = minutes_hash.max_by { |min, times| times}\nend",
"def find_guard_with_most_sleep\n @guard_map.max_by { |_k, v| v[:total_sleep] }[0]\n end",
"def max_interval\n MAX_INTERVAL\n end",
"def end_time_after_start_time\n if start_time && end_time && end_time < start_time\n errors.add :end_time, \"must be after the start of shift\"\n errors.add :start_time, \"must be before the end of shift\"\n end\n end",
"def remaining\n return Float::INFINITY if unbounded?\n template.max - seq\n end",
"def effective_end_time\n if start_time.nil?\n accommodated_end_time\n else\n [start_time + accommodated_duration, accommodated_end_time].min\n end\n end",
"def bounded?\n @timestamps[-2] + 2.0 <= video_length\n end",
"def remaining\n max - used\n end",
"def time_required\n @time_required ||= distribution.map(&:sum).max\n end",
"def longestStreak\n\t\t\t# Set an initial value for the streak\n\t\t\tstreak = 0\n\t\t\t# Set an empty array to hold the streak values\n\t\t\tstreakArray = []\n\t\t\t# Loop through the raw data\n\t\t\t@rawData.each do |day|\n\t\t\t\t# Check if a day is \"prefect\"\n\t\t\t\tif perfectDayChecker day\n\t\t\t\t\tstreak += 1 \t\t\t\t\t\t\t# Add one to the previous streak value\n\t\t\t\t# If the day is not prefect\n\t\t\t\telse\n\t\t\t\t\tstreakArray << streak if streak > 0\t\t# If the previous streak count was not zero\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# That means that there were consecutive perfect days\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# Push the value of the streak in the array\n\t\t\t\t\tstreak = 0\t\t\t\t\t\t\t\t# Reset the streak\n\t\t\t\tend\n\t\t\tend\n\t\t\t# Push in the last value of the streak since the loop ends before adding it.\n\t\t\tstreakArray << streak\n\t\t\tstreakArray.max \t\t\t\t\t\t\t\t# Return the max value in the array\n\t\tend",
"def get_upper_limit_of(range)\n range.max\nend",
"def last_possible_defense_semester\n study_length * 2\n end",
"def ending_at_after_starting_at\n return if ending_at.blank? || starting_at.blank? || starting_at <= ending_at\n\n errors.add(:ending_at, s_(\"MetricsDashboardAnnotation|can't be before starting_at time\"))\n end",
"def time_survived\n return 0 if self.is_oz\n tag = self.killing_tag\n real_begins = self.game.game_begins - self.game.utc_offset\n return [0, tag.datetime - real_begins].max unless tag.nil?\n return [0, Game.now(self.game) - real_begins].max\n end",
"def get_upper_limit_of(range)\n range.max\nend",
"def max_lead_time\n self.standing_line_items.includes(:variant).map{|li| li.variant.lead_time}.max || 0\n end",
"def tau\n [current_time - last_updated, 1].max\n end",
"def expected\n (@terminated_at - @started_at).to_i * @schedule.pill_times.size\n end",
"def continuous_overstay_days\n days = continuous_overstay_days\n days > 90 ? days - 90 : 0\n end",
"def time_cannot_be_in_the_past\n time1 = DateTime.now - 300.minutes\n time2 = self.time \n if time1 > time2 \n errors.add(:time, \"can't be in the past \")\n end\n end",
"def longest_build_part\n build_parts.max_by { |part| part.elapsed_time || 0 }.elapsed_time\n end",
"def time_tolerance_seconds\n 600\n end",
"def max_twist_angle\n MSPhysics::Newton::BallAndSocket.get_max_twist_angle(@address)\n end",
"def get_upper_limit_of(range)\n range.last\nend",
"def attempting_times_left\n @times_left ||= begin\n return MAX_ATTEMPTING_TIMES unless question.actable.attempt_limit\n\n times = question.actable.attempt_limit - submission.evaluated_or_graded_answers(question).size\n times = 0 if times < 0\n times\n end\n end",
"def criminal_checks_run_at\n if sex_offender_check_run_at && background_check_run_at\n [sex_offender_check_run_at, background_check_run_at].max\n else\n nil\n end\n end",
"def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end",
"def validate_negative_times\n return true if (time_type != \"penalty\" && time_type != \"gift_given\") || start.nil? || finish.nil?\n if r = start <= finish\n errors.add(:start, \"must come after finish, for penalties\")\n end\n r\n end",
"def next_closest_time(time)\n store = Array.new(9)\n past = []\n\n time.split('').each do |num| \n if (num.ord >= 48 && num.ord <= 57)\n store[num.to_i] = true \n past.push(num.to_i)\n end\n end\n\n future = past\n place = 3\n until (place == -1)\n limit = find_limit(place, past[place])\n if next_greatest(store, past[place], limit)\n if place == 1 && next_greatest(store, past[place], limit) >= 5 && future[0] == 2\n next_num = next_greatest(store, 0, 2)\n future[0] = next_num\n future[1] = next_num\n else \n future[place] = next_greatest(store, past[place], limit)\n end\n break\n else\n future[place] = lowest(store)\n place -= 1\n end\n end\n\n future[0..1].join(\"\").to_s + \":\" + future[2..3].join(\"\").to_s\nend",
"def latest_interview_timeblock_end\n interview_timeblocks.find(:first, :order => 'end_time DESC').end_time\n end",
"def most_free_time(arr)\n free_times = []\n arr = arr.map do |event|\n start_time, end_time = event.split('-')\n [time_to_minutes(start_time), time_to_minutes(end_time)]\n end.sort\n 1.upto(arr.size - 1) do |idx|\n free_times << arr[idx].first - arr[idx -1].last\n end\n most = free_times.max\n hours, mins = most.divmod(60)\n \"#{format('%02d', hours)}:#{format('%02d', mins)}\"\nend",
"def check_max_exits\n max = ts_max_exits || 1\n\n if max_destinations_for_time_segment < max\n errors.add(:max_destinations_for_time_segment, \"must be greater than or equal to #{max}, the maximum number of destinations on an already existing time segment\")\n end\n end",
"def dyhead_max\n return @dyhead_max if @dyhead_max\n\n yheads = @camera.rectangle.map { |h| h[1] }\n yhead_min = (yheads.sort)[0]\n @dyhead_max = (@camera.position[1] - yhead_min)\n end",
"def effective_maximum\n maximum_bound ? maximum_bound.value : Infinity\n end",
"def find_failed_temporal_constraint(time)\n each_backward_temporal_constraint do |parent|\n next if block_given? && !yield(parent)\n\n disjoint_set = parent[self, TemporalConstraints]\n next if disjoint_set.intervals.empty?\n\n if disjoint_set.boundaries[0] < 0\n # It might be fullfilled in the future\n next\n end\n\n max_diff = disjoint_set.boundaries[1]\n parent.history.each do |parent_event|\n diff = time - parent_event.time\n if diff > max_diff || !disjoint_set.include?(diff)\n return parent, disjoint_set\n end\n\n disjoint_set.include?(diff)\n end\n end\n nil\n end",
"def max_wait_time\n @data[\"max_wait_time\"]\n end",
"def time_left\n return 0.0 if free?\n return end_time - Time.now.to_f\n end",
"def <=>(ov)\n return @vector.values.max <=> ov.get_max_clock\n end",
"def max_run_time\n 96.hours\n end",
"def max(board)\n #Generate moves array\n moves = minmax_moves(board, self)\n #Placeholder for max score, even the worst score is > -2\n max = -2\n #Find terminal and check terminal nodes and delete them from move array. If any of them are 1 instantly return\n moves.delete_if do |index, board|\n if over?(board)\n #If board is terminal get score\n res = minmax_score(board)\n #If terminal is winning instantly return it\n return res if res == 1\n max = res if res > max\n true\n else\n false\n end\n end\n\n #Else get worst scores of new states\n moves.each do |index, board|\n res = min(board)\n return res if res == 1\n max = res if res > max\n end\n max\n end",
"def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end",
"def last_possible_exam_semester\n study_length * 2 - 2\n end",
"def time_until_hungry\n time_since_recent_action = if time_since_last_burrito < time_since_active\n time_since_last_burrito\n else\n time_since_active\n end\n\n x = greedy_time - time_since_recent_action.to_i\n x > 0 ? x : 0\n end",
"def finished_at\n build_attempts.maximum(:finished_at)\n end",
"def calculate_overtime_hours_from(from_time, grouping)\n overtime_hours = (from_time - grouping.due_date) / 1.hour\n # If the overtime is less than 0, that means it was submitted early, so\n # just return 0 - otherwise, return overtime_hours.\n [0, overtime_hours].max\n end",
"def run_end_time\n end_times =\n @data['controls'].map do |control|\n control['results'].map { |result| end_time(result['start_time'], result['run_time']) }\n end\n\n end_times.flatten.max\n end",
"def maximum_outbound_jitter\n return @maximum_outbound_jitter\n end",
"def deltas_max_index\n abs_deltas.index(abs_deltas.max)\n end",
"def max_exit_date\n local_range.end\n end",
"def soloMax(unknown)\n\t\t#vf^2 = vo^2 + 2a/\\y | 0 = vo^2 + 2a/\\y | vo = sqrt(-2a/\\y)\n\t\tcase unknown\n\t\twhen :voy\n\t\t\t(2 * -vars[:ay] * (vars[:ymax] - vars[:yo]))**(1.0/2)\n\t\twhen :ymax\n\t\t\tvars[:yo] + ((-1.0 * vars[:voy]**2) / (2 * vars[:ay]))\n\t\twhen :yo\n\t\t\tvars[:ymax] - ((-1.0 * vars[:voy]**2) / (2 * vars[:ay]))\n\t\tend\n\tend",
"def end_time_check\n if self.event_type == \"Script\" || self.event_type == \"Gamecall\"\n if end_time > start_time\n self.end_time = start_time\n end\n end\n end",
"def find_max_hop_times!(hop_times, type, divider)\n raise ArgumentError.new(\n \"Divider for #{type} must be >= 1, but #{divider} was given!\"\n ) if divider < 1\n\n type = type.underscore\n [:solar_system, :galaxy].each do |space|\n hop_time = CONFIG.evalproperty(\"units.#{type}.move.#{space}.hop_time\")\n raise \"CONFIG[units.#{type}.move.#{space}.hop_time] is nil!\" \\\n if hop_time.nil?\n hop_time = (hop_time.to_f / divider).round\n hop_times[space] = hop_time if hop_time > hop_times[space]\n end\n end",
"def max_angular_velocity; end",
"def error_bound\n return nil unless @worst_possible_phase_error && @worst_possible_freq_error && @last_measure\n\n elapsed = @clock.time - @last_measure.local_time\n\n # the last known phase offset\n # the last known phase offset error\n # the last known frequency error\n # time since the last frequency measurement\n # clock variability assumption\n\n elapsed * @worst_possible_freq_error / $REFERENCE_FREQ + @worst_possible_phase_error\n end",
"def time_limit\n [2, problem.time_limit].min\n end",
"def time_constraint\n return @time_constraint\n end",
"def night_length night_timelimit\n case day_timelimit\n when 1\n return \"336 hours (2 weeks)\"\n when 2\n return \"168 hours (1 week)\"\n when 3\n return \"120 hours (5 days)\"\n when 4\n return \"72 hours (3 days)\"\n when 5\n return \"48 hours (2 days)\"\n when 6\n return \"24 hours (1 day)\"\n when 7\n return \"12 hours\"\n when 8\n return \"6 hours\"\n when 9\n return \"3 hours\"\n when 10\n return \"2 hours\"\n when 11\n return \"1 hour\"\n when 12\n return \"30 minutes\"\n when 13\n return \"15 minutes\"\n when 14\n return \"10 minutes\"\n when 15\n return \"5 minutes\"\n else\n return \"Error\"\n end\n end",
"def max\n @range.end\n end",
"def room_has_maxhold\n return @maxhold\nend",
"def busiest_time(doordata)\n pop_cnt = 0\n max_pop = 0\n res = 0\n \n doordata.each_with_index do |e, i| \n \n if e.last == 0 \n pop_cnt -= e[1]\n elsif e.last == 1 \n pop_cnt += e[1] \n end \n \n # need to check all values at a given time stamp \n # before making the comparison with max_pop\n next if i < doordata.length-1 && e[0] == doordata[i+1][0]\n \n if pop_cnt > max_pop \n res = e.first\n max_pop = pop_cnt\n end \n end \n \n res \nend",
"def schengen_overstay_days\n return nil unless schengen_days\n days = schengen_days\n days > 90 ? days - 90 : 0\n end",
"def get_upper_limit_of(range)\n range.end\nend",
"def time_after_now? time\n time_now_with_resetted_date = reset_date_for_time_now\n time_with_resetted_date = reset_date_for_time time\n (time_now_with_resetted_date <=> time_with_resetted_date) == Timeable::TIME_COMPARE_RESULTS[:left_side_later]\n end",
"def cutoff\n Time.now - (60 * 60 * HOURS)\n end",
"def finish_in \n if valid?\n #raise CustomError::InvalidBar unless valid?\n remaining_time = (current_at.to_f - start_at.to_f)*(max.to_f/current.to_f - 1.0) if current.to_i > 0\n remaining_time ? distance_of_time_in_words(remaining_time) : \"non disponibile\" \n end\n end",
"def max_speed\r\n if @pitches.size > 0\r\n return (@pitches.max {|a,b| a.start_speed.to_f <=> b.start_speed.to_f }).start_speed\r\n end\r\n return 0\r\n end",
"def unavailable_threshold\n if organization.has_monitor_params?\n organization.monitor_param.unavailable_threshold.minutes\n else\n 3.minutes\n end\n end",
"def max_teams(rounds)\n 2**rounds\n end",
"def max_teams(rounds)\n 2**rounds\n end",
"def collision_tollerance\n 0.0\n end",
"def max_talk_time_length\n 240\n end",
"def hours_left\n remaining = WorkingTime::Interval.new(self, close_of_business)\n return remaining.duration\n end",
"def min_out\n @min_out ||= time_out.min\n end",
"def late_nights\n blocks.count(&:over_midnight?)\n end",
"def get_max_length(x)\n x % 2 == 0 ? y = 180 : y = 240\n end",
"def maximum_of_two_players\n # TODO implement\n end",
"def collision_ceiling!\n return unless state.dy > 0 # return unless player is moving up\n player_rect = [state.x, state.y + 0.1, state.tile_size, state.tile_size]\n\n # Goes through world_collision_rects to find intersections between the bottom of a\n # world_collision_rect and the top of the player's rect (hence the \"+0.1\" above)\n ceil_collisions = state.world_collision_rects\n .find_all { |r| r[:bottom].intersect_rect?(player_rect, collision_tollerance) }\n .first\n\n return unless ceil_collisions # return unless collision occurred\n\n # player's y is set to the bottom y of the rect it collided with, minus the size of a rect\n state.y = ceil_collisions[:bottom].y - state.tile_size\n state.dy = 0 # if a collision occurred, the player isn't moving up because its path is blocked\n end",
"def is_correct_time? #:doc:\n if(self.endTime && self.startTime && (self.endTime<=>self.startTime)==-1)\n errors.add([:starTime,:endTime],\"Attenzione l'ora di inizio è piu grande dell'ora di fine\")\n end\n end",
"def high_score\n if self.end_date < Date.today\n self.teams.max_by { |team| team.score }.score\n end\n end",
"def validate_time_blocks(time_blocks)\n b = time_blocks.select(&:collision_free?)\n\n # Test environment has unreliable data entry for start times.\n b = b.select(&:in_future?) unless Rails.env.test?\n\n b\n end",
"def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end",
"def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end",
"def after?(other)\n self.hsec > other.hsec\n end",
"def add_max_time(current_string)\n add_if_present(@max_time, current_string, \" -max-time #{@max_time} \")\n end",
"def ts_max_exits\n TimeSegment\n .select(\"ts.id as ts_id, count(rd.exit_id) as ts_count\")\n .from(\"web_time_segments as ts\")\n .joins(\"INNER JOIN web_routings as r ON ts.id = r.time_segment_id\")\n .joins(\"INNER JOIN web_routing_destinations as rd ON r.id = rd.routing_id\")\n .where(\"ts.app_id = ?\", app_id)\n .group(\"ts.id\").map(&:ts_count).max\n end"
] | [
"0.677644",
"0.5843807",
"0.57572776",
"0.5753104",
"0.57078505",
"0.56829065",
"0.5681175",
"0.5587056",
"0.541402",
"0.5399369",
"0.5351964",
"0.5346725",
"0.53122896",
"0.5284753",
"0.5260341",
"0.52282315",
"0.5228178",
"0.5179661",
"0.51731735",
"0.51653385",
"0.51583165",
"0.5151938",
"0.5136724",
"0.5123238",
"0.51015776",
"0.5098069",
"0.50838894",
"0.5083331",
"0.50742614",
"0.5069664",
"0.5066963",
"0.5066699",
"0.5063253",
"0.5056417",
"0.5053364",
"0.5051323",
"0.5039058",
"0.5027955",
"0.5012486",
"0.49903122",
"0.49900052",
"0.49868283",
"0.49813703",
"0.49755442",
"0.49728823",
"0.4971157",
"0.49584398",
"0.4946577",
"0.4945597",
"0.49455133",
"0.49425745",
"0.49390167",
"0.4935218",
"0.49259844",
"0.4920473",
"0.49084115",
"0.49040008",
"0.49015775",
"0.4900258",
"0.4896998",
"0.48949227",
"0.48912653",
"0.48868567",
"0.48794505",
"0.48758695",
"0.4872817",
"0.48661014",
"0.48627162",
"0.48617208",
"0.4855116",
"0.48459744",
"0.48425466",
"0.4840913",
"0.4840651",
"0.4837105",
"0.4835986",
"0.48354638",
"0.48308608",
"0.48256662",
"0.48247963",
"0.4823301",
"0.48232913",
"0.48090366",
"0.48090366",
"0.48033565",
"0.47939762",
"0.47914663",
"0.4785767",
"0.47836852",
"0.4777472",
"0.47768992",
"0.47729766",
"0.4772221",
"0.47722057",
"0.47721064",
"0.4770345",
"0.47696584",
"0.47692338",
"0.47676775",
"0.4766569"
] | 0.7936712 | 0 |
Set property values by an list/array (matching array index on property index) or hash (matching hash key on property name or index depending on key type) | def set_properties(*values)
if values.size == 1 && values.first.is_a?(Hash)
# We are dealing with a hash
values.first.each do |key, index|
self.set_property(key, value)
end
else
# We are dealing with a list/array
values.flatten.each_with_index do |value, index|
self.set_property(index, value)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def []=(property, value); end",
"def []=(key, value)\n k = key.to_s\n if value.nil?\n remove_property(k)\n elsif (Array === value)\n case value[0]\n when NilClass\n set_property(k, [].to_java(:string))\n when String\n set_property(k, value.to_java(:string))\n when Float\n set_property(k, value.to_java(:double))\n when FalseClass, TrueClass\n set_property(k, value.to_java(:boolean))\n when Fixnum\n set_property(k, value.to_java(:long))\n else\n raise \"Not allowed to store array with value #{value[0]} type #{value[0].class}\"\n end\n else\n set_property(k, value)\n end\n end",
"def []=(key, value)\n raise \"Not valid OrientDB Property value #{value.class}, valid: #{VALID_PROPERTY_VALUE_CLASSES.to_a.join(', ')}\" unless valid_property?(value)\n \n k = key.to_s\n if value.nil?\n remove_property(k)\n elsif (Array === value)\n case value[0]\n when NilClass\n set_property(k, [].to_java(:string))\n when String\n set_property(k, value.to_java(:string))\n when Float\n set_property(k, value.to_java(:double))\n when FalseClass, TrueClass\n set_property(k, value.to_java(:boolean))\n when Fixnum\n set_property(k, value.to_java(:long))\n else\n raise \"Not allowed to store array with value #{value[0]} type #{value[0].class}\"\n end\n else\n set_property(k, value)\n end\n end",
"def set(params)\n params.each do |param, value|\n @property_hash[param.intern] = value\n end\n end",
"def set_property_at_index(propertyIndex,value,exception = nil)\n value = JS::Value.from_ruby(context,value)\n res = super(context,self,propertyIndex,value,exception)\n return res\n end",
"def set(index, val)\n \n end",
"def set_property_at_index(ctx,object,propertyIndex,value,exception)\n JS::Lib.JSObjectSetPropertyAtIndex(ctx,object,propertyIndex,value,exception)\n end",
"def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end",
"def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end",
"def []=(*key_list, value)\n store_with_init(Array(key_list).flatten, value)\n end",
"def update_field_property(source, property, fields=Hamster::Set[])\n field = source[property]\n # collect previous fields if present\n field.each do |value|\n # add previous fields\n fields = fields.add(value)\n end unless field.nil?\n # reassign fields\n source[property] = fields.to_a\n source\n end",
"def set_property(tokens, value)\n property_owner_token = tokens.shift\n\n property_owner = get_property_owner property_owner_token\n\n validate_type [String, SdArray], property_owner\n\n case property_owner\n when String then set_string_property property_owner, tokens.shift, value\n when SdArray then set_array_property property_owner, tokens.shift, value\n end\n\n if property_owner_token.sub_type == Token::VAR_ARE\n @are = property_owner\n elsif property_owner_token.sub_type == Token::VARIABLE\n @current_scope.set_variable property_owner_token.content, property_owner\n end\n end",
"def set_property(key, value)\n end",
"def []=(index, value)\n\t\t@field[1][index] = value\n\tend",
"def set_value(owner, value)\n values = value.to_s.split(/ +/)\n \n @properties.each_index do |index|\n break if index > values.length-1\n subproperties = @properties[index]\n\n subproperties.each do |subproperty|\n owner.set_property_value(subproperty, values[index])\n end\n end\n end",
"def lset(key, index, value); end",
"def lset(key, index, value); end",
"def embed_property_value_list( property_value_list )\n count = 1 \n property_value_list.each do |property_value_pair|\n PropertyValue.create(:item_id => self.id, \n :property_id => property_value_pair[:property_id],\n :value_id => property_value_pair[:value_id],\n :position => count)\n count += 1 \n end\n end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value) self.send(\"#{key}=\", value) end",
"def set_multiple(keys, values)\n @mutex.synchronize do\n raise \"Invalid size #{keys}=#{values}\" unless keys.size == values.size\n # pp keys,values\n keys.zip(values).each do |var, val|\n do_set(var,val) unless var.nil? or val.nil?\n end\n end\n end",
"def []=(index, value)\n @driver_instance.set_list_value(@key, index, value)\n end",
"def set(index,x)\n if index.is_a? Symbol\n index = get_by_sym(index)\n end\n unless x.nil? or x == ''\n if fields_desc[index][1] # we're a repeating field\n x = [x] unless x.is_a? Array\n @fields[index] = x.map { |y| fields_desc[index][2].from_ruby(y)}\n else\n @fields[index] = fields_desc[index][2].from_ruby(x)\n end\n if @fields[index].respond_to?(:separator) && @separator == '^' # we're a field, so it's a subfield\n @fields[index].separator = '&'\n end\n end\n end",
"def []=(index, value)\n method_name = \"#{index.to_s.downcase}=\"\n raise KeyError.new(\"Unkown index: #{index}\") unless respond_to? method_name\n send method_name, value\n end",
"def build_properties\n properties.each do |key,val|\n prop = listing_properties.find_or_initialize_by(key:key)\n prop.value = val\n\n end\n end",
"def assign_property(name, value); end",
"def []=(k, v)\n @property[k.to_s] = v\n end",
"def change_quantity(list, food, quantity)\n list[food] = quantity\nend",
"def variants_multiply_properties(list)\n return if list.empty?\n keys = list.first.keys\n raise \"Must have same properties\" unless list.collect { |h| h.keys }.uniq.length == keys.length\n raise \"Must have unique list\" unless list.uniq.length == list.length\n self.variants = self.variants.collect do |vd|\n list.collect do |h|\n v = vd.dup\n if num = keys.delete('supplier_num')\n v.supplier_num = num\n elsif post = keys.delete('postfix')\n v.supplier_num += post\n else\n v.supplier_num += keys.collect { |k| \"-#{h[k]}\" }.join\n end\n v.properties = v.properties.merge(h)\n v\n end\n end.flatten\n end",
"def set(pairs={})\n if not(immutable?)\n pairs.each {|idx, val| self[idx] = val}\n return self\n else\n pairs.inject(self) {|obj, (idx, val)| obj.send(\"[]=\", idx, val)}\n end\n end",
"def []=(index, value)\n end",
"def []=(index, obj)\n if obj.is_a?(Array)\n obj.each { |o| expect(o, [Data, Header]) }\n else\n expect(obj, [Data, Header])\n end\n super\n end",
"def []=(key, val); end",
"def set!(value_obj)\n\t\t\tinsist!()\n\t\t\t@lookup[0...-1].inject(@obj_with_keys) { |deep_obj, this_key|\n\t\t\t\tdeep_obj[this_key]\n\t\t\t}[@lookup[-1]] = value_obj\n\t\tend",
"def set(property_name, value, status = nil)\n status = value.nil? ? 404 : 200 if status.nil?\n result[property_name] = [status, value]\n end",
"def set(obj, key, *fields)\n if obj.is_a?(String)\n hmset_params = [key, fields[0], obj]\n elsif obj.is_a?(Array)\n hmset_params = [key, fields[0], Oj.dump(obj)]\n else\n hmset_params = [key]\n fields.each do |field|\n raw_value = obj.__send__(field)\n value = raw_value.is_a?(Array) ? Oj.dump(raw_value) : raw_value\n hmset_params << field\n hmset_params << value\n end\n end\n\n @redis.hmset hmset_params\n end",
"def []=(index, value)\n end",
"def []=(key, val)\n @properties[key] = val\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @list = args[:list] if args.key?(:list)\n @map = args[:map] if args.key?(:map)\n @type = args[:type] if args.key?(:type)\n @value = args[:value] if args.key?(:value)\n end",
"def []=(indx, value)\n elements[indx] = value\n end",
"def []=(term_or_property, value)\n self[term_or_property].set(value)\n end",
"def set(values); end",
"def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end",
"def set_fields(object, json_object, *field_specs)\n field_specs.each do |field_spec|\n field_spec = field_spec.zip(field_spec).to_h if field_spec.is_a?(Array)\n field_spec.each do |json_field, hq_field|\n object.send(\"#{hq_field}=\", json_object[json_field.to_s])\n end\n end\n end",
"def []=(name, index = 0, value)\n __send__(self.class::MEMBERS_SETFN[name], value, index)\n end",
"def set(key, value); end",
"def set(key, value); end",
"def set_property(key, value)\n @data[key] = value\n end",
"def set(*indices, value)\n set_root @config, value, *indices\n end",
"def []= name, value\n set_all name => value\n end",
"def set(instance)\n # TODO could we not cause a nasty bug by dropping nil value keys when the \n # user is using composite keys? Should we not rather raise an error if\n # the value is nil?\n key = instance.key\n \n raise ArgumentError.new(\"+key+ must be an Array, and can not be empty\") if key.empty? \n @cache[instance.class][key] = instance \n end",
"def set(obj, value)\n if @type\n if @single\n value = @type.parse(value)\n else\n value = value.map{|e| @type.parse(e)}\n end\n elsif @builder\n if @single\n value = @builder.call(value)\n else\n value = value.map{|e| @builder.call(e)}\n end\n end\n obj.send(\"#{@sym}=\".to_sym, value)\n end",
"def index(*rel_type_props)\n if rel_type_props.size == 2 and rel_type_props[1].kind_of?(Hash)\n rel_type_props[1].each_pair do |key, value|\n idx = rel_type_props[0]\n indexer.field_infos[idx.to_sym][key] = value\n end\n rel_type_props = rel_type_props[0..0]\n end\n rel_type_props.each do |rel_type_prop|\n rel_name, prop = rel_type_prop.to_s.split('.')\n index_property(rel_name) if prop.nil?\n index_relationship(rel_name, prop) unless prop.nil?\n end\n end",
"def apply_hash!(props)\n props.each do |k, v|\n send(\"#{k}=\", v) if respond_to? \"#{k}=\"\n end\n end",
"def []=(key, value)\n end",
"def []=(*indexes, value)\r\n validate_index_count(indexes)\r\n source = value.in_array.cycle\r\n process_indexes(indexes) {|_index, posn| @array_data[posn] = source.next}\r\n value\r\n end",
"def []=(index, value)\n self.__setitem__ index, value\n end",
"def index(*rel_type_props)\n if rel_type_props.size == 2 and rel_type_props[1].kind_of?(Hash)\n rel_type_props[1].each_pair do |key,value|\n idx = rel_type_props[0]\n lucene_index.field_infos[idx.to_sym][key] = value\n end\n rel_type_props = rel_type_props[0..0]\n end\n rel_type_props.each do |rel_type_prop|\n rel_type, prop = rel_type_prop.to_s.split('.')\n index_property(rel_type) if prop.nil?\n index_relation(rel_type_prop, rel_type, prop) unless prop.nil?\n end\n end",
"def aset(index, value)\n end",
"def do_set current, keys, value\n if keys.blank?\n current[:value] = value\n return current\n end\n\n keys = [keys] unless keys.is_a? Array\n current_key = keys.shift.to_sym\n if current[current_key].blank?\n current[current_key] = {:value => {}}\n end\n \n if keys.size > 0\n current[current_key] = do_set(current[current_key], keys, value)\n else\n current[current_key][:value] = value \n end\n \n current\n end",
"def property_index\n schema.index_groups.each do |group_name, definitions|\n next if group_name =~ FIELD_INDEX_REGEXP\n cur_indices = {}\n definitions.each do |key, proc|\n if key\n value = prop[key]\n if !value.blank?\n if proc\n # Get value(s) to index through proc\n cur_indices.merge!(proc.call(self))\n else\n # Set current value from prop\n cur_indices[key] = value\n end\n end\n else\n # No key: group index generated with\n # p.index(group_name) do |record| ...\n cur_indices.merge!(proc.call(self))\n end\n end\n \n if group_name.kind_of?(Class)\n # Use a custom indexer\n group_name.set_property_index(self, cur_indices)\n elsif index_reader(group_name)\n # Add key/value pairs to the default tables\n old_indices = get_indices(group_name)\n\n old_keys = old_indices.keys\n cur_keys = cur_indices.keys\n\n new_keys = cur_keys - old_keys\n del_keys = old_keys - cur_keys\n upd_keys = cur_keys & old_keys\n \n upd_keys.each do |key|\n value = cur_indices[key]\n if value.blank?\n del_keys << key\n elsif value != old_indices[key]\n update_index(group_name, key, value)\n end\n end\n\n if !del_keys.empty?\n delete_indices(group_name, del_keys)\n end\n\n new_keys.reject! {|k| cur_indices[k].blank? }\n if !new_keys.empty?\n create_indices(group_name, new_keys, cur_indices)\n end\n end\n end\n end",
"def []=(arg, value)\n Neo4jr::Indexer.attempt_index(self, arg.to_s, value)\n set_property(arg.to_s, value)\n end",
"def set(key, value, **options); end",
"def []=(key , value)\n set(key, value)\n end",
"def set(key , value)\n index = key_index(key)\n if( index )\n @i_values.set(index , value)\n else\n @i_keys.push(key)\n @i_values.push(value)\n end\n value\n end",
"def map(input, property); end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end",
"def []=(key, value)\n property = candy_coat(key, value) # Transform hashes and arrays, and communicate embedding\n candy[key] = property\n set key.to_sym => property\n end",
"def property_ids=(ids)\n property_regions = []\n\n ids.each_with_index do |id, index|\n r = nil\n if self.id && !id.blank?\n begin\n r = Gca::PropertyRegion.find_or_create_by_region_id_and_property_id(self.id, id)\n rescue ActiveRecord::RecordNotFound\n next\n end\n\n r.update_attributes!(:position => index)\n property_regions << r\n end\n end\n\n update_attributes(:property_regions => property_regions)\n end",
"def set(key, value)\n arr_pos = to_hash(key)\n list = @array[array_pos]\n node = list.find_by_key(key)\n if node\n node.data = value\n else\n self.put(key, value)\n end\n end",
"def []=(key, value)\n @properties[key] = value\n end",
"def []=(key, value)\n @properties[key] = value\n end",
"def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def set(index, val)\n @current[index] = val\n end",
"def apply(diffs)\n diffs.each do |diff|\n flag, key, v1, v2 = diff\n if key =~ /\\[/\n keyname, is_array, index = key.match(/^(.*)(\\[)(.*)\\]$/).captures\n else\n keyname = key\n end\n\n property = PropertyMappings[keyname]\n if property\n case flag\n when '~'\n # change a value in place\n\n if keyname == 'other.dob'\n # date-of-birth must be formatted correctly\n dob = v1 && Date.parse(v1).to_time\n set(property, dob)\n\n elsif keyname == 'org.is_org'\n # must merge with other flags\n set_org(property, v1)\n\n elsif keyname == 'other.note'\n # for notes, we concatenate, not replace\n newnote = [v1, v2].join(\"\\n\\n\")\n set(property, newnote)\n\n elsif is_array\n raise \"SOMETHING IS WRONG - NOT SUPPOSED TO EVER CHANGE ARRAY ENTRIES IN PLACE, ALWAYS DELETE & ADD\"\n\n else\n # puts \"MAP #{keyname} TO #{property} AND SET TO #{v1}\"\n set(property, v1)\n end\n\n when '+'\n # add something\n if keyname == 'other.dob'\n # date-of-birth must be formatted correctly\n dob = v1 && Date.parse(v1).to_time\n set(property, dob)\n elsif keyname == 'org.is_org'\n # must merge with other flags\n set_org(property, v1)\n elsif is_array\n # multivalue property\n if property == []\n add_link(v1)\n else\n addmulti(property.first, v1, property.last)\n end\n else\n # scalar property\n set(property, v1)\n end\n\n when '-'\n # remove something\n if is_array\n # multivalue property\n if property == []\n del_link(index.to_i, v1)\n else\n # delmulti(property.first, index.to_i)\n delcomplex(keyname, v1)\n end\n else\n # scalar property\n if keyname == 'org.is_org'\n # must clear a flag bit, not wipe the entire flag\n set_org(property, 0)\n else\n # set the value to nil\n set(property, nil)\n end\n end\n end\n else\n if keyname == 'xref.ab'\n raise \"*** DO NOT APPLY CHANGES TO UID VALUE ***\"\n else\n raise \"NO PROPERTY MAPPING FOR KEY #{keyname}\"\n end\n end\n end\n end",
"def []=(*names)\n values = names.pop\n values = [values] unless Array === values\n names.each_with_index do |name, i|\n use name => (values[i] || values.last)\n end\n end",
"def []=(index, value)\n set(index, value)\n end",
"def lset(key, index, value)\n send_command([:lset, key, Integer(index), value])\n end",
"def []= name, value\n set name, value\n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def set_property_values_from_script(results)\n reg_flag = /\\$\\$SS_Set_.+\\}\\$\\$/\n reg = /\\$\\$SS_Set_Property.+\\$\\$/\n #msg = \"SS__ Updating property values from script.\\n\"\n occurrences = results.scan(reg_flag)\n return if occurrences.empty?\n props = Hash.new\n set_props = Hash.new\n occurrences.each do |set_str|\n prop = set_str.gsub(\"$$SS_Set_Property{\", \"\").gsub(\"}$$\", \"\")\n keyval = prop.split(\"=>\")\n props[keyval[0].strip] = keyval[1].strip\n end\n cur_props = current_property_values\n props.each do |k, v|\n if cur_props.has_key?(k)\n id = installed_component.properties.active.find_by_name(k).id\n msg += \"SS__ Updating property #{k}(#{id.to_s}: change value from: #{cur_props[k]} to #{v.to_s}\"\n set_props[id.to_s] = v.to_s # Add back as the id\n else\n msg += \"\\nSS__ Property not found: #{k}\\n\"\n end\n end\n #logger.info(msg)\n new_values = {\"installed_component\" => {installed_component.id.to_s => set_props}}\n update_property_values!(new_values)\n end",
"def property_field_index\n schema.index_groups.each do |group_name, definitions|\n if group_name =~ FIELD_INDEX_REGEXP\n # write attribute in owner\n key = definitions.first.first\n self[$1] = prop[key]\n end\n end\n end",
"def set_properties(properties_hash)\n # Set the initial property values from the given hash\n properties_hash.each do |key, value|\n self.send(\"#{key}=\", value)\n end\n end",
"def property(*props)\n if props.size == 2 and props[1].kind_of?(Hash)\n props[1].each_pair do |key, value|\n pname = props[0].to_sym\n properties_info[pname] ||= {}\n properties_info[pname][key] = value\n end\n props = props[0..0]\n end\n\n props.each do |prop|\n pname = prop.to_sym\n properties_info[pname] ||= {}\n properties_info[pname][:defined] = true\n\n define_method(pname) do\n self[pname]\n end\n\n name = (pname.to_s() +\"=\").to_sym\n define_method(name) do |value|\n self[pname] = value\n end\n end\n end",
"def []=(index, value)\n @members[index] = cast_value(value)\n end"
] | [
"0.63857895",
"0.6379823",
"0.6344935",
"0.62090087",
"0.6051336",
"0.59849536",
"0.59822863",
"0.59011275",
"0.58627415",
"0.5824263",
"0.58038026",
"0.5799478",
"0.5796597",
"0.579442",
"0.5773002",
"0.57089293",
"0.57089293",
"0.56992245",
"0.5680076",
"0.5680076",
"0.5680076",
"0.5680076",
"0.5680076",
"0.5680076",
"0.5680076",
"0.5680076",
"0.5680076",
"0.5680076",
"0.5680076",
"0.5680076",
"0.5680076",
"0.5680076",
"0.5680076",
"0.5680076",
"0.56507504",
"0.5611018",
"0.5606459",
"0.5590982",
"0.5588206",
"0.55495644",
"0.5532243",
"0.55280125",
"0.5506873",
"0.5505167",
"0.5495014",
"0.5490712",
"0.5470581",
"0.5468809",
"0.54679143",
"0.5456366",
"0.5452945",
"0.5446129",
"0.5426723",
"0.541343",
"0.54030794",
"0.5391899",
"0.53915274",
"0.5390404",
"0.53880113",
"0.53861415",
"0.53786236",
"0.53786236",
"0.5373088",
"0.5365345",
"0.53594106",
"0.53489953",
"0.53485966",
"0.5344594",
"0.53336614",
"0.53205866",
"0.5316378",
"0.5314427",
"0.5306674",
"0.52933204",
"0.52906257",
"0.5286872",
"0.52831775",
"0.52783555",
"0.5263772",
"0.5260227",
"0.5250382",
"0.52459615",
"0.52426165",
"0.5232903",
"0.5231575",
"0.52296597",
"0.52296597",
"0.5224918",
"0.5224403",
"0.5220012",
"0.52178705",
"0.52169514",
"0.5215565",
"0.52048266",
"0.5197987",
"0.519225",
"0.51917684",
"0.5187971",
"0.5174579",
"0.51717263"
] | 0.7385258 | 0 |
def before_create_save(record) if ! current_user.data_entry_only record.approved = 0 end end | def add_dynamic_columns
organism = Organism.find(:first, :conditions => ["project_id = ?", current_project_id])
c = active_scaffold_config
for cp in [c.list, c.update, c.create, c]
columns_for_deletion = (cp.columns.map(&:name).map(&:to_sym) - Organism.columns.map(&:name).map(&:to_sym))
cp.columns.exclude *columns_for_deletion
if organism
dynamic_columns ||= organism.dynamic_attributes.map(&:name)
cp.columns.add dynamic_columns
end
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n self.approved = true\n super\n end",
"def set_approved\n if not self.approved # don't want to run with seed file\n self.approved = false\n end\n end",
"def approve!\n self.approved = true\n self.save\n end",
"def approve_setup_fee_collection( current_user )\n self.is_setup_fee_collection_approved = true \n self.setup_fee_collection_approver_id = current_user.id \n self.save\n \n # create all those payment payable : loan disbursement \n end",
"def before_save\n # boolean fields cannot be NULL at database level\n self.is_active = 0 if self.is_active.nil?\n end",
"def approve()\n if update_attributes({:level => Membership::LEVELS[:regular]})\n true\n else\n reload\n false\n end\n end",
"def auto_approve!\n update_attribute(:approved_at,DateTime.now)\n update_attribute(:approved_by, User.APPLICATION)\n write_key!\n end",
"def set_approval\n self.sanctuary? ? self.approved = false : self.approved = true\n end",
"def disapprove\n self.approved = false\n end",
"def before_save\n # boolean fields cannot be NULL at database level\n self.is_active = 0 if self.is_active.nil?\n end",
"def before_create_save(record); end",
"def prohibit\n @profile.approved = false\n @profile.save!\n redirect_to profiles_path(status: 'approved')\n end",
"def before_save\n self.status = 'submitted' if status.blank?\n end",
"def set_grace_period_defaultee_status\n if self.group_loan_backlogs.where(:is_paid => false).count != 0 \n self.is_defaultee = true \n self.save \n end\n end",
"def approve!\n self.approved_at = Time.now\n registration.approve\n save!\n end",
"def user_can_save?\n false\n end",
"def check_for_spam\n if self.spam?\n self.update_column(:approved, false)\n elsif !approved\n self.update_column(:approved, true)\n end\n end",
"def approve_writer(flag)\n if flag=='true' || flag==1\n self.wflag=true\n if self.save\n return true\n end\n else\n self.wflag=false\n self.save\n end\n end",
"def approved?\n !approved_on.nil?\n end",
"def approved?\n !pending\n end",
"def create\n super do |user|\n if User.where(user_type: 0).empty?\n user.user_type = 0\n resource_saved = user.save\n end\n end\n end",
"def approve_user\n # set the enabled flag to true for the user\n # send out approval notification\n end",
"def create\n @post = Post.new(post_params)\n @post.approved = false # double check this\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to root_url, notice: 'Post was successfully created.' }\n format.json { render action: '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",
"def approved?\n self.is_approved == true \n end",
"def can_be_approved?\n self.applied?\n end",
"def approve\n @profile.approved = true\n @profile.save!\n redirect_to profiles_path(status: 'prohibited')\n end",
"def approve!\n update_attribute(:active, true)\n end",
"def check_if_needs_approval\r\n self.suspended_at = Time.now if Setting.user_signup == :needs_approval && !self.admin\r\n end",
"def approve_adoption\n self[:adoptable] = false\n save\n end",
"def set_to_approved\n if self.rating > 3\n self.update_attribute('approved', true)\n end\n @project = Project.find(self.project_id)\n @project.update_attribute('has_reviewed_contractor', true)\n end",
"def before_create_save(record)\n do_save_logic(record)\n record.usr_id = session[:usr_id]\n end",
"def before_create\n \tself.day_made ||= Date.current if new_record?\n \tself.got_bonus = false\n \tend",
"def before_update_save(record)\n record.puesto_id = nil\n record.origen_id = record.buzon_id\n record.carpeta_id = nil\n record.add_traza(current_user.id, 8, current_user.puesto.buzon_id)\n if record.documento.digital \n record.despachar\n else\n record.estado_id = 6\n end\n end",
"def deny\n self.status = 'denied'\n save\n end",
"def approve_me\n self.update!(status: 'APPROVED')\n end",
"def before_update_save(record)\n record.save if record && record.valid?\n end",
"def before_update_save(record); end",
"def approve!\n self.update_attribute(:status, ConfigCenter::User::APPROVED)\n end",
"def is_editable\n not is_default_cash_gift\n end",
"def money_approved?\n true\n end",
"def approve_user\n @user = User.find(params[:id])\n\n @user.approved_torcida = true\n @user.save(validate: false)\n redirect_to root_path\n end",
"def auto_approve\n user=photo.user or return nil\n if user.admin?\n photo.approver_id=user.id\n photo.status = Photo::STATUS_APPROVED\n end\n end",
"def approve(user)\n if !self.approved?\n self.approved = true\n self.manager = user\n self.approved_at = Time.now\n end\n end",
"def update?\n raise CustomErrors::PermissionError unless record.id == user.id\n\n Regular.new(record)\n end",
"def is_approval_required_for_add=(value)\n @is_approval_required_for_add = value\n end",
"def do_before_save\n self.dc_user_id = nil if self.public\nend",
"def make_first_user_admin\n return unless User.count.zero?\n\n self.is_admin = true\n self.approved = true\n end",
"def post_is_create?\n\t\ttrue\n\tend",
"def create?\n @current_user.permission('Bid', :clerk)\n end",
"def create?\n\t\tuser.course_grants > 0\n\tend",
"def before_create_save(record)\n record.user = current_user\n record.categories = CategoryNews.find(params[:record][:news_categories_override]) unless params[:record][:news_categories_override].blank?\n end",
"def update!(**args)\n @approved = args[:approved] if args.key?(:approved)\n end",
"def approved?\n !self.pending\n end",
"def put_can_create?\n false\n end",
"def approve\n if self.status == \"pending_presenter\" || self.status == \"pending_admin\"\n \n #move edit columns to permanent columns\n self.bio = self.bio_edit\n if self.picture_edit_stored?\n self.picture = self.picture_edit\n end\n\n #clear edit columns\n self.bio_edit = ''\n self.picture_edit = nil\n \n #update status to approved\n self.status = :approved\n return self.save\n else\n return false\n end\n end",
"def authorized_for_update? \n return !self.is_default?\n end",
"def approve\n # raise @user.inspect\n @initiatives = Initiative.find(params[:id])\n @initiatives.is_approved = !@initiatives.is_approved?\n @initiatives.update_column(:is_approved,true) \n # if @initiatives.is_approved\n @user= User.find_by_id(@initiatives.user_id)\n reputation_count = @user.reputation\n @initiatives1 = @user.update_column(:reputation,reputation_count+10)\n # end\n @initiatives.save!\n \n redirect_to :back\n end",
"def approving_change?(approving)\n saved_instance = DesignChange.find(self.id) if self.id\n approving && (!saved_instance || !saved_instance.approved?)\n end",
"def cfp_data_only_if_manages_proposals\n return true if manages_proposals\n self.cfp_open_date = self.cfp_close_date = nil\n self.public_proposals = false\n true\n end",
"def prep_for_save\n # what about when doing the set deposited flag ????\n # if @allow_edit\n # @employee_benefit[\"deposit\"] = round_money(@employee_benefit[\"monthly_benefit\"] - tot_current_benefit)\n # end\n # Deposit to make calculation\n self.deposit =\n self.monthly_benefit.to_f - # Required Total Benefit\n self.tot_current_benefit.to_f - # Current Benefit without DBP (Employee Hourly Benefit (rate) * Total Hours (of Benefit record)\n self.tot_deposits_made.to_f # Previous Deposits (sum of all Employee Benefits for this month that have already been deposited)\n if self && !self.reg_hours\n self.reg_hours = 0.0\n end\n if self && !self.ot_hours\n self.ot_hours = 0.0\n end\n end",
"def permitted?; end",
"def is_approved?\n self.approved == 'approved'\n end",
"def inactivate=(val)\n self.deleted_at = Time.zone.now if !deleted_at && (val && (val == '1' || val.to_s == 'true'))\n end",
"def not_active_on_create!\n self.deleted_at ||= Time.zone.now\n end",
"def before_approve\n validate_associated_fields\n if organizations.where(approved: false).count > 0\n fail_validation :organizations, 'only_approved_organizations',\n list: organizations.approved.pluck(:name).join(', ')\n end\n fail_validation :area, 'needs_area_when_remote' if !personal? && !area\n end",
"def before_save\n begin\n #\n # test-mode status is redundant here for the purpose reporting etc...\n #\n # ramonrails Thu Oct 14 05:14:06 IST 2010\n # lately, we have test_mode working as follows\n # * user is considered in test mode when user.test_mode == true\n # * when user goes into test mode\n # * membership of safety_care is opted\n # * caregivers are set away\n # user = User.find(user_id) # not required. user is already assigned here\n self.test_mode = user.test_mode? unless user.blank?\n #\n # ramonrails: Thu Oct 14 01:56:19 IST 2010\n # CHANGED: ** do not ** return a false\n # returning false will abort any further execution of calbacks, or this save\n # above code was un-intentionally returning false in some cases\n true # continue execution. returning false would not save the record\n rescue\n true # no matter what, execute critical_device_event_observer.after_save\n end\n end",
"def before_save\n self.available = true if self.available.nil?\n super\n end",
"def before_save\n self.available = true if self.available.nil?\n super\n end",
"def dean_approved?\n !approved_at.blank?\n end",
"def mark_lead_approved(event)\n if event.job.lead && event.job.lead.approved_at.nil?\n event.job.lead.update(approved_at: Time.now.utc)\n end\n end",
"def is_approved?\n moderation_flag ? true : false\n end",
"def is_approved?\n moderation_flag ? true : false\n end",
"def adjust_after_create\n # The record is in @record, do what you will, this precedes a save.\n end",
"def assign_approver\n if approver == \"1\"\n document.approver = user\n document.save!\n end\n end",
"def inactivate=(val)\n return unless val.present?\n if val.to_s == '1' || val.to_s == 'true'\n self.deleted_at ||= Time.zone.now\n else\n self.deleted_at = nil\n end\n end",
"def attach_to_publishers user\n #self.publisher_id\n return nil unless self.user\n\n if user.personal_publishing_status == \"I have an exclusive publisher\" || \n user.personal_publishing_status == \"I own and control my own publishing\"\n self.publisher_id = user.personal_publisher_id\n self.save(validate: false)\n attach_to_publishing_agreement\n else\n ap 'something fancy here'\n end \n end",
"def before_create(model)\n model.created_by = @@current_user if model.respond_to?(\"created_by\")\n end",
"def before_save(sender); end",
"def release_on_approval\n super == 'true'\n end",
"def apply_approve\n \t# condition for check the cancelled flag then update flag as false else update only apply approve\n @product.cancelled ? @product.update(apply_approve: true,cancelled: false) : @product.update(apply_approve: true)\n @product.update(apply_approve: true)\n respond_to do |format|\n format.html { redirect_to publish_product_url(@product)}\n format.json { head :no_content }\n end\n end",
"def auto_approve\n if !self.auto_approved && self.approval_status.nil?\n UserMailer.auto_approved_email(self).deliver\n self.auto_approved = true\n self.approval_status = true\n self.save\n end\n end",
"def prepaid?\n not postpaid?\n end",
"def approve\n self.update(status: \"APPROVED\")\n end",
"def approve_clutch\n @clutch.approved = !@clutch.approved\n if @clutch.save\n redirect_to users_path\n else\n redirect_to users_path, alert: \"Error! Failed to Approve!\"\n end\n end",
"def save\n super if self.user_id.present?\n # Else do nothing (dont call save)\n end",
"def create?\n record.resourceable.owner == user || user.is?(:admin)\n end",
"def after_create_save(record); end",
"def allow_publication\n\n if new_state=publishing_workflow.next_state(self, PublishingAction::ALLOW)\n\n self.publishing_state_id = new_state.id\n if new_state != PublishingState::BANNED\n self.publishing_allowed_date = Time.now\n self.publishing_allowed_user = connected_user.username\n end\n\n save if self.respond_to?(:save)\n BusinessEvents::BusinessEvent.fire_event(:publication_allowed, publication_info)\n\n end\n\n\n end",
"def save\n a = @data_object\n unless a.existing_record?\n a.aff_to_do = TODO_CHALLENGES | TODO_FEES | TODO_DATES\n if a.aff_has_regions\n a.aff_to_do |= TODO_REGIONS\n end\n end\n super\n end",
"def is_approved?\n level > Membership::LEVELS[:pending]\n end",
"def only_create!\n self.operation = :only_create\n end",
"def active_for_authentication? \n super && is_approved? \n end",
"def registration_approval_required?; false; end",
"def is_approval_required_for_update=(value)\n @is_approval_required_for_update = value\n end",
"def approve!\n self.update_attribute(:status, APPROVED)\n self.registration.update_attribute(:status, Registration::VERIFIED) if self.registration\n end",
"def grant\n self.status = 'granted'\n save\n end",
"def auth_create_filter\n if not self.class.allowed_to_create\n false\n else\n true\n end\n end",
"def patch_can_create?\n false\n end",
"def create_permitted?\n acting_user.signed_up?\n end",
"def create_permitted?\n acting_user.signed_up?\n end",
"def before_create()\n end"
] | [
"0.75614184",
"0.68679637",
"0.66747713",
"0.66095054",
"0.6549236",
"0.65282166",
"0.64734954",
"0.64690673",
"0.64510965",
"0.6448938",
"0.6432727",
"0.6431113",
"0.63685566",
"0.6328542",
"0.63144296",
"0.62947196",
"0.6260362",
"0.62288254",
"0.62211394",
"0.62189066",
"0.6195444",
"0.6193384",
"0.61683327",
"0.61302024",
"0.61260897",
"0.6123655",
"0.6099877",
"0.60923433",
"0.6077264",
"0.60770947",
"0.60730124",
"0.6056498",
"0.6051991",
"0.6033888",
"0.6028752",
"0.6028435",
"0.602311",
"0.60190666",
"0.6010013",
"0.6003774",
"0.59987193",
"0.59843004",
"0.5966595",
"0.59628356",
"0.59581155",
"0.5946509",
"0.59294003",
"0.59147567",
"0.59145755",
"0.59137785",
"0.59082824",
"0.5902235",
"0.58769125",
"0.5865996",
"0.58632016",
"0.5858971",
"0.58550215",
"0.5846721",
"0.5839635",
"0.5831445",
"0.5828974",
"0.5828447",
"0.58275735",
"0.5819446",
"0.58091396",
"0.578555",
"0.5780245",
"0.5780245",
"0.5775669",
"0.576855",
"0.57619256",
"0.57619256",
"0.57601804",
"0.57590145",
"0.5756503",
"0.5752519",
"0.57461095",
"0.5739724",
"0.5736884",
"0.57318664",
"0.5719619",
"0.5719561",
"0.57182324",
"0.57134044",
"0.57106537",
"0.56982917",
"0.569082",
"0.56896144",
"0.56879807",
"0.5684298",
"0.5670172",
"0.5665739",
"0.56516856",
"0.56501883",
"0.5645086",
"0.56412584",
"0.56382406",
"0.56320864",
"0.56242",
"0.56242",
"0.5620602"
] | 0.0 | -1 |
TO: tenants, reservers, searchers | def tenant_notification(tenant)
@header_img_name = 'rental_confirm'
setup_email tenant.email, 'USSelfStorageLocator.com <info@usselfstoragelocator.com>', "Your #{tenant.listing.storage_type.try(:titleize) || 'Self Storage'} Rental"
@body[:tenant] = tenant
@body[:rental] = tenant.rental
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @consultant_customer_destinations = ConsultantCustomerDestination.all\n end",
"def index\n @user = current_user\n @destinations = Destination.search(params[:search])\n end",
"def index\n @license_tos = LicenseTo.all\n end",
"def index\n if current_user.user_type_id == 1 #SUPER USER\n @reservations = Agenda::Reservation.search(params[:search]).order(\"#{sort_column} #{sort_direction}\").paginate(per_page: 15, page: params[:page])\n else\n @reservations = Agenda::Reservation.my_department(current_user.department_id).search(params[:search]).order(\"#{sort_column} #{sort_direction}\").paginate(per_page: 15, page: params[:page])\n end\n end",
"def to(*receivers)\n receivers(receivers, 'to')\n end",
"def index\n unless current_user.has_role?('Librarian')\n if @user\n if current_user == @user\n redirect_to reserves_url(:format => params[:format])\n return\n else\n access_denied; return\n end\n end\n end\n\n search = Reserve.search\n query = @query = params[:query].to_s.strip\n sort_by = params[:sort_by].to_s.downcase\n if sort_by == 'title'\n @sort_by = :title\n sort_column = :title_transcription\n order = :asc\n else\n @sort_by = :created_at\n sort_column = :created_at\n order = :desc\n end\n if params[:format].to_s.downcase == 'csv'\n page = 1\n per_page = 65534\n else\n page ||= params[:page] || 1\n per_page ||= Reserve.default_per_page\n end\n\n if params[:mode] == 'hold' and current_user.has_role?('Librarian')\n search.build do\n with(:hold).equal_to true\n end\n else\n if @user\n user = @user\n if current_user.has_role?('Librarian')\n search.build do\n with(:username).equal_to user.username\n end\n else\n access_denied; return\n end\n else\n unless current_user.has_role?('Librarian')\n search.build do\n with(:username).equal_to current_user.username\n end\n end\n end\n end\n\n begin\n reserved_from = Time.zone.parse(params[:reserved_from])\n @reserved_from = params[:reserved_from].to_s.strip\n rescue\n reserved_from = nil\n end\n\n begin\n reserved_to = Time.zone.parse(params[:reserved_to])\n @reserved_to = params[:reserved_to].to_s.strip\n rescue\n reserved_to = nil\n end\n\n if params[:state].present?\n state = params[:state].downcase\n end\n\n search.build do\n fulltext query\n if reserved_from\n with(:created_at).greater_than_or_equal_to reserved_from.beginning_of_day\n end\n if reserved_to\n with(:created_at).less_than reserved_to.tomorrow.beginning_of_day\n end\n order_by sort_column, order\n with(:state).equal_to state if state\n facet :state\n paginate :page => page.to_i, :per_page => per_page\n end\n\n @reserves = search.execute.results\n @state_facet = search.facet(:state).rows\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @reserves }\n format.rss { render :layout => false }\n format.atom\n format.csv\n end\n end",
"def index\n @transports = Transport.all.includes(:bus,:from,:to)\n end",
"def index\n @travel_destinations = TravelDestination.all\n end",
"def index\n @travelers = Traveler.search(params[:search])\n end",
"def index\n @halalfoodhunt_seos = HalalfoodhuntSeo.all\n @search = Caterer.ransack(params[:q])\n @search.sorts = 'created_at DESC' if @search.sorts.empty?\n @caterers = @search.result.where(draft: false)\n @qualifying_type = QualifyingType.all\n end",
"def index\n @tourneys = Tourney.all\n end",
"def index\n @reach_out_to_customers = ReachOutToCustomer.all\n end",
"def index\n @reservations = @bus.reservations\n end",
"def index\n\n if current_user.role == \"admin\"\n reservations = VehicleReservation.all\n else\n reservations = VehicleReservation.where(user_id: current_user.id)\n end\n\n if params[:filter_by]==\"finished\"\n reservations = reservations.from_past\n elsif params[:filter_by]==\"future\"\n reservations = reservations.from_future\n end\n\n pending_reservations = reservations.where(status: \"pending\")\n approved_reservations = reservations.where(status: \"approved\")\n rejected_reservations = reservations.where(status: \"rejected\")\n\n @pending_reservations = VehicleReservationDecorator.decorate_collection(pending_reservations)\n @approved_reservations = VehicleReservationDecorator.decorate_collection(approved_reservations)\n @rejected_reservations = VehicleReservationDecorator.decorate_collection(rejected_reservations)\n end",
"def index\n @reservations = @apartment.reservations.all\n end",
"def index\n @halalfoodhunt_seos = HalalfoodhuntSeo.all\n @search = FoodDelivery.ransack(params[:q])\n @search.sorts = 'created_at DESC' if @search.sorts.empty?\n @food_deliveries = @search.result.where(draft: false)\n @qualifying_type = QualifyingType.all\n end",
"def index\n manage_filter_state\n\n filter = params[:ifilter]\n subscriber_code = params[:SubscriberCode]\n street_name = params[:StreetName]\n meter = params[:Meter]\n caliber = params[:Caliber]\n use = params[:Use]\n tariff_type = params[:TariffType]\n reading_route = params[:ReadingRoute]\n letter = params[:letter]\n # OCO\n init_oco if !session[:organization]\n # Initialize select_tags\n # @address = !street_name.blank? ? Subscriber.find(street_name).supply_address : \" \"\n @calibers = Caliber.by_caliber if @calibers.nil?\n @uses = Use.by_code if @uses.nil?\n @tariff_types = TariffType.by_code if @tariff_types.nil?\n @reading_routes = reading_routes_dropdown\n #@service_points = service_points_dropdown if @service_points.nil?\n #@meters = meters_dropdown if @meters.nil?\n\n # If inverse no search is required\n subscriber_code = !subscriber_code.blank? && subscriber_code[0] == '%' ? inverse_no_search(subscriber_code) : subscriber_code\n meter = !meter.blank? ? inverse_meter_search(meter) : meter\n street_name = !street_name.blank? ? inverse_street_name_search(street_name) : street_name\n\n # Set searches to use in @subscribers & @@subscribers\n search = subscribers_search(params[:search], session[:office], letter, subscriber_code, street_name, meter, caliber, use, tariff_type, reading_route, filter, per_page, true)\n # search_atat = subscribers_search(params[:search], session[:office], letter, subscriber_code, street_name, meter, caliber, use, tariff_type, filter, Subscriber.count, false)\n\n # @search = Subscriber.search do\n # fulltext params[:search]\n # if session[:office] != '0'\n # with :office_id, session[:office]\n # end\n # if !letter.blank? && letter != \"%\"\n # with(:full_name).starting_with(letter)\n # end\n # if !subscriber_code.blank?\n # if subscriber_code.class == Array\n # with :subscriber_code, subscriber_code\n # else\n # with(:subscriber_code).starting_with(subscriber_code)\n # end\n # end\n # if !street_name.blank?\n # if street_name.class == Array\n # with :supply_address, street_name\n # else\n # with(:supply_address).starting_with(street_name)\n # end\n # end\n # # if !street_name.blank?\n # # with :subscriber_id, street_name\n # # end\n # if !meter.blank?\n # if meter.class == Array\n # with :meter_code, meter\n # else\n # with(:meter_code).starting_with(meter)\n # end\n # end\n # if !caliber.blank?\n # with :caliber_id, caliber\n # end\n # if !use.blank?\n # with :use_id, use\n # end\n # if !tariff_type.blank?\n # with :tariff_type_id, tariff_type\n # end\n # if !filter.blank?\n # case filter\n # when 'all'\n # any_of do\n # with :subscribed, true\n # with :unsubscribed, true\n # end\n # when 'subscribed'\n # with :subscribed, true\n # when 'unsubscribed'\n # with :unsubscribed, true\n # when 'active'\n # with :activated, true\n # when 'inactive'\n # with :deactivated, true\n # end\n # end\n # data_accessor_for(Subscriber).include = [:street_directory, :meter]\n # order_by :sort_no, :desc\n # paginate :page => params[:page] || 1, :per_page => per_page || 10\n # end\n # @subscribers = @search.results\n # @@subscribers = Subscriber.where(id: @subscribers.map(&:id)).by_code_desc\n @reports = reports_array\n @subscribers = search.results\n\n # subscriber_ids = []\n # search_atat.hits.each do |i|\n # subscriber_ids << i.result.id\n # end\n # @@subscribers = Subscriber.where(id: @subscribers.map(&:id)).by_code_desc\n session[:page_entries] = @subscribers.map(&:id)\n page_entries_info_page = (params[:page] || 1)\n page_entries_info_per_page = (per_page || 10)\n page_entries_info_total = search.total\n page_entries = ' ' + I18n.t('activerecord.models.subscriber', count: search.total)\n if page_entries_info_total <= page_entries_info_per_page\n page_entries = page_entries_info_total.to_s + page_entries\n else\n page_entries = page_entries_info_page.to_s + '-' + page_entries_info_per_page.to_s + I18n.t(:of) + page_entries_info_total.to_s + page_entries\n end\n page_entries = ' ' + page_entries\n session[:page_entries_show] = page_entries\n\n # @@subscribers = Subscriber.where(id: subscriber_ids).by_code_desc\n # @@subscribers = Subscriber.with_these_ids(subscriber_ids).by_code_desc\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subscribers }\n format.js\n end\n end",
"def buses\n @buses = Bus.search(params[:source_search], params[:destination_search])\n end",
"def index\n if params[:brewery_id]\n @reservations = @brewery.reservations.all\n else\n @reservations = @user.reservations.all\n end\n end",
"def index\n @rental = Rental.find(params[:rental_id])\n @tenant_family_members = TenantFamilyMember.where(rental: @rental)\n end",
"def index\n @tenants = Tenant.search(params[:search])\n end",
"def index\n @servants = Servant.all\n end",
"def retrieveAgents(index,listing)\n case index\n when 0 #Sagamore\n listing[:contact_tel] = \"8773622684\"\n listing[:email] = \"cjjohnson@bozzuto.com\"\n\n when 1 #theChelsea\n listing[:contact_tel] = \"8884595280\"\n listing[:email] = \"jsanmiguel@bozzuto.com\"\n\n when 2 #Artisan\n listing[:contact_tel] = \"8887168573\"\n listing[:email] = \"dmcnally@bozzuto.com\"\n end\n listing\n end",
"def tenants\n @tenants\n end",
"def run\n super\n\n # Attach to the corpwatch service & search\n x = Ear::Client::Corpwatch::CorpwatchService.new\n corps = x.search @object.name\n\n corps.each do |corp|\n # Create a new organization object & attach a record\n o = create_object Organization, { \n :name => corp.name, \n }\n o.physical_locations << create_object(PhysicalLocation, {\n :address => corps.first.address, \n :state => corps.first.state,\n :country => corps.first.country }\n )\n end\n \n #@task_run.save_raw_result corps.to_s\n\n # Queue a detailed search\n TaskManager.instance.queue_task_run(\"hoovers_company_detail\",o, {})\nend",
"def index\n @transfers = []\n if current_user.admin?\n @transfers = Transfer.all\n else\n @transfers = Transfer.where(from: current_accounts.collect{|x| x.acct_number}) + Transfer.where(to: current_accounts.collect{|x| x.acct_number}) \n end\n end",
"def index\n order = Arel.sql('coalesce(sca_name,mundane_name) ASC')\n @search = params[:search]\n @recipients = if @search\n search_recipients(@search).order(order)\n else\n Recipient.order(order)\n end\n end",
"def index\n @offers = Offer.where(company_id: params[:company_id]) \n if params[:search].present?\n @q = @company.offers.near(params[:search], 200, :order => 'distance' ).ransack(params[:q])\n @offers = @q.result(:distinct => true)\n else \n @q = @company.offers.ransack(params[:q])\n @offers = @q.result(:distinct => true)\n end\n end",
"def index\n if params[:search]\n unless params[:search][:start_date].blank? &&\n params[:search][:end_date].blank? &&\n params[:search][:query].blank? &&\n params[:search][:capacity].blank?\n @reservation = Reservation.new(start_date: params[:search][:start_date], end_date: params[:search][:end_date])\n if params[:search][:capacity].blank?\n @trailers = Trailer.where(\"address ILIKE ?\", \"%#{params[:search][:query]}%\")\n else\n @trailers = Trailer.where(\"address ILIKE ?\", \"%#{params[:search][:query]}%\")\n .where(onboard_capacity: params[:search][:capacity])\n @trailers.select do |trailer|\n Reservation.where(trailer: trailer).where(\"start_date > ? OR end_date < ?\", params[:search][:end_date], params[:search][:start_date]).empty?\n end\n end\n @markers = @trailers.geocoded.map do |flat|\n {\n lat: flat.latitude,\n lng: flat.longitude,\n infoWindow: render_to_string(partial: \"info_window\", locals: { trailer: @trailers })\n }\n end\n else\n @trailers = Trailer.order(created_at: :desc)\n @markers = @trailers.geocoded.map do |flat|\n {\n lat: flat.latitude,\n lng: flat.longitude,\n infoWindow: render_to_string(partial: \"info_window\", locals: { trailer: @trailers })\n }\n end\n end\n else\n @trailers = Trailer.order(created_at: :desc)\n @markers = @trailers.geocoded.map do |flat|\n {\n lat: flat.latitude,\n lng: flat.longitude,\n infoWindow: render_to_string(partial: \"info_window\", locals: { trailer: @trailers })\n }\n end\n end\n end",
"def partner\n @services = Service.all\n @countries = Country.all\n @departments = Department.all\n end",
"def travel_and_places; end",
"def index\n if user_signed_in?\n @reservations = current_user.reservations\n elsif owner_signed_in?\n @reservations = []\n current_owner.restaurants.each {|rest| @reservations += rest.reservations}\n else\n redirect_to root_url, alert: \"Please, sign in!\" \n end\n end",
"def mapping_tenant\n @tenants = Tenant.where(:client_id => current_user.id, :is_active => true)\n @users = current_user.corporate_user\n end",
"def toronto\n\n end",
"def index\n authorize! :read, Transport\n type = params[:type]\n if type.present?\n @category = type == 'private' ? \"Car Riders\" : type == 'shuttle' ? \"Shuttle Cars\" : \"???\"\n end\n @transports = type ? Transport.where('lower(category) = ?', type.downcase) : Transport.all \n if params[:term] =~ /\\A\\d{10}\\Z/ # 10 digits\n @transports = @transports.joins(:smart_cards).where(smart_cards: {code: params[:term]})\n elsif params[:term]\n @transports = @transports.where('name LIKE ?', \"%#{params[:term]}%\")\n end \n @transports = @transports.order(:name).paginate(page: params[:page], per_page: 30) \n end",
"def index\n sanitized = whitelist(params, :index)\n\n # Extract travels\n if sanitized[:user_id]\n # As to Rails 4 doesn't have support for OR operator\n # @travels = Travels::Travel.submitted.where(\"customer_id = ? OR performer_id = ?\", sanitized[:user_id], sanitized[:user_id])\n @travels = Travels::Travel.of(current_user)\n else\n @travels = Travels::Travel.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { as_json @travels }\n end\n end",
"def index\n @suggestions = policy_scope(Item).order(expiration: :desc)\n\n Reservation.joins(:item)\n .where('items.pickup_time < ?', Time.now)\n .destroy_all\n\n @reservations = policy_scope(Reservation).order(created_at: :desc)\n @reservation = Reservation.new\n authorize @reservation\n\n # CAROUSEL: OTHER UNIQUE ITEMS BY SAME SUPPLIER\n @my_owned_items = Item.all.where(user: current_user)\n @same_supplier_items = []\n @in_cart = []\n @reservations.each do |reservation|\n @same_supplier_items |= reservation.item.user.items\n @in_cart << reservation.item\n end\n @same_supplier_items.select! { |item| item.pickup_time.to_datetime > DateTime.now }\n @same_supplier_items -= @in_cart\n @same_supplier_items -= @my_owned_items\n\n # CAROUSEL: OTHERS WITH SAME ITEMS IN CART ALSO HAVE THESE IN CART\n @other_reserved_items = []\n @my_reserved_items = []\n @reservations.each do |my_reservation|\n my_reservation.item.reservations.each do |same_reservation|\n same_reservation.user.reservations.each do |other_reservation|\n if other_reservation.user_id == current_user.id\n @my_reserved_items |= [other_reservation.item]\n else\n @other_reserved_items |= [other_reservation.item]\n end\n end\n end\n end\n @other_reserved_items.uniq!\n\n @other_reserved_items.select! { |item| item.pickup_time.to_datetime > DateTime.now }\n @other_reserved_items -= @my_reserved_items\n @other_reserved_items -= @my_owned_items\n\n # CAROUSEL: OTHERS WHO BOUGHT WHAT YOU'VE BOUGHT ALSO BOUGHT\n if @others_purchased_items = Order.all\n .where(state: 'paid')\n .where.not(user_id: current_user.id)\n .map(&:purchased_items)\n .flatten\n .map(&:item)\n .uniq!\n @others_purchased_items.select! { |item| item.pickup_time.to_datetime > DateTime.now }\n\n if @my_purchased_items = Order.all\n .where(state: 'paid')\n .where(user_id: current_user.id)\n .map(&:purchased_items)\n .flatten\n .map(&:item)\n .uniq!\n @others_purchased_items -= @my_purchased_items\n @others_purchased_items -= @my_owned_items\n end\n end\n\n # SHOPPING CART: SEPARATE ITEMS BY SELLER\n @reservations_suppliers = []\n @reservations.each do |reservation|\n supplier = reservation.item.user\n @reservations_suppliers |= [supplier]\n end\n @reservations_suppliers_with_reserved = @reservations_suppliers.map { |supplier|\n [\n supplier,\n @reservations\n .joins(:item)\n .where(items: { user_id: supplier.id })\n ]\n }\n\n if user_signed_in?\n @purchased_item = PurchasedItem.new\n @subtotal_price = 0\n @total_price = 0\n @total_items = 0\n @reservations.each do |reservation|\n @subtotal_price += reservation.item.price * reservation.quantity\n @total_items += reservation.quantity\n end\n @percent = 5.0\n @amount = @subtotal_price\n @subtotal_price = @subtotal_price * (1 / (1 + (@percent/100)))\n @commission = @amount - @subtotal_price\n else\n redirect_to reservations_error_path\n end\n end",
"def index\n if params[:from] and params[:to]\n if params[:from].blank? and params[:to].blank?\n\n flash[:error] = \"Please choose a valid date\"\n @search = MiscellaneousItem.search(params[:search])\n @miscellaneous_items = [] #@search.all(:order => \"transaction_date DESC, amount\", :limit => 0, :joins => :agent)\n\n else\n from = Date.parse(params[:from]).to_s rescue from = Date.today.to_s\n to = Date.parse(params[:to]).to_s rescue to = Date.today.to_s\n\n @search = MiscellaneousItem.search(params[:search])\n @search.transaction_date_greater_than_or_equal_to(from)\n @search.transaction_date_less_than_or_equal_to(to)\n\n if params[:option]\n unless params[:option][:agent_name].blank?\n check_name = params[:option][:agent_name]\n end\n end\n if check_name\n agent_id = MiscellaneousItem.check_agent_name(check_name)\n @search.agent_id_equals(agent_id)\n @miscellaneous_items = @search.all\n else\n @miscellaneous_items = @search.all\n end\n \n end\n \n else\n @search = MiscellaneousItem.search(params[:search])\n @miscellaneous_items = [] #@search.all(:order => \"date_paid DESC\", :limit => 0)\n end\n \n @miscellaneous_items = @miscellaneous_items.paginate(:page => params[:page], :per_page => 30)\n\n end",
"def index \n #@reservations = current_user.crm_redemption_reservations\n mbr_id = current_user.mbr_id \n @reservations = CrmRedemptionReservation.find_through_id_status(mbr_id, 0)\n @product_reservations = CrmProductReservation.find_through_id_status(mbr_id, 0)\n @workshop_reservations = CrmWorkshopReservation.find_through_mbr_id(mbr_id)\n end",
"def paid_request_to_tenant(reservation)\n @reservation = reservation\n @tenant = @reservation.user\n @cookoon = @reservation.cookoon\n @host = @cookoon.user\n mail(to: @tenant.full_email, subject: 'Vous avez demandé un Cookoon !')\n end",
"def index\n @travelers = Traveler.all\n end",
"def index\n @company = Company.all\n if session[:group] == \"admin\"\n if params[:fillter]\n @travellers = Traveller.search(params[:fillter]).order(\"created_at DESC\").page(params[:page])\n else\n @travellers = Traveller.order(:name).page(params[:page])\n end\n else\n @company = Company.where(id:session[:company_id])\n if params[:fillter]\n @travellers = Traveller.search(params[:fillter],session[:company_id]).order(\"created_at DESC\").page(params[:page])\n else\n @travellers = Traveller.where(company_id:session[:company_id]).order(:name).page(params[:page])\n end \n end\n # if params[:search]\n # @travellers = Traveller.search(params[:search]).order(\"created_at DESC\").page(params[:page])\n # else\n # @travellers = Traveller.order(:name).page(params[:page])\n # end\n end",
"def to_users \r\n return {rule: self, user_senders: actor_list('sender'), action: self.action, user_receivers: actor_list('receiver'), backup_list: backup_list}\r\n end",
"def index\n @reservation_owners = ReservationOwner.all\n end",
"def booking_email(reservation) #customer, host, reservtion_id\n @user = reservation.user #appoint reservation user id(email,name)\n @host = reservation.listing.user #appoint listing user(email,name)\n @listing = reservation.listing #appoint reservation. listing(which id)\n\n mail(to: @user.email, subject: \"Thank you for your booking.\") #after all info appointed, send an email to user(customer)\n end",
"def index\n @search_places = Place.ransack(params[:q])\n @places = @search_places.result.order(\"created_at DESC\").where(draft: false)\n @search_homies = Homy.ransack(params[:q])\n @homies = @search_homies.result.order(\"created_at DESC\").where(draft: false)\n @search_caterers = Caterer.ransack(params[:q])\n @caterers = @search_caterers.result.order(\"created_at DESC\").where(draft: false)\n @search_food_deliveries = FoodDelivery.ransack(params[:q])\n @food_deliveries = @search_food_deliveries.result.order(\"created_at DESC\").where(draft: false)\n @search_online_retails = OnlineRetail.ransack(params[:q])\n @online_retails = @search_online_retails.result.order(\"created_at DESC\").where(draft: false)\n @search_suppliers = Supplier.ransack(params[:q])\n @suppliers = @search_suppliers.result.order(\"created_at DESC\").where(draft: false)\n @search_raw_foods = RawFood.ransack(params[:q])\n @raw_foods = @search_raw_foods.result.order(\"created_at DESC\").where(draft: false)\n @search_bakers = Baker.ransack(params[:q])\n @bakers = @search_bakers.result.order(\"created_at DESC\").where(draft: false)\n @discounts = Discount.all\n end",
"def to\n @to = Array.new\n if new_hope == CHECKED\n @to << NEW_HOPE\n end\n if bridges == CHECKED\n @to << BRIDGES\n end\n if confirmation == CHECKED\n @to << @email\n end\n @to\n end",
"def index\n @engineers = Engineer.where(rentee_id: params[:rentee_id])\n @rentee = Rentee.find(params[:rentee_id])\n # @renteeId = Rentee.find(params[:tokens])\n end",
"def search\n \n # Populate the @traveler variable\n get_traveler\n \n query = params[:query]\n query_str = query + \"%\"\n Rails.logger.debug query_str\n\n # This array will hold the list of matching places\n matches = [] \n # We create a unique index for mapping etc for each place we find\n counter = 0 \n \n # First search for matching names in my places\n rel = Place.arel_table[:name].matches(query_str)\n places = @traveler.places.active.where(rel)\n places.each do |place|\n matches << {\n \"index\" => counter,\n \"type\" => PLACES_TYPE,\n \"name\" => place.name,\n \"id\" => place.id,\n \"lat\" => place.location.first,\n \"lon\" => place.location.last,\n \"address\" => place.address,\n \"description\" => render_to_string(:partial => \"/shared/map_popup\", :locals => { :place => {:icon => 'icon-building', :name => place.name, :address => place.address} })\n }\n counter += 1\n end\n \n # Second search for matching address in trip_places. We manually filter these to find unique addresses\n rel = TripPlace.arel_table[:raw_address].matches(query_str)\n tps = @traveler.trip_places.where(rel).order(\"raw_address\")\n old_addr = \"\"\n tps.each do |tp|\n if old_addr != tp.raw_address\n matches << {\n \"index\" => counter,\n \"type\" => CACHED_ADDRESS_TYPE,\n \"name\" => tp.raw_address,\n \"id\" => tp.id,\n \"lat\" => tp.lat,\n \"lon\" => tp.lon,\n \"address\" => tp.raw_address,\n \"description\" => render_to_string(:partial => \"/shared/map_popup\", :locals => { :place => {:icon => 'icon-building', :name => tp.name, :address => tp.raw_address} })\n }\n counter += 1\n old_addr = tp.raw_address\n end \n end\n \n # Lastly search for matching names in the POI table\n rel = Poi.arel_table[:name].matches(query_str)\n pois = Poi.where(rel).limit(MAX_POIS_FOR_SEARCH)\n pois.each do |poi|\n matches << {\n \"index\" => counter,\n \"type\" => POI_TYPE,\n \"name\" => poi.name,\n \"id\" => poi.id,\n \"lat\" => poi.lat,\n \"lon\" => poi.lon,\n \"address\" => poi.address,\n \"description\" => render_to_string(:partial => \"/shared/map_popup\", :locals => { :place => {:icon => 'icon-building', :name => poi.name, :address => poi.address} })\n }\n counter += 1\n end\n \n respond_to do |format|\n format.js { render :json => matches.to_json }\n format.json { render :json => matches.to_json }\n end\n end",
"def index\n @bookings = Booking.where(consumer_id: current_user).or(Booking.where(consultant_id: current_user))\n\n end",
"def indexUser\n #to show a list of the contract for the user\n @packages = Package.where(\"user_id == ?\", current_user.id)\n @journeys = Journey.where(\"driverID_id == ?\", current_user.id)\n @matches = Match.where(\"packageID_id IN (?) or journeyID_id IN (?)\", @packages.ids, @journeys.ids)\n @delivery_orders = DeliveryOrder.where(\"matchID_id IN (?)\", @matches.ids)\n end",
"def index\n\n @units = Unit.where(tower_id: params[:tower_id])\n @contracts = Contract.allbelongsto(params[:tower_id])\n end",
"def partners\n end",
"def index\n #approve_request\n @resource_transportation_bookings = ResourceTransportationBooking.where(:requester_id => \"#{current_user.id}\").order.page(params[:page]).per(5)\n end",
"def index\n query = params[:q].presence || \"*\"\n @destinations = Destination.search(query)\n end",
"def planner(from, to, params={})\n @client.get(\"/Journey/JourneyResults/#{from}/to/#{to}\", params)\n end",
"def index\n #@reservations = Reservation.all\n @reservations = current_user.reservations #.order(\"created_at DESC\")\n #@eateries = Eatery.all.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 5)\n end",
"def index\n search = params[:term].present? ? params[:term] : nil\n @offers = if search\n Offer.search(search, where: { user_id: { not: current_user.id }})\n else\n Offer.all\n end\n @request = Request.new\n @ver_oferta_todas = Offer.where.not(:user_id => current_user.id)\n end",
"def index\n #@agenda_reserv_resources = Agenda::ReservResource.all\n @agenda_reserv_resources = Agenda::ReservResource.search(params[:search]).order(\"#{sort_column} #{sort_direction}\").paginate(per_page: 15, page: params[:page])\n end",
"def index\n if params[:search]\n @page_title = \"List of Tours from filter\"\n # function located above...\n search_results = search()\n @tours = search_results[0]\n @filter = search_results[1]\n else\n personalize = params[:my_tours]\n bookmarked_tours = params[:bookmarked_tours]\n waitlisted_tours = params[:waitlisted_tours]\n\n if personalize\n if %w[admin agent].include?(current_user.role)\n @tours = current_user.tours\n @page_title = \"My Tours\"\n elsif current_user.role.eql? 'customer'\n booked_user_tours = current_user.user_tours.select {|x| x.booked? || x.wait_listed?}\n @tours = booked_user_tours.map {|ut| Tour.find(ut[:tour_id])}\n @page_title = \"My Tours\"\n end\n elsif bookmarked_tours\n bookmarked_user_tours = current_user.user_tours.select {|x| x.bookmarked?}\n @tours = bookmarked_user_tours.map {|ut| Tour.find(ut[:tour_id])}\n @page_title = \"My Bookmarked Tours\"\n elsif waitlisted_tours\n waitlisted_user_tours = current_user.user_tours.select {|x| x.wait_listed?}\n @tours = waitlisted_user_tours.map {|ut| Tour.find(ut[:tour_id])}\n @page_title = \"My Waitlisted Tours\"\n else\n @tours = Tour.all\n @page_title = \"All Tours\"\n end\n end\n end",
"def to(user, exclude=false)\n @query[:q] << \"#{exclude ? \"-\" : \"\"}to:#{user}\"\n self\n end",
"def index\n @relay_destinations = @relay.relay_destinations.order(base_url: :asc).all\n end",
"def index\n @reservations = Reservation.all\n #@reservations = current_user.reservations\n end",
"def tribes\n Tribe.all\n end",
"def list_branch_offices_near_to opts={}\n\t\t\trequest_id = rand(10000)\n\t\t\txml = \"<?xml version='1.0' encoding='utf-8'?>\n\t\t\t\t\t<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>\n\t\t\t\t\t <soap:Body>\n\t\t\t\t\t <consultaSucursalMasCercana xmlns='http://tempuri.org/'>\n\t\t\t\t\t <usuario>#{@user}</usuario>\n\t\t\t\t\t <contrasena>#{@password}</contrasena>\n\t\t\t\t\t <id>#{request_id}</id>\n\t\t\t\t\t <nombreCalle>#{opts[:street_name]}</nombreCalle>\n\t\t\t\t\t <numeroCalle>#{opts[:street_number]}</numeroCalle>\n\t\t\t\t\t <restoCalle>#{opts[:street_detail]}</restoCalle>\n\t\t\t\t\t <NombreComuna>#{opts[:commune_name]}</NombreComuna>\n\t\t\t\t\t <latitud>#{opts[:latitude]}</latitud>\n\t\t\t\t\t <longitud>#{opts[:longitude]}</longitud>\n\t\t\t\t\t </consultaSucursalMasCercana>\n\t\t\t\t\t </soap:Body>\n\t\t\t\t\t</soap:Envelope>\"\n\n\t\t\tbegin\n\t\t\t\txml_response = RestClient.post @server_url, xml, content_type: \"text/xml\"\n\t\t\t\tjson_response = Crack::XML.parse(xml_response)\n\t\t\t\tjson_response[\"soap:Envelope\"][\"soap:Body\"][\"consultaSucursalMasCercanaResponse\"][\"consultaSucursalMasCercanaResult\"]\n\t\t\trescue => error\n\t\t\t\treturn CityboxApi.catch_error(error)\n\t\t\tend\n\t\tend",
"def index\n @q = Restaurant.enabled.ransack(params[:q])\n @restaurants = @q.result(:distinct => true).sort_by{|r| [r.open? ? 0 : 1, r.rating * -1] } # refactor!\n @q.build_sort if @q.sorts.empty?\n\n save_district params[:q].try(:[], :deliverabilities_district_id_in)\n end",
"def index\n if params[:from] && params[:to]\n @schedules = Schedule.term_between(\n Date.new(params[:from][:year].to_i, params[:from][:month].to_i, params[:from][:day].to_i),\n Date.new(params[:to][:year].to_i, params[:to][:month].to_i, params[:to][:day].to_i).tomorrow)\n else\n @schedules = Schedule.all\n end\n end",
"def index\n @tenants = Tenant.all\n @tenants = policy_scope(Tenant).order(created_at: :desc)\n #@tenant = Tenant.find(params[:id])\n #@tenant = Tenant.find(params[:id])\n #tr4 = Apartment.find(6).tenants.first.first_name\n # => apartment(:id).tenants(@tenant)\n #@tenant = Apartment.find(params[:id]).tenants(tenant_params)\n\n end",
"def index\n @current_date = Date.today\n dated_params = {}\n @dests = Dest.all\n if params[:search].present?\n @dests = @dests.search(params[:search])\n end\n if params[:closed] != 'true'\n @dests = @dests.non_closed\n end\n if params[:dest_type].present?\n @dests = @dests.where(dest_type: params[:dest_type])\n end\n case params[:provisional]&.to_sym\n when :exclude\n @dests = @dests.where(provisional: false)\n when :only\n @dests = @dests.where(provisional: true)\n end\n if params[:company_id].present?\n @dests = @dests.where(company_id: params[:company_id])\n end\n if params[:prefecture].present?\n @dests = @dests.where(prefecture: params[:prefecture])\n end\n if params[:area_id].present?\n dated_params[:area_id] = params[:area_id]\n end\n # @dests = @dests.eager_load(:dest_dated_values)\n @dests = @dests.with_dated_values(@current_date, dated_params) if dated_params.present?\n @dests = @dests.page(params[:page])\n end",
"def index\n @renters = Renter.order(sort_column + \" \" + sort_direction)\n\n if user_signed_in?\n @renters = current_user.renters.order(sort_column + \" \" + sort_direction) if current_user.is_manager?\n if current_user.has_role?(:realtor) || current_user.has_role?(:vip_realtor)\n @renters = params[:with_order].eql?('true') ? @renters.with_order(current_user) : @renters.published\n # @renters = @renters.hide_inactive\n end\n if params[:state].present?\n @renters = @renters.by_state(params[:state])\n end\n else\n @renters = @renters.published.limit(100)\n end\n\n if params[:check_in].present?\n @renters = @renters.check_in_from(Date.parse(params[:check_in]))\n end\n\n @renters = @renters.where(town_id: params[:town_id] || 2)\n @renters = @renters.page(params[:page]).per(10)\n @url = params.dup\n @url.delete(:town_id)\n @url[:page] = params[:page] || 0\n end",
"def users\n runner_users + corporation_users\n end",
"def via(from, to)\r\n dest = { 'Hospital' => 'Foo St', 'Museum' => 'Bar St',\\\r\n 'Monroeville' => 'Fourth Ave', 'MuseumHillman' => 'Fifth Ave', \\\r\n 'HospitalHillman' => 'Foo St',\\\r\n 'MuseumCathedral' => 'Bar St', \\\r\n 'HospitalCathedral' => 'Fourth Ave' }\r\n return dest[to] if dest.include? to\r\n\r\n from_to = from + to\r\n return dest[from_to] \\\r\n if dest.include? from_to\r\n\r\n 'Fifth Ave'\r\n end",
"def index\n \tCongress.key = '0ef8e130fe124b69a2388d253fd05e63'\n \t#locating the congressmen by the logged on users zip code\n \tlegislators = Congress.legislators_locate(current_user.zip)[\"results\"]\n \t#isolating HOUSE (as opposed to House + Senate). Returning house member listed\n \t#in the event more than one appear\n \t@representative = legislators.select { |leg| leg.chamber == \"house\" }[0]\n #commented out aborted grading system\n \t#@grade = Grade.find_by_user_id_and_bioguide_id(current_user.id, @representative.bioguide_id)\n \t#sets up comments system\n \t@repcomments = Repcomment.find_all_by_bioguide_id(@representative.bioguide_id)\n \t#pulls recent votes from Sunlight API\n \t@votes = Congress.votes[\"results\"]\n end",
"def index\n begin\n ActiveRecord::Base.transaction do\n if !current_user.type.eql?(\"Admin\")\n @all_reservations = current_user.reservations\n else\n @all_reservations = Reservation.includes(:client, location_type: :sale_event).joins(\n location_type: :sale_event).where(sale_events:{admin_id: current_user.id})\n end\n end\n rescue Exception => exc\n flash[:danger] = exc.message\n redirect_to root_path\n end\n end",
"def index\n @destinations = current_user.destinations\n end",
"def index\n @tourtwos = Tourtwo.all\n if params[:search]\n @tourtwos = Tourtwo.search(params[:search]).order(\"created_at DESC\")\n else\n @tourtwos = Tourtwo.all.order('created_at DESC')\n end\n end",
"def index \n #@reservations = current_user.crm_redemption_reservations\n mbr_id = current_user.mbr_id \n #@reservations = CrmProductReservation.find_through_id_status(mbr_id, 0)\n @product_reservations = CrmProductReservation.find_through_id_status(mbr_id, 0)\n end",
"def index\n\n tour_creator = Tour.find_by(tourname: session[:tourname])\n #Agent who created the tour\n if session[:role]==2 and session[:username] == tour_creator.username\n @bookings=Booking.where(tourname: session[:tourname])\n #Customer\n elsif session[:role]==1\n @bookings=Booking.where(username: session[:username])\n #Admin\n elsif session[:role]==3\n @bookings=Booking.all\n #Other agents\n else\n respond_to do |format|\n format.html { redirect_to tours_url, notice: 'Agents can view bookings only of tours created by them' }\n end\n end\n end",
"def index\n @tadresses = Tadress.all\n end",
"def index\n @receita_a_recebers = ReceitaAReceber.all\n end",
"def tenants=(value)\n if getObject(getUrl,resource[:name]).include?('project_back_refs')\n tenants_to_add = resource[:tenants] - getObject(getUrl,resource[:name])['project_back_refs'].collect { |x| x['to'].join(':')}\n else\n tenants_to_add = resource[:tenants]\n end\n tenants_to_add.each do |x|\n use_fip('--project_name', \"default-domain:#{x}\", '--floating_ip_pool_name',\"#{resource[:network_fqname]}:#{resource[:name]}\")\n end\n end",
"def your_reservations\n @rooms = current_user.rooms\n @reservations = Reservation.all\n end",
"def recipients_from_to\n to\n end",
"def index\n @check_ins = CheckIn.all\n @destinations = Destination.all\n end",
"def index\n @tasks = Task.not_related.root.where(assigned_to: @user).or(Task.root.where(for_individual: @user) )\n end",
"def index\n @phone_reservations = PhoneReservation.all\n end",
"def perform (from=nil)\n if from.nil?\n subscribers = Octo::Subscriber.where(created_at: 24.hours.ago..Time.now.floor)\n else\n subscribers = Octo::Subscriber.where(created_at: from..Time.now.floor)\n end\n # MAIL CODE\n Octo.get_config(:email_to).each { |x|\n opts1 = {\n text: \"Today number of new susbcribes are \" + subscribers.length,\n name: x.fetch('name')\n }\n Octo::Email.send(x.fetch('email'), subject, opts1)\n }\n end",
"def to\n if self.reservation.user_id == self.user_id\n # client send a message to the author\n return self.reservation.product.user\n end\n return self.reservation.user\n else\n end",
"def index\n @orphan_sponsorships = OrphanSponsorship.all\n end",
"def index\n if params[:keywords].present?\n search = Address.search do\n fulltext params[:keywords]\n\n if params[:option] == \"Assigned\"\n without(:user_id, AddressesHelper.find_nobody_id)\n elsif params[:option] == \"Free\"\n with(:user_id, AddressesHelper.find_nobody_id)\n end\n\n paginate page: params[:page] || 1,\n per_page: IPAMSConstants::RECORD_COUNT_PER_PAGE\n end \n # Type Sunspot::Search::PaginatedCollection < Array\n @addresses = search.results\n elsif params[:option].present? && (params[:option] != \"All\")\n nobody_id = AddressesHelper.find_nobody_id\n if params[:option] == \"Assigned\"\n @addresses = Address.where.not(user_id: AddressesHelper.find_nobody_id)\n .paginate(page: params[:page],\n per_page: IPAMSConstants::RECORD_COUNT_PER_PAGE)\n elsif params[:option] == \"Free\"\n @addresses = Address.where(user_id: AddressesHelper.find_nobody_id)\n .paginate(page: params[:page],\n per_page: IPAMSConstants::RECORD_COUNT_PER_PAGE)\n end\n else\n # paginate returns object of \n # type User::ActiveRecord_Relation < ActiveRecord::Relation\n @addresses = Address.paginate(page: params[:page],\n per_page: IPAMSConstants::RECORD_COUNT_PER_PAGE)\n end\n\n authorize @addresses\n #policy_scope(@addresses)\n end",
"def index\n @user_reservations = query_reservations(user: current_user).paginate(page: params[:user_reservations_page], :per_page => 5)\n if current_user.is_admin?\n @awaiting_approval = query_reservations(status: 'requested')\n @all_reservations = query_reservations.paginate(page: params[:all_reservations_page], :per_page => 5)\n render :admin_index\n end\n end",
"def index\n @telfornecedors = Telfornecedor.all\n end",
"def index\n @global_links = GlobalLink.all\n @tier_two_links = TierTwoLink.all\n end",
"def subscribers_search(search, office, letter, subscriber_code, street_name, meter, caliber, use, tariff_type, reading_route, filter, per_page=10, data_accessor)\n Subscriber.search do\n fulltext search\n if office != '0'\n with :office_id, office\n end\n if !letter.blank? && letter != \"%\"\n with(:full_name).starting_with(letter)\n end\n if !subscriber_code.blank?\n if subscriber_code.class == Array\n with :subscriber_code, subscriber_code\n else\n with(:subscriber_code).starting_with(subscriber_code)\n end\n end\n if !street_name.blank?\n if street_name.class == Array\n with :supply_address, street_name\n else\n with(:supply_address).starting_with(street_name)\n end\n end\n # if !street_name.blank?\n # with :subscriber_id, street_name\n # end\n if !meter.blank?\n if meter.class == Array\n with :meter_code, meter\n else\n with(:meter_code).starting_with(meter)\n end\n end\n if !caliber.blank?\n with :caliber_id, caliber\n end\n if !use.blank?\n with :use_id, use\n end\n if !tariff_type.blank?\n with :tariff_type_id, tariff_type\n end\n if !reading_route.blank?\n with :reading_route_id, reading_route\n end\n if !filter.blank?\n case filter\n when 'all'\n any_of do\n with :subscribed, true\n with :unsubscribed, true\n end\n when 'subscribed'\n with :subscribed, true\n when 'unsubscribed'\n with :unsubscribed, true\n when 'active'\n with :activated, true\n when 'inactive'\n with :deactivated, true\n end\n end\n if data_accessor\n data_accessor_for(Subscriber).include = [:street_directory, :meter]\n end\n order_by :sort_no, :desc\n paginate :page => params[:page] || 1, :per_page => per_page\n end\n end",
"def index\n #@tipo_agressores = TipoAgressor.all\n @q = TipoAgressor.ransack(params[:q])\n @tipo_agressores = @q.result.accessible_by(current_ability).order('descricao ASC').paginate(:page => params[:page], :per_page => @@per_page)\n \n end",
"def index\n @destinations = Destination.all\n end",
"def index\n @customer_reservations = CustomerReservation.all\n end",
"def index\n @reservations = Reservation.includes(:guest).all\n end",
"def index\n @client.spots(-33.8670522, 151.1957362, :types => 'restaurant')\n @users = User.all\n end",
"def pickup_list(from, to, rental_location_code=nil, include_journal=false)\n\n # Get reservations\n\n conditions = {:date_from.gte => from,\n :date_from.lte => to,\n :status => [:confirmed, :in_progress, :done]}\n conditions.store(:rental_location_code, rental_location_code) if rental_location_code\n \n data = BookingDataSystem::Booking.all(\n :conditions => conditions,\n :order => [:date_from.asc, :time_from.asc]).map do |item|\n product = item.booking_lines.inject('') do |result, b_l|\n result << b_l.item_id\n b_l.booking_line_resources.each do |b_l_r|\n result << ' - '\n result << (b_l_r.booking_item_reference.nil? ? 'NO ASIGNADO' : b_l_r.booking_item_reference)\n result << ' '\n end\n result\n end\n extras = item.booking_extras.inject('') do |result, b_e|\n result << b_e.extra_description\n result << \"(#{b_e.quantity}) \"\n result\n end\n {id: item.id, date_from: item.date_from.to_date.to_datetime, time_from: item.time_from, pickup_place: item.pickup_place, product: product,\n status: item.status, customer: \"#{item.customer_name} #{item.customer_surname}\", customer_phone: item.customer_phone, customer_mobile_phone: item.customer_mobile_phone,\n customer_email: item.customer_email, flight: \"#{item.flight_airport_origin} #{item.flight_company} #{item.flight_number} #{item.flight_time}\",\n total_pending: item.total_pending, extras: extras, notes: item.notes, days: item.days, rental_location_code: item.rental_location_code}\n end\n \n # Include journal\n \n if include_journal\n journal_calendar = ::Yito::Model::Calendar::Calendar.first(name: 'booking_journal')\n event_type = ::Yito::Model::Calendar::EventType.first(name: 'booking_pickup')\n journal_events = ::Yito::Model::Calendar::Event.all(\n :fields => [:id, :from, :description],\n :conditions => {:from.gte => from, :from.lt => to+1, event_type_id: event_type.id,\n :calendar_id => journal_calendar.id},\n :order => [:from.asc]).map.each do |journal_event|\n {id: '.', date_from: journal_event.from.to_date.to_datetime,\n time_from: journal_event.from.strftime('%H:%M'), pickup_place: '', product: journal_event.description,\n status: '', customer: '', customer_phone: '', customer_mobile_phone: '',\n customer_email: '', flight: '', total_pending: 0, extras: '', notes: '', days: 0}\n end\n data.concat(journal_events)\n end\n\n data.sort! do |x, y|\n comp = x[:date_from] <=> y[:date_from]\n if comp.zero?\n begin\n Time.parse(x[:time_from]) <=> Time.parse(y[:time_from])\n rescue\n comp\n end\n else\n comp\n end\n end\n\n return data\n\n end",
"def index\n @search = Restaurant.ransack(params[:q])\n end"
] | [
"0.57205874",
"0.559882",
"0.55944085",
"0.55601573",
"0.55466485",
"0.55219793",
"0.5500766",
"0.5480267",
"0.54621303",
"0.5458389",
"0.5401559",
"0.5373629",
"0.5370903",
"0.5336728",
"0.5313613",
"0.5306105",
"0.52884793",
"0.5270205",
"0.52602905",
"0.52560216",
"0.52451694",
"0.5241653",
"0.5239432",
"0.5237686",
"0.52340543",
"0.52328914",
"0.5222715",
"0.52225137",
"0.5218859",
"0.5201118",
"0.5180266",
"0.5179964",
"0.51638097",
"0.5159029",
"0.51576227",
"0.51473796",
"0.51425225",
"0.5137341",
"0.513516",
"0.5122272",
"0.5121999",
"0.51157457",
"0.51146317",
"0.5102315",
"0.50997853",
"0.5093784",
"0.5093656",
"0.5092423",
"0.5092076",
"0.5084711",
"0.50841755",
"0.5083401",
"0.50765884",
"0.50757957",
"0.50723505",
"0.5067752",
"0.5067408",
"0.50572276",
"0.5053209",
"0.50513756",
"0.5050604",
"0.50462925",
"0.5045828",
"0.50455576",
"0.503528",
"0.503316",
"0.5030517",
"0.5028696",
"0.50252396",
"0.5022463",
"0.50193524",
"0.5015044",
"0.50085056",
"0.49990046",
"0.49964523",
"0.49885595",
"0.49871895",
"0.49815843",
"0.49811393",
"0.49800116",
"0.49791968",
"0.4972632",
"0.49706942",
"0.49646512",
"0.4963609",
"0.4956061",
"0.49534255",
"0.49497628",
"0.49443266",
"0.4938215",
"0.49372295",
"0.49359584",
"0.49358562",
"0.4935703",
"0.49286157",
"0.49282795",
"0.49233183",
"0.4922106",
"0.49189913",
"0.49155647",
"0.49074078"
] | 0.0 | -1 |
Returns an array 'board' of rows Each row is an array with randomly assigned values from 'colours' array | def get_board(width, height)
# Create a new 2D array
board = Array.new($board_height) {Array.new($board_width)}
# Each element will be assigned a random value from 'colours'
# That is done by choosing a random index of the 'colours' array
(0...$board_height).each do |row|
(0...$board_width).each do |cell|
board[row][cell] = $colours[rand(6)]
end
end
# Return board
return board
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_board(width, height)\n #array with all possible colors\n colors = [:red, :blue, :green, :yellow, :cyan, :magenta]\n\n board = Array.new(height)\n (0..height-1).each do |i|\n board[i] = Array.new(width)\n (0..width-1).each do |j|\n board[i][j] = colors.sample\n end\n end\n\n return board\nend",
"def get_board(width, height)\n #Here i have created a 2d array which will contain the contents of the board\n board = Array.new(height) { Array.new(width, ' ')}\n \n #Loops through the rows and columns of the board array and creates a random number which is used to set the colour of each position \n #in the board array to one of the 6 random colours\n (0..height-1).each do |row|\n\t(0..width-1).each do |column| \n\t rand_num = rand(1..6)\n\t if rand_num == 1 then\n\t\tboard[row][column] = :red\n\t elsif rand_num == 2 then\n\t\tboard[row][column] = :blue\n\t elsif rand_num == 3 then\n\t\tboard[row][column] = :cyan\n elsif rand_num == 4 then\n\t\tboard[row][column] = :magenta\n elsif rand_num == 5 then\n\t\tboard[row][column] = :green\n\t elsif rand_num == 6 then\n\t\tboard[row][column] = :yellow\n\t end \n\tend\n end\n return board\nend",
"def get_board(width, height)\n # Create a 2d array the size of the board\n board = Array.new(height) { Array.new(width) }\n colors = [:red, :blue, :green, :yellow, :cyan, :magenta]\n\n # Loop through each square of the board\n (0...height).each do |row|\n (0...width).each do |column|\n # Get a random color symbol\n random_color = colors[rand 0...colors.length]\n\n # Set the value of the square to the random color symbol\n board[row][column] = random_color\n end\n end\n\n # Return the 2d array of random color symbols\n return board\nend",
"def get_board(width,height,finished_game_counter,current_score)\n board = Array.new(height) { Array.new(width, 0)}\n (0..(height-1)).each do |row|\n (0..(width-1)).each do |column| \n \n #generate a random number between 1 and 6 inclusive, in order to create an array\n #of randomly coloured fields\n array_element = rand(1..6)\n \n #allocates a number to each colour\n if array_element == 1 \n board[row][column] = :red\n elsif array_element == 2\n board[row][column] = :green\n elsif array_element == 3\n board[row][column] = :blue\n elsif array_element == 4\n board[row][column] = :yellow\n elsif array_element == 5\n board[row][column] = :magenta\n elsif array_element == 6\n board[row][column] = :cyan\n end\n end\n end\n \n #sets count to 0\n count = 0\n choose_colour(board,width,height,count,finished_game_counter,current_score)\nend",
"def get_board(width, height)\n boardChange = Array.new(height){Array.new(width)}\n (0..height - 1).each do |i|\n (0..width - 1).each do |j|\n boardChange[i][j] = getRandomColor\n end \n end\n return boardChange\nend",
"def populate_board\n rows_of_pieces = (size - 2) / 2\n make_pieces([0, 1], 'red', rows_of_pieces, 1)\n make_pieces([size - 1, 0], 'black', rows_of_pieces, -1)\n end",
"def random_colors\n color_array = []\n 4.times {color_array.push @colors.sample}\n color_array\n end",
"def all_pieces_on_board(colour)\n pos_array = []\n @board.each_with_index do |row, row_idx|\n row.each_with_index do |square, square_idx|\n pos_array << [row_idx, square_idx] if @white_pieces.any?(square) && colour == 'white'\n pos_array << [row_idx, square_idx] if @black_pieces.any?(square) && colour == 'black'\n end\n end\n pos_array\n end",
"def image_board\n\t\t(0...@width).map do |i|\n\t\t\t(0...@height).map do |j|\n\t\t\t\t# ([1]*3+[0]*7)[rand 10]\n\t\t\t\trand 2\n\n\n\t\t\t\t# rand 2\n\t\t\tend\n\t\tend\n\tend",
"def new_board\n board = []\n 8.times do |row|\n board << case row\n when 0\n add_back_row(\"white\", row)\n when 1\n add_pawn_row(\"white\", row)\n when 6\n add_pawn_row(\"black\", row)\n when 7\n add_back_row(\"black\", row)\n else\n Array.new(8)\n end\n end \n board\n end",
"def board\n @board ||= Array.new(HEIGHT) { Array.new(WIDTH) { [true, false].sample } }\n end",
"def create_board\n (1..(@width * @width).to_i).each do |i|\n values = i <= @amount_mines ? @bomb : @empty\n @board.push({\n value: values,\n revealed?: false\n })\n end\n @board.shuffle!\n @board\n end",
"def computer_color\n\t valid_colors = [\"r\", \"y\", \"b\", \"w\", \"c\", \"g\"] \n\t return [valid_colors[rand(0..5)],valid_colors[rand(0..5)], valid_colors[rand(0..5)], valid_colors[rand(0..5)]]\n\tend",
"def populate_board\n back_row = [Rook, Knight, Bishop, Queen, King, Bishop, Knight, Rook]\n\n black_back_row = []\n back_row.each_with_index do |piece_class, j|\n black_back_row << piece_class.new(self, :black, [0, j])\n end\n board[0] = black_back_row\n \n black_front_row = []\n (0..7).each {|idx| black_front_row << Pawn.new(self, :black, [1, idx])}\n board[1] = black_front_row\n \n (2..5).each do |row|\n board[row] = Array.new(8) {NullPiece.instance} \n end\n \n white_front_row = []\n 8.times {|idx| white_front_row << Pawn.new(self, :white, [6, idx])}\n board[6] = white_front_row\n \n white_back_row = []\n back_row.each_with_index do |piece_class, j|\n white_back_row << piece_class.new(self, :white, [7, j])\n end\n board[7] = white_back_row\n end",
"def starting_board\n init_rows([0, 2], :black)\n init_rows([5, 7], :red)\n end",
"def random_black_piece\n pieces = @data.flatten(1).compact\n black_pieces = pieces.select do |piece|\n next unless piece.color == :black\n\n piece.moves.size.positive? || piece.captures.size.positive?\n end\n location = black_pieces.sample.location\n { row: location[0], column: location[1] }\n end",
"def random_chess_board_square\n\t# chessboard_array =[]\n\t# \"a\".upto(\"h\") do |letter|\n\t# 1.upto(8) do |number|\n\t# chessboard_array << \"#{letter}#{number}\"\n\t# end\n\t# end\n\t chessboard_array = [\"a1\", \"a2\", \"a3\", \"a4\", \"a5\", \"a6\", \"a7\", \"a8\", \"b1\", \"b2\", \"b3\", \"b4\", \"b5\", \"b6\", \"b7\", \"b8\", \"c1\", \"c2\", \"c3\", \"c4\", \"c5\", \"c6\", \"c7\", \"c8\", \"d1\", \"d2\", \"d3\", \"d4\", \"d5\", \"d6\", \"d7\", \"d8\", \"e1\", \"e2\", \"e3\", \"e4\", \"e5\", \"e6\", \"e7\", \"e8\", \"f1\", \"f2\", \"f3\", \"f4\", \"f5\", \"f6\", \"f7\", \"f8\", \"g1\", \"g2\", \"g3\", \"g4\", \"g5\", \"g6\", \"g7\", \"g8\", \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"h7\", \"h8\"]\n\t # p chessboard_array.sample\n\t # print \"\\n\"\n\tchessboard_array.sample\n end",
"def generate_boogle_board_random(dim=4)\n chars = (\"A\"..\"Z\").to_a # to array\n (0...dim).map{\n (0...dim).map {\n chars[rand(chars.length - 1)] # will append the alphabet in matrix\n # rand_alpha = chars[rand(chars.length - 1)]\n # if rand_alpha == 'Q'\n # 'Qu'\n # else\n # rand_alpha\n # end\n }\n }\n end",
"def print_board(board)\n height = board.length\n width = board[0].length\n\n # Loop through each square of the board\n (0...height).each do |row|\n (0...width).each do |column|\n # Print a square the color of the array element's' value\n print \" \".colorize( :background => board[row][column])\n end\n\n # Print a new line every row\n puts\n end\nend",
"def moves_for(player_color)\n moves = Array.new\n board.each_with_keys do |x, y, value|\n if value.eql?(player_color)\n moves.concat generate_for(x,y)\n end\n end\n moves\n end",
"def create_board\n cols = Array.new(7) { Array.new(6, 0) }\n cols\n end",
"def board_creator\n def row_gen\n [rand(16), rand(15..31), rand(30..46), rand(45..61), rand(60..76)]\n end\n [row_gen,row_gen,[rand(16), rand(16..30), 'X', rand(46..60), rand(61..75)],row_gen,row_gen].each { |row| p row.join ' ' }\nend",
"def board_generator\n ref_array = ref_array_generator().shuffle(random: Random.new(self.seed))\n board = []\n count = 0\n row = -1\n area = self.height * self.width\n \n while count < area do\n if count % self.width == 0\n board.push([0,ref_array.pop(),0])\n row += 1\n else\n board[row].insert(1,ref_array.pop())\n end\n count += 1\n end\n \n border = [0,0]\n self.width.times do\n border.push(0)\n end\n board.unshift(border)\n board.push(border)\n\n board = border_slicer(tile_number_generator(board))\n \n return board\n end",
"def generateBoard()\n board = []\n\n (1..@board.rows).each do |r|\n row = []\n (1..@board.cols).each { |c| row.push('X') }\n board.push(row)\n end\n\n board\n end",
"def back_rows(color)\n back_pieces = [Rook, Knight, Bishop, Queen, King, Bishop, Knight, Rook]\n i = (color == :white) ? 7 : 0\n\n back_pieces.each_with_index do |piece, j|\n @grid[i][j] = piece.new(color, [i, j], @grid)\n end\n end",
"def setup_random\n @blocks = Array.new(ROWS) do\n Array.new(COLUMNS) { rand(COLOR_TABLE.size) }\n end\n end",
"def mexican_blanket_magic(colours)\n ptr = -1\n pattern = []\n colours.size.times do\n # Next 10 lines build the gradient\n 5.times { pattern[ptr += 1] = colours[0] }\n pattern[ptr+=1] = colours[1]\n\n 4.times { pattern[ptr+=1] = colours[0] }\n 2.times { pattern[ptr+=1] = colours[1] }\n\n 3.times { pattern[ptr+=1] = colours[0] }\n 3.times { pattern[ptr+=1] = colours[1] }\n\n 2.times { pattern[ptr+=1] = colours[0] }\n 4.times { pattern[ptr+=1] = colours[1] }\n\n pattern[ptr+=1] = colours[0]\n 5.times { pattern[ptr+=1] = colours[1] }\n\n # This is our black stripe which divides the gradients\n n = rand(100)\n if n <= 20 # Aprox. 20% chance of 3px wide line\n 3.times { pattern[ptr+=1] = \"black\" }\n elsif n >= 80 # Aprox. 20% chance of 7px wide line\n 7.times { pattern[ptr+=1] = \"black\" }\n end # Aprox. 60% chance of no line\n\n # Aprox. 20% chance we will get a diagonal bar\n # of random colour and size (<= 21px)\n if rand(100) < 20\n clr = colours[rand(colours.size)]\n (rand(20)+1).times { pattern[ptr+=1] = clr }\n end\n\n # Rotate through the colours in order\n cs = colours.shift\n colours.push(cs)\n end\n\n # Pad out the pattern to match image width\n ptr = -1\n while pattern.size < COLUMNS\n pattern << pattern[ptr+=1]\n end\n return pattern\nend",
"def display\n board.flatten.map { |stone| stone&.color }\n end",
"def gen_board\n\n (\"A\"..\"I\").each do |row|\n (0..8).each_with_index { |column, value| @board.merge!( { \"#{row}#{column}\".to_sym => @board_array.shift.to_i } ) }\n end\n return @board\n end",
"def random_colors\n colors = [\"blue\",\"red\",\"green\",\"black\",\"yellow\",\"pink\",\"white\",\"grey\"]\n color = colors[rand(colors.length)]\nend",
"def game_solution\n @solution << @colors.map do |color|\n @colors.sample\n end\n end",
"def code\n colors = Game::COLORS.shuffle\n print colors\n# empty array that will become the generated code\n generated_code = []\n \n# i think it 4 times will pop off the shuffled colors and add it to the end\n# of the generated code array\n 4.times{ generated_code << colors.pop }\n generated_code\n end",
"def display_board(board)\n (0..board.length - 1).each do |i|\n (0..board[i].length - 1).each do |j|\n print \" \".colorize(:background => board[i][j])\n end\n puts\n end\nend",
"def generate_list\n n = @screen_dim[:cols] / (4 + Canvas::MARGIN)\n (1..n).to_a.shuffle\n end",
"def create_board(size)\n return (0...size).map{|b| (0...size).map{|bb| 0}}\n end",
"def generate_boggle_board_hasbro(dim=4)\n shuffled = DICE_CONFIG.shuffle!()\n # shuffled = shuffled.shuffle!()\n (0...dim).map do |i|\n (0...dim).map{ |j|\n letters = shuffled[dim * i + j]\n letters[rand(letters.length)] # will append the alphabet in matrix\n # random_char = letters[rand(letters.length)]\n # if random_char == 'Q'\n # 'Qu'\n # else\n # random_char\n # end\n }\n end\n end",
"def show_board\n @grid.each_with_index do |row, row_index|\n row.each_with_index do |square, col_index|\n piece = self[row_index, col_index]\n if row_index.even? && col_index.even?\n print \" #{piece.display} \".colorize( :color => :black, :background => :white ) if (piece && piece.color == :black)\n print \" #{piece.display} \".colorize( :color => :red, :background => :white ) if (piece && piece.color == :red)\n print \" \".colorize( :background => :white ) if piece.nil?\n elsif row_index.even? && col_index.odd? \n print \" #{piece.display} \".colorize( :color => :black, :background => :light_white ) if (piece && piece.color == :black)\n print \" #{piece.display} \".colorize( :color => :red, :background => :light_white ) if (piece && piece.color == :red)\n print \" \".colorize( :background => :light_white ) if piece.nil?\n elsif row_index.odd? && col_index.even? \n print \" #{piece.display} \".colorize( :color => :black, :background => :light_white ) if (piece && piece.color == :black)\n print \" #{piece.display} \".colorize( :color => :red, :background => :light_white ) if (piece && piece.color == :red)\n print \" \".colorize( :background => :light_white ) if piece.nil?\n elsif row_index.odd? && col_index.odd?\n print \" #{piece.display} \".colorize( :color => :black, :background => :white ) if (piece && piece.color == :black)\n print \" #{piece.display} \".colorize( :color => :red, :background => :white ) if (piece && piece.color == :red)\n print \" \".colorize( :background => :white ) if piece.nil?\n end\n end\n puts \"\"\n end\n end",
"def generate_board\n [0, 1, 2].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]] = Piece.new([row, col], self, :B) if offset.odd?\n end\n end\n\n [5, 6, 7].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]] = Piece.new([row, col], self, :W) if offset.odd?\n end\n end\n end",
"def board_generator\r\n y = Array.new(8)\r\n y.each_index {|i| y[i] = Array.new(8)}\r\n end",
"def build_board(choices)\n line = []\n board = []\n 0.upto(choices.length) do |i|\n line << fig(choices[i], i + 1)\n if ((i + 1) % 3).zero?\n board << line\n line = []\n end\n end\n board\n end",
"def setup_easier\n (1...ROWS).each do |row|\n (1...COLUMNS).each do |col|\n set_neighbour_colour(col, row) if rand(-1...COLOR_TABLE.size) == -1\n end\n end\n end",
"def choose_colour(board,width,height,count,finished_game_counter,current_score)\n \n #prints the array\n board.each do |row|\n row.each do |column| \n \n #the field is coloured according to the element in the array \n if column == :red\n \n #prints the element as two space characters with a coloured background\n print column = \" \".colorize(:background => :red)\n elsif column == :green\n print column = \" \".colorize(:background => :green)\n elsif column == :blue\n print column = \" \".colorize(:background => :blue)\n elsif column == :yellow\n print column = \" \".colorize(:background => :yellow)\n elsif column == :magenta\n print column = \" \".colorize(:background => :magenta)\n elsif column == :cyan\n print column = \" \".colorize(:background => :cyan)\n end \n end\n puts\n end\n \n #display number of turns\n print \"Number of turns: \"\n turns(count)\n \n #display percentage completed\n print \"Current completion: \"\n completion(board,width,height,count,finished_game_counter,current_score)\n \n #gets user input r,g,y,b,c,m and increases count by one\n print \"Choose a colour: \"\n user_colour = gets.chomp.downcase\n count = count + 1\n \n #the user_colour variable will be set , depending on the user input\n if user_colour == \"r\"\n user_colour = :red\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"g\"\n user_colour = :green\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"b\"\n user_colour = :blue\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"y\"\n user_colour = :yellow\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"m\"\n user_colour = :magenta\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"c\"\n user_colour = :cyan\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n \n #if user types q, he will return to the main menu\n elsif user_colour == \"q\"\n main_menu(width,height,current_score,finished_game_counter)\n end\nend",
"def populate_grid\n start_rows = { red: (0..2), black: (5..7) }\n\n 8.times do |x|\n 8.times do |y|\n [:red, :black].each do |color|\n if (x + y).even? && start_rows[color].include?(y)\n self[[x, y]] = Piece.new(color, [x, y], self)\n end\n end\n end\n end\n\n grid.each_with_index do |row, y|\n row.each_with_index do |cell, x|\n puts \"x=#{x}, y=#{y}, cell.class=#{cell.class}\"\n end\n end\n end",
"def generate_code\n a = []\n 4.times do\n a.push(@@COLORS.sample)\n end\n a\n end",
"def draw_board\n # first, it updates the @board variables to get the current state of each case\n @board = [[@case_a1.case, @case_b1.case, @case_c1.case], [@case_a2.case, @case_b2.case, @case_c2.case], [@case_a3.case, @case_b3.case, @case_c3.case]]\n\n # then prints beautifully the board\n print \"\\n\" + \"=\".red * 33 + \"\\n\"\n print \"|| \".red + \" | \" + \" A | B | C \" + \" ||\".red + \"\\n\"\n print \"||\".red + \"_____\" + \"|_\" + \"______|_______|_______\" + \"||\".red + \"\\n\"\n print \"|| \".red + \" | \" + \" ||\".red\n print \"\\n\" + \"||\".red + \" 1 | #{@board[0][0]} | #{@board[0][1]} | #{@board[0][2]} \" + \" ||\".red + \"\\n\"\n print \"||\".red + \"_\" * 5 + \"| \" + \" ___ ___ ___\" + \" ||\".red + \"\\n\"\n print \"|| \".red + \" | \" + \" ||\".red\n print \"\\n\" + \"||\".red + \" 2 | #{@board[1][0]} | #{@board[1][1]} | #{@board[1][2]} \" + \" ||\".red + \"\\n\"\n print \"||\".red + \"_\" * 5 + \"| \" + \" ___ ___ ___\" + \" ||\".red + \"\\n\"\n print \"|| \".red + \" | \" + \" ||\".red\n print \"\\n\" + \"||\".red + \" 3 | #{@board[2][0]} | #{@board[2][1]} | #{@board[2][2]} \" + \" ||\".red + \"\\n\"\n print \"=\".red * 33 + \"\\n\"\n end",
"def get_board_colors(game)\n board_colors = {}\n [1,2,3,4,5,6,7,8,9,10,11,12].each do |num|\n ['A','B','C','D','E','F', 'G','H','I'].each do |letter|\n cell = (num.to_s + letter)\n board_colors[cell] = 'none'\n end\n end \n \n placed_tiles = game.game_tiles.where(placed: true)\n placed_tiles.each do |game_tile|\n hotel = game_tile.hotel\n color = game.get_hotel_color(hotel)\n board_colors[game_tile.cell] = color\n end\n\n board_colors\n end",
"def board_creator()\n board = []\n 10.times do |x|\n board << Array.new\n 10.times do |y|\n board[x] << \"sea #{x} #{y}\"\n end\n end\n return board\nend",
"def random_guess\n return Colors.sample(4)\n end",
"def square_arrays\n squares = []\n org_row = 0\n org_col = 0\n (0..8).each do |i|\n squares[i] = []\n (org_row..org_row+2).each do |k|\n (org_col..org_col+2).each do |j|\n squares[i].push(@board[k][j])\n end \n end\n if org_row == 6\n org_col += 3 \n org_row = 0\n else\n org_row += 3 \n end\n end \n squares\n end",
"def pawn_rows(color)\n i = (color == :white) ? 6 : 1\n\n @grid[i].each.with_index do |el, j|\n @grid[i][j] = Pawn.new(color, [i, j], @grid)\n end\n end",
"def create_grid\n grid = Array.new(8) { Array.new(8) { [] } }\n grid.map! do |row|\n if grid.index(row).even?\n row.each { |space| row.index(space).even? ? space << 'white' : space << 'black' }\n else\n row.each { |space| row.index(space).even? ? space << 'black' : space << 'white' }\n end\n row.map! do |space|\n space << [grid.index(row), row.index(space)]\n end\n end\n grid.reverse\n end",
"def generate_random_color\n COLORS[rand(6)]\n end",
"def sample_board\n\t\t puts \"\\n\\n1|2|3\"\n\t\t puts \"-----\"\n\t\t puts \"4|5|6\"\n\t\t puts \"-----\"\n\t\t puts \"7|8|9\"\n\t\tend",
"def display_board(board)\n colors=board\n r=\"-----------\"\n puts \" #{colors[0]} | #{colors[1]} | #{colors[2]} \"\n puts r\n puts \" #{colors[3]} | #{colors[4]} | #{colors[5]} \"\n puts r\n puts \" #{colors[6]} | #{colors[7]} | #{colors[8]} \"\nend",
"def tile_board\n @board_array.each_with_index do |row_array, row|\n 10.times{|column| row_array << Tile.new(row,column)}\n end\n end",
"def newBoard\n\t\t\t[['r', 'n', 'b', 'k', 'q', 'b', 'n', 'r'],\n\t\t\t ['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p'],\n\t\t\t ['', '', '', '', '', '', '', ''],\n\t\t\t ['', '', '', '', '', '', '', ''],\n\t\t\t ['', '', '', '', '', '', '', ''],\n\t\t\t ['', '', '', '', '', '', '', ''],\n\t\t\t ['P', 'P', 'P', 'P', 'P', 'P', 'P', 'P'],\n\t\t\t ['R', 'N', 'B', 'K', 'Q', 'B', 'N', 'R']]\n\tend",
"def make_board\n board = Array.new(8) { Array.new(8) { Array.new(2) } }\n board.each_with_index do |row, row_i|\n row.each_with_index { |column, column_i| column[0], column[1] = row_i, column_i }\n end\n end",
"def gen_color()\n random = Random.new\n\n colorname = Array.new(9)\n colorname = [ 'red', 'blue', 'lightblue', 'pink', 'gold', 'white', 'yellow', 'green', 'lightgreen', 'orange', 'grey', 'black' ]\n\n return colorname[random.rand(9)]\nend",
"def start_hexes(color)\n squares = []\n @size.times do |index|\n if color == :red\n squares << [0, index] if self[[0, index]] == :red\n else\n squares << [index, 0] if self[[index, 0]] == :blue \n end \n end\n squares\n end",
"def blacks\n matrix.select { |piece| piece && piece.color == :b }\n end",
"def create_grid(board_array)\n\t# split into triplets\n\ttriplets_array = []\n board_array.each { |array| triplets_array << array.each_slice(3).to_a }\n\n # shuffle the triplets\n shuffle_container = [[], [], []]\n 9.times do |row|\n 3.times do |column|\n current_array = triplets_array[row][column]\n shuffle_container[column] << current_array\n end\n end\n\n # flatten and re-split\n final_array = []\n shuffle_container.flatten.each_slice(9) { |array| final_array << array }\n\n return final_array\nend",
"def code_generator(colors, length)\n answer = Array.new(length).map do\n colors.sample\n end.join\n end",
"def initialize()\n @board = {}\n colors = [Square::BLACK, Square::WHITE]\n \n (1..8).each do |row|\n (1..8).each do |col|\n sq = Square.new(colors[0])\n\n # Place starting pieces on board\n if (1..3).include?(row) && sq.color == Square::BLACK\n sq.checker_piece = Piece.new(Piece::BLACK)\n elsif (6..8).include?(row) && sq.color == Square::BLACK\n sq.checker_piece = Piece.new(Piece::RED)\n end\n \n @board[[row,col]] = sq\n \n colors << colors.delete_at(0) unless col == 8\n end\n end\n end",
"def bit_board(color)\n @board.map { |row|\n row.map { |cell| ROAD[color].include?(cell.last) ? 1 : 0 }\n }\n end",
"def add_random_color\n seq << COLORS.sample\n end",
"def populate_board(board)\n #Fills in the top and bottom rows\n [0, 7].each do |row|\n 4.times do |col|\n board[row][col] = create_piece(row, col)\n board[row][(7-col)] = create_piece(row, (7-col))\n end\n end\n\n #Fills in the pawns\n 8.times do |col|\n board[1][col] = BlackPawn.new(1, col)\n board[6][col] = WhitePawn.new(6, col)\n end\n\n board\n end",
"def initialize()\n @board = {}\n colors = [Square::BLACK, Square::WHITE]\n\n (1..8).each do |row|\n (1..8).each do |col|\n\n # Place starting pieces on board\n if (1..3).include?(row) && Square.new(colors[0]).color == Square::BLACK\n Square.new(colors[0]).checker_piece = Piece.new(Piece::BLACK)\n elsif (6..8).include?(row) && Square.new(colors[0]).color == Square::BLACK\n Square.new(colors[0]).checker_piece = Piece.new(Piece::RED)\n end\n\n @board[[row,col]] = Square.new(colors[0])\n\n colors << colors.delete_at(0) unless col == 8\n end\n end\n end",
"def initialize_board\n init_board = \"-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1\"\n if self.update(board: init_board)\n return [[ 0,-1,0,-1,0,-1, 0,-1 ],[-1,0,-1,0,-1,0,-1,0],[0,-1,0,-1,0,-1,0,-1],\n [0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],\n [1,0,1,0,1,0,1,0],[0,1,0,1,0,1,0,1],[1,0,1,0,1,0,1,0]]\n end\n end",
"def board_2d\n # slice the array into groups of 4 to create 2d-array\n @board.enum_slice(4).to_a\n end",
"def create\n (0..7).each do |row|\n @board << []\n (0..7).each do |col| \n @board[row] << \"[ ]\"\n end\n end\n end",
"def board_new\n\t\n\t@board1 = [1, 2, 3]\n\t@board2 = [4, 5, 6]\n\t@board3 = [7, 8, 9]\n\t@board_index = [@board1, @board2, @board3]\n\n\n\tputs \"| #{@board_index [0] [0]} | #{@board_index [1] [0]} | #{@board_index [2] [0]} |\"\n\tputs \"| #{@board_index [0] [1]} | #{@board_index [1] [1]} | #{@board_index [2] [1]} |\"\n\tputs \"| #{@board_index [0] [2]} | #{@board_index [1] [2]} | #{@board_index [2] [2]} |\"\n\treturn @board_index\nend",
"def _get_board_rows()\n array_of_rows = []\n sudoku_board.each { |row| array_of_rows << row }\n end",
"def create_code\n code = []\n 4.times do\n code << Mastermind.show_colors[rand(0..7)]\n end\n code\n end",
"def build_first_row(board)\n (0..7).each do |col|\n if col.zero?\n board[1][col] = BoardSquare.new('cyan', Rook.new('white'), 1)\n elsif col == 7\n board[1][col] = BoardSquare.new('magenta', Rook.new('white'))\n elsif col == 1\n board[1][col] = BoardSquare.new('magenta', Knight.new('white'))\n elsif col == 6\n board[1][col] = BoardSquare.new('cyan', Knight.new('white'))\n elsif col == 2\n board[1][col] = BoardSquare.new('cyan', Bishop.new('white'))\n elsif col == 5\n board[1][col] = BoardSquare.new('magenta', Bishop.new('white'))\n elsif col == 3\n board[1][col] = BoardSquare.new('magenta', King.new('white'))\n elsif col == 4\n board[1][col] = BoardSquare.new('cyan', Queen.new('white'))\n end\n end\n board\n end",
"def random_color\n return Color.new(random(COL_DEP), random(COL_DEP), random(COL_DEP), 255)\nend",
"def computer_code_acquisition\n @code_length.times.map { @colors.sample }\n end",
"def build_board\n @original_board\n @working_board.collect! { |row|\n row.collect! { |cell|\n cell = @original_board.shift\n }\n }\n @working_board\n end",
"def display_board\n row_idx = -1\n numera = [1,2,3,4,5,6,7,8,9]\n @display = @grid.map do |row|\n \n col_idx = -1\n row_idx += 1 \n row.map do |col| \n col_idx += 1 \n if @flag_pair.include? ((row_idx.to_s) + (col_idx.to_s))\n col = 'F'.orange\n elsif col == :B\n col = 'H'.green\n elsif (@known_empty.include? ((row_idx.to_s) + (col_idx.to_s))) && (numera.include? col)\n col = col.to_s.red\n elsif @known_empty.include? ((row_idx.to_s) + (col_idx.to_s))\n col = 'O'.blue\n else\n col = 'H'.green\n end \n end \n end\n end",
"def print_board\n 6.times do |y|\n y = 5 - y # To print from top to bottom\n 7.times do |x|\n if @board[[x, y]] == nil\n x == 6 ? (puts \"( )\") : (print \"( )\")\n else\n # Prints only the 3 first letters of each color to keep board alignment\n x == 6 ? (puts \"(#{@board[[x, y]].color[0, 3]})\") : (print \"(#{@board[[x, y]].color[0, 3]})\")\n end\n end\n end\n end",
"def choose_code\r\n @code = []\r\n 4.times do\r\n @code.push($possible_color[(rand(0..5))])\r\n end\r\n @code\r\n end",
"def generate\n (0..@horizontal_size-1).each do |column|\n (0..@vertical_size-1).each do |row|\n val = Settings.get_random.rand(0..10)\n @map[column][row] = val > 3 ? 1 : 2\n end\n end\n end",
"def sample_board\n\tputs \" 1 | 2 | 3\"\n puts \"-----------\"\n puts \" 4 | 5 | 6\"\n puts \"-----------\"\n puts \" 7 | 8 | 9\"\n\tend",
"def visualize_array\n(0...ROWS).each { |row|\n (0...COLS).each { |col|\n print row.to_s + \" \" + col.to_s + \" \"\n print \"(\" + (COLS*row + col).to_s + \") \" # index into board array\n }\n puts\n}\nend",
"def random_cell(array)\n cell_sel = array.sample\n\n # Keep choosing random cells until one is empty.\n until board.board_hash[cell_sel].empty? do\n cell_sel = array.sample\n end\n cell_sel\n end",
"def create_board\n temp_index = 0\n temp_column1 = Array.new(4) { 'O' }\n temp_column2 = Array.new(4) { 'O' }\n @board = []\n 10.times do\n @board << [temp_column1, temp_column2, \"Turn:#{temp_index += 1}\"]\n end\n @board\n end",
"def initialize\n @board = Array.new(3) { Array.new(3) }\n end",
"def initialize\n @board = Array.new(3) { Array.new(3) }\n end",
"def setup_mans(row,color)\n 3.times do\n @grid[row].each_index do |col|\n Piece.new(self, [row,col], color) if (row+col).odd?\n end\n row += 1\n end\n end",
"def row(shape, y)\n n, col = 16, %w(firebrick darkorange white saddlebrown black).shuffle\n (1..n - 1).each do |x|\n col.rotate! # cycle through the colors\n (options = shape.options.clone)[:fill] = col[0]\n (s = shape.clone).options = options\n canvas << s.move(@width / n * x, y)\n end\nend",
"def new_board\n @board = {'a1'=>' ','a2'=>' ','a3'=>' ','b1'=>' ','b2'=>' ','b3'=>' ','c1'=>' ','c2'=>' ','c3'=>' '}\n end",
"def pick_hair_color\n # colors = ['Blonde', 'Silver', 'Periwinkle',\n # 'Pink', 'Teal', 'Green', 'Light Green',\n # 'Blue', 'Light Blue',\n # 'Red', 'Dark Red']\n\n ## only use \"darker\" colors - why? why not?\n colors = [ 'Purple',\n 'Orange', 'Red', 'Dark Red']\n\n colors[ rand( colors.size ) ]\nend",
"def chess_board(board)\n pieza = [ \"T-\", \"H-\", \"B-\", \"Q-\", \"K-\", \"B-\", \"H-\", \"T-\" ]\n color = [\"W\", \"B\"]\n peon = [\"P-\", \"P-\", \"P-\", \"P-\", \"P-\", \"P-\", \"P-\", \"P-\"]\n \n\n for i in 0..7\n for j in 0..7 \n if i == 0 \n (board[i][j] = pieza[j] + color[0])\n elsif i == 1 \n board[i][j] = peon[j] + color[0] \n elsif i == 6 \n board[i][j] = peon[j] + color[1] \n elsif i == 7 \n board[i][j] = pieza[j] + color[1] \n elsif i == 2..5 \n board[i][j] = \" * \" \n end \n end \n end\n board.each do |x|\n puts \"#{x}\"\n end \nend",
"def print_board(array)\n system('cls')\n puts\n puts \"\\033[33m 1 2 3 4 5 6 7 8 \\033[0m\"\n array.each do |row|\n puts\"\\033[33m│\\033[0m #{(row.join\" \\033[33m││\\033[0m \")} \\033[33m│\\033[0m\"\n puts \"#{\"\\033[33m╞---╡\\033[0m\"*row.count}\"\n end\n puts \"\\033[33m╘─-─╛╘─-─╛╘─-─╛╘─-─╛╘─-─╛╘─-─╛╘─-─╛╘─-─╛\\033[0m\"\nend",
"def populate_board\n #the six rows get updated\n players.each do |player|\n rows = player == players[0] ? [ 0,1,2 ] : [ 5,6,7 ]\n piece_count = 0\n col = 0\n\n player.pieces.each do |piece|\n\n rows.shift if piece_count % 4 == 0 and piece_count != 0\n\n col_start = rows[0] % 2 == 1 ? 0 : 1\n col = 0 if (col_start == 0 || col_start == 1) && piece_count % 4 == 0\n\n piece.position = [col + col_start, rows[0]]\n squares[[col + col_start, rows[0]]] = piece\n\n col += 2\n piece_count += 1\n\n end\n\n end\n\n end",
"def setup_grid\n empty_rows\n [:white, :light_yellow].each do |color|\n back_rows(color)\n pawn_rows(color)\n end\n end",
"def populate_board\n\t\t8.times{|x|\t@board[x][6] = Pawn.new([x, 6], \"black\", @board)}\n\t\t@board[0][7] = Rook.new([0, 7], \"black\", @board)\t\n\t\t@board[1][7] = Knight.new([1, 7], \"black\", @board)\n\t\t@board[2][7] = Bishop.new([2, 7], \"black\", @board)\n\t\t@board[3][7] = Queen.new([3, 7], \"black\", @board)\n\t\t@board[4][7] = King.new([4, 7], \"black\", @board)\t\t\n\t\t@board[5][7] = Bishop.new([5, 7], \"black\", @board)\n\t\t@board[6][7] = Knight.new([6, 7], \"black\", @board)\n\t\t@board[7][7] = Rook.new([7, 7], \"black\", @board)\n\t\t\t\t\n\t\t 8.times{|x|\t@board[x][1] = Pawn.new([x, 1], \"white\", @board)}\n\t\t@board[0][0] = Rook.new([0, 0], \"white\", @board)\t\n\t\t@board[1][0] = Knight.new([1, 0], \"white\", @board)\n\t\t@board[2][0] = Bishop.new([2, 0], \"white\", @board)\n\t\t@board[3][0] = Queen.new([3, 0], \"white\", @board)\n\t\t@board[4][0] = King.new([4, 0], \"white\", @board)\t\t\n\t\t@board[5][0] = Bishop.new([5, 0], \"white\", @board)\n\t\t@board[6][0] = Knight.new([6, 0], \"white\", @board)\n\t\t@board[7][0] = Rook.new([7, 0], \"white\", @board)\n\tend",
"def team_pieces(color)\n \tteam_spaces = []\n \t(0..7).each do |x|\n \t\t(0..7).each do |y|\n \t\t\tteam_spaces << @board[x][y] if @board[x][y].piece != nil && @board[x][y].piece.color == color\n \t\tend\n \tend\n \tteam_spaces.flatten\n end",
"def get_board\n board = @driver.execute_script('''\n b = window.ThreesGame.grid.map(function(t) { return t.value; });\n return b\n ''')\n \n board = board.each_slice(4).to_a\n board\n end",
"def generate_board\n board_array = @board_string.split(\"\")\n @board = Array.new(9){board_array.shift(9)}\n for row in 0...@board.length\n for col in 0...@board.length\n @board[row][col] = Square.new(@board[row][col], row, col)\n end\n end\n create_starting_numbers\n @board\n end",
"def make_Fake_Map(num_rows, num_columns) \n random_row_index = (rand() * num_rows).to_i\n puts random_row_index\n random_column_index = (rand() * num_columns).to_i\n puts random_column_index\n \n fake_map_array = []\n\n count_row = 0\n\n while count_row < num_rows do \n row_array = []\n count_col = 0\n while count_col < num_columns do\n if (count_col == random_column_index && count_row == random_row_index) \n row_array.push(\"X\")\n else row_array.push(\"A\")\n end\n count_col +=1\n end\n count_row +=1\n fake_map_array.push(row_array)\n end\n\n p fake_map_array\nend"
] | [
"0.7755951",
"0.77496403",
"0.76519626",
"0.7622318",
"0.7169492",
"0.696025",
"0.68786216",
"0.667716",
"0.65812236",
"0.65675664",
"0.65639997",
"0.64597964",
"0.64535964",
"0.64436233",
"0.6436676",
"0.6432895",
"0.6426898",
"0.6418176",
"0.6403544",
"0.63710356",
"0.63389474",
"0.63113105",
"0.62878144",
"0.627794",
"0.6251393",
"0.62455434",
"0.6244168",
"0.62171936",
"0.62097436",
"0.61851203",
"0.6176176",
"0.61664575",
"0.6158518",
"0.61522424",
"0.61511415",
"0.61433214",
"0.6122297",
"0.61136204",
"0.60945094",
"0.6093444",
"0.60896206",
"0.6086344",
"0.6084782",
"0.6079436",
"0.60788995",
"0.6075717",
"0.60704386",
"0.6055956",
"0.60068834",
"0.60063386",
"0.59981275",
"0.5987035",
"0.59800094",
"0.59694195",
"0.5964322",
"0.59548503",
"0.5947329",
"0.5944061",
"0.59435564",
"0.5939789",
"0.59247065",
"0.5922912",
"0.5920812",
"0.58992416",
"0.58887297",
"0.5877145",
"0.58720595",
"0.58582836",
"0.584368",
"0.5839512",
"0.5836749",
"0.5830308",
"0.5829485",
"0.582662",
"0.5820453",
"0.58176905",
"0.5814191",
"0.5811728",
"0.58111995",
"0.58097196",
"0.579637",
"0.57955986",
"0.5794268",
"0.5793663",
"0.5787982",
"0.57703865",
"0.57703865",
"0.57689714",
"0.5767203",
"0.5764337",
"0.5758945",
"0.5753996",
"0.57530254",
"0.57505554",
"0.57486326",
"0.57461244",
"0.5740051",
"0.5738095",
"0.57331556",
"0.57316995"
] | 0.8066209 | 0 |
update_board method used to update the board after the user choose a new colours First the top left field is updated to the new colour For each neighbour field that has the same colour as the first field had before changing it, recursively update that field as well | def update_board(board,new_colour,old_colour,i,j)
# Update field colour
board[i][j]= new_colour
# Check if there is a neighbour on top and if that neighbour has the same colour as the previous colour
# If yes, then that neighbour is chosen to be updated in turn
if (i-1) >=0 && board[i-1][j] == old_colour
board = update_board(board,new_colour,old_colour,i-1,j)
end
# Check if there is a neighbour on the right and if that neighbour has the same colour as the previous colour
# If yes, then that neighbour is chosen to be updated in turn
if (j+1) < $board_width && board[i][j+1] == old_colour
board = update_board(board,new_colour,old_colour,i,j+1)
end
# Check if there is a neighbour on the buttom and if that neighbour has the same colour as the previous colour
# If yes, then that neighbour is chosen to be updated in turn
if (i+1) <$board_height && board[i+1][j] == old_colour
board = update_board(board,new_colour,old_colour,i+1,j)
end
# Check if there is a neighbour on the left and if that neighbour has the same colour as the previous colour
# If yes, then that neighbour is chosen to be updated in turn
if (j-1) >=0 && board[i][j-1] == old_colour
board = update_board(board,new_colour,old_colour,i,j-1)
end
# return board
return board
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def neighbour_update(board,width,height,next_colour,i,j,count,first_block,finished_game_counter,current_score)\n \n #if condition checking if field at i,j has the same colour as the top-left field\n if board[i][j] == first_block\n \n #checks if it is the correct element and changes its colour, (c == j ?) means (if c == j do)\n board[i].map!.with_index{|r,c| (c == j ? r = next_colour : r)}\n if i > 0 \n neighbour_update(board,width,height,next_colour,i-1,j,count,first_block,finished_game_counter,current_score)\n end\n if j > 0 \n neighbour_update(board,width,height,next_colour,i,j-1,count,first_block,finished_game_counter,current_score)\n end\n if i < height-1\n neighbour_update(board,width,height,next_colour,i+1,j,count,first_block,finished_game_counter,current_score)\n end\n if j < width-1 \n neighbour_update(board,width,height,next_colour,i,j+1,count,first_block,finished_game_counter,current_score)\n end\n end\n \n #calls choose_colour method for next user input\n choose_colour(board,width,height,count,finished_game_counter,current_score)\nend",
"def update_adjacent(board, column, row, new_color)\n # Get current color of square\n old_color = board[row][column]\n\n # Update color of square\n board[row][column] = new_color\n\n # Check is square ABOVE was the same color\n if row - 1 >= 0 && old_color == board[row-1][column]\n update_adjacent board, column, row - 1, new_color\n end\n\n # Check if the square to the RIGHT was the same color\n if column + 1 < board[0].length && old_color == board[row][column+1]\n update_adjacent board, column + 1, row, new_color\n end\n\n # Check if the square BELOW was the same color\n if row + 1 < board.length && old_color == board[row+1][column]\n update_adjacent board, column, row + 1, new_color\n end\n\n # Check if the square to the LEFT was the same color\n if column - 1 >= 0 && old_color == board[row][column-1]\n update_adjacent board, column - 1, row, new_color\n end\n\nend",
"def update(board, player_color, input_color, x, y)\n board[x][y] = input_color\n # Recursively call the function for all nearby positions\n if x < board.length - 1 && board[x + 1][y] == player_color\n update(board, player_color, input_color, x + 1, y)\n end\n if y < board[x].length - 1 && board[x][y + 1] == player_color\n update(board, player_color, input_color, x, y + 1)\n end\n if x > 0 && board[x - 1][y] == player_color\n update(board, player_color, input_color, x - 1, y)\n end\n if y > 0 && board[x][y - 1] == player_color\n update(board, player_color, input_color, x, y - 1)\n end\n\n return board\nend",
"def update()\n # Loops through each corrdinate of the board and asks it what\n # piece colour it has on it. print the piece colour to the screen.\n\n # A line connecting two spaces. This gets printed after a '|' in rows\n # that contain only these connecting lines (rows that cannot contain pieces)\n connection = \"\\\\\"\n\n # Board size is 9x5\n for i in (8).downto(0) do\n # If i is even, print number, and the pieces on the board.\n # Else: print a row of connecting lines\n if (i%2 == 0)\n # Print the number\n print (\"#{i/2} \")\n\n # Print the pieces on the board\n for j in 0..8 do\n piece = @current_board.get_board_hash(\"#{j},#{(i/2)}\") \n if (piece == :Black)\n print \"x\"\n elsif (piece == :White)\n print \"o\"\n else\n print \"+\"\n end\n\n if (j != 8)\n print \"-\"\n end\n end\n print \"\\n\"\n\n # print the connecting lines\n else\n print \" \"\n for j in 0..8 do\n # print a pair of connecting lines.\n # Rows do not end with a diagnol\n # connecting line. Print only\n # a \"|\" when that occurs\n if (j != 8)\n print \"|#{connection}\"\n else\n print \"|\"\n end\n\n # Toggle the diagonal connecting lines.\n # these lines do no toggle the final\n # time that they are printed in a row.\n if (j < 7)\n if (connection == \"\\\\\")\n connection = \"/\"\n else\n connection = \"\\\\\"\n end\n end\n end\n print \"\\n\"\n end\n end\n\n # Print the numbers column numbers at\n # the bottom of the board.\n print \" \"\n for i in 0..8\n print \" #{i}\"\n end\n print \"\\n\"\n end",
"def update_board\n #clear previous move_list from all pieces\n @board.each do |row|\n row.each do |col|\n col.move_list = [] if !col.nil?\n end\n end\n #clear previous state of @all_pieces\n @all_pieces = []\n #adds every piece obj to all_pieces instance variable\n @board.each do |row|\n row.each do |col|\n @all_pieces << col if !col.nil?\n end\n end\n #give each piece a copy of the board state\n #then allow generate_moves method to come up with a list of possible moves\n #based on that board state\n @all_pieces.each do |n|\n n.board = self\n n.generate_moves\n end\n #add this state to the board_history instance variable\n @board_history << @board\n end",
"def updateboard\n #scan through \n board_temp = []\n (0...@board.length).each do |iy|\n new_row = []\n (0...@board[iy].length).each do |ix|\n\n ## Following rules of Conway's GOL\n val = case neighbors([iy,ix])\n when 0, 1\n 0\n when 2\n @board[iy][ix]\n when 3 \n 1\n when 4,5,6,7,8\n 0 \n end\n new_row << val\n end\n board_temp << new_row\n end\n ## Replace board with new board, decided to use a new board because its \n ## confusing to update the existing board when considering neighbors\n @board = board_temp\n end",
"def board_update\n matrix.each do |row|\n row.each do |cell|\n cell.board_updates\n end\n end\n end",
"def populate_board\n rows_of_pieces = (size - 2) / 2\n make_pieces([0, 1], 'red', rows_of_pieces, 1)\n make_pieces([size - 1, 0], 'black', rows_of_pieces, -1)\n end",
"def setColors(boardGame, newColor, oldColor, i, j) \n #checks if the pointer is within the bounds of the array and the colour that needs to be replaced \n #but not the new colour as this can lead to a stackoverflow\n if (i >= 0 and i <= boardGame.length - 1) and (j >= 0 and j <= boardGame[i].length - 1) and (boardGame[i][j] == oldColor) and (newColor != oldColor) then \n boardGame[i][j] = setColors boardGame, newColor, oldColor, i - 1, j\n boardGame[i][j] = setColors boardGame, newColor, oldColor, i + 1, j\n boardGame[i][j] = setColors boardGame, newColor, oldColor, i, j + 1\n boardGame[i][j] = setColors boardGame, newColor, oldColor, i, j - 1 \n else\n return newColor\n end\nend",
"def update\n update_grid = Array.new(@grid_height) { Array.new(@grid_width, 0) }\n update_grid.each_index do |row|\n update_grid[row].each_index do |col|\n num_neighbours = get_num_neighbours col, row\n if (@grid[row][col] == 1 && num_neighbours.between?(2, 3)) ||\n (@grid[row][col] == 0 && num_neighbours == 3)\n update_grid[row][col] = 1\n end\n end\n end\n @grid = update_grid\n end",
"def update_board(column, color)\n @grid[column][bottom(column)] = Piece.new(color)\n end",
"def update start_row, start_col, end_row, end_col\n temp = @board[start_row][start_col]\n @board[start_row][start_col] = \"[ ]\"\n @board[end_row][end_col] = temp\n end",
"def update_view\n end_offsets = []\n color_sign = ((@color == :black) ? -1 : 1)\n \n end_offsets = []\n \n @legal_moves = end_offsets\n if color == :black\n if @coordinates.first == 6\n end_offsets << [5, @coordinates.last]\n end_offsets << [4, @coordinates.last]\n else\n end_offsets << [@coordinates.first + color_sign, @coordinates.last] unless @board.tiles[@coordinates.first + color_sign, @coordinates.last] \n end\n else\n if @coordinates.first == 1\n end_offsets << [2, @coordinates.last]\n end_offsets << [3, @coordinates.last]\n else\n end_offsets << [@coordinates.first + color_sign, @coordinates.last] unless @board.tiles[@coordinates.first + color_sign, @coordinates.last]\n end\n end\n # p \"updateview\"\n # p @board\n # p @coordinates.last + 1\n # # p @board.tiles[1,0]\n # p @board.tiles[@coordinates.first - 1][@coordinates.last + 1]\n \n if inside_bounds?([@coordinates.first + color_sign, @coordinates.last - 1])\n left_corner = @board.tiles[@coordinates.first + color_sign][@coordinates.last - 1]\n if (!left_corner.nil? && left_corner.color != color)\n end_offsets << left_corner.coordinates\n end\n end\n\n if inside_bounds?([@coordinates.first + color_sign, @coordinates.last + 1])\n # p [@coordinates.first + color_sign, @coordinates.last + 1]\n # if !@board.tiles[@coordinates.first + color_sign, @coordinates.last + 1].nil?\n \n # p \"right corner: #{@board.tiles[@coordinates.first + color_sign][@coordinates.last + 1]}\"\n right_corner = @board.tiles[@coordinates.first + color_sign][@coordinates.last + 1]\n if (!right_corner.nil? && right_corner.color != color)\n end_offsets << right_corner.coordinates\n end\n end\n @legal_moves = end_offsets\n \n end",
"def choose_colour(board,width,height,count,finished_game_counter,current_score)\n \n #prints the array\n board.each do |row|\n row.each do |column| \n \n #the field is coloured according to the element in the array \n if column == :red\n \n #prints the element as two space characters with a coloured background\n print column = \" \".colorize(:background => :red)\n elsif column == :green\n print column = \" \".colorize(:background => :green)\n elsif column == :blue\n print column = \" \".colorize(:background => :blue)\n elsif column == :yellow\n print column = \" \".colorize(:background => :yellow)\n elsif column == :magenta\n print column = \" \".colorize(:background => :magenta)\n elsif column == :cyan\n print column = \" \".colorize(:background => :cyan)\n end \n end\n puts\n end\n \n #display number of turns\n print \"Number of turns: \"\n turns(count)\n \n #display percentage completed\n print \"Current completion: \"\n completion(board,width,height,count,finished_game_counter,current_score)\n \n #gets user input r,g,y,b,c,m and increases count by one\n print \"Choose a colour: \"\n user_colour = gets.chomp.downcase\n count = count + 1\n \n #the user_colour variable will be set , depending on the user input\n if user_colour == \"r\"\n user_colour = :red\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"g\"\n user_colour = :green\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"b\"\n user_colour = :blue\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"y\"\n user_colour = :yellow\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"m\"\n user_colour = :magenta\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"c\"\n user_colour = :cyan\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n \n #if user types q, he will return to the main menu\n elsif user_colour == \"q\"\n main_menu(width,height,current_score,finished_game_counter)\n end\nend",
"def reset_board_variables\r\n @color_on_turn = :white\r\n @pieces = {:white => [], :black => []} \r\n @last_moved_item = BoardInfoItem.new(0,0)\r\n @infosquare.each do |row_square|\r\n row_square.each do |cell|\r\n cell.clear\r\n end\r\n end\r\n #p @infosquare\r\n end",
"def show_board\n @grid.each_with_index do |row, row_index|\n row.each_with_index do |square, col_index|\n piece = self[row_index, col_index]\n if row_index.even? && col_index.even?\n print \" #{piece.display} \".colorize( :color => :black, :background => :white ) if (piece && piece.color == :black)\n print \" #{piece.display} \".colorize( :color => :red, :background => :white ) if (piece && piece.color == :red)\n print \" \".colorize( :background => :white ) if piece.nil?\n elsif row_index.even? && col_index.odd? \n print \" #{piece.display} \".colorize( :color => :black, :background => :light_white ) if (piece && piece.color == :black)\n print \" #{piece.display} \".colorize( :color => :red, :background => :light_white ) if (piece && piece.color == :red)\n print \" \".colorize( :background => :light_white ) if piece.nil?\n elsif row_index.odd? && col_index.even? \n print \" #{piece.display} \".colorize( :color => :black, :background => :light_white ) if (piece && piece.color == :black)\n print \" #{piece.display} \".colorize( :color => :red, :background => :light_white ) if (piece && piece.color == :red)\n print \" \".colorize( :background => :light_white ) if piece.nil?\n elsif row_index.odd? && col_index.odd?\n print \" #{piece.display} \".colorize( :color => :black, :background => :white ) if (piece && piece.color == :black)\n print \" #{piece.display} \".colorize( :color => :red, :background => :white ) if (piece && piece.color == :red)\n print \" \".colorize( :background => :white ) if piece.nil?\n end\n end\n puts \"\"\n end\n end",
"def init_pos\r\n reset_board_variables\r\n colors = {:white => 0, :black => 7}\r\n pieces = {:torr => [0,7], :cav => [1,6], :alf => [2,5], :reg => [3], :re => [4]}\r\n key_pieces = {:white => [:w1, :w2, :w3, :w4, :w5, :w6, :w7, :w8, :w9, :w10, :w11, :w12, :w13, :w14, :w15, :w16],\r\n :black => [:b1, :b2, :b3, :b4, :b5, :b6, :b7, :b8, :b9, :b10, :b11, :b12, :b13, :b14, :b15, :b16]}\r\n # set pieces \r\n colors.each do |k_col, v_col|\r\n # iterate each color\r\n key_color_array = key_pieces[k_col]\r\n pieces.each do |k_pie, v_pie|\r\n # iterate each piece\r\n v_pie.each do |ix_piece|\r\n #p v_col, ix_piece, k_pie, k_col\r\n @infosquare[v_col][ix_piece].setinfo(k_pie, k_col)\r\n #kk_p = key_color_array.pop\r\n @pieces[k_col] << @infosquare[v_col][ix_piece] \r\n end\r\n end#end pieces\r\n \r\n # now set pawn for this color\r\n ix_col = 1\r\n ix_col = 6 if k_col == :black\r\n [0,1,2,3,4,5,6,7].each do |ix_piece|\r\n #p ix_col, ix_piece\r\n @infosquare[ix_col][ix_piece].setinfo(:ped, k_col)\r\n #kk_p = key_color_array.pop\r\n @pieces[k_col] << @infosquare[ix_col][ix_piece] \r\n end\r\n end \r\n #p @pieces\r\n #p @infosquare\r\n #p @pieces.size\r\n #p @pieces[:white].first\r\n end",
"def reset_board_variables\n @color_on_turn = :white\n @fifty_counter = 0\n @pieces = {:white => [], :black => []} \n @last_moved_item = BoardInfoItem.new(0,0)\n @infosquare.each do |row_square|\n row_square.each do |cell|\n cell.clear\n end\n end\n #p @infosquare\n end",
"def init_pos\n reset_board_variables\n colors = {:white => 0, :black => 7}\n pieces = {:torr => [0,7], :cav => [1,6], :alf => [2,5], :reg => [3], :re => [4]}\n key_pieces = {:white => [:w1, :w2, :w3, :w4, :w5, :w6, :w7, :w8, :w9, :w10, :w11, :w12, :w13, :w14, :w15, :w16],\n :black => [:b1, :b2, :b3, :b4, :b5, :b6, :b7, :b8, :b9, :b10, :b11, :b12, :b13, :b14, :b15, :b16]}\n # set pieces \n colors.each do |k_col, v_col|\n # iterate each color\n key_color_array = key_pieces[k_col]\n pieces.each do |k_pie, v_pie|\n # iterate each piece\n v_pie.each do |ix_piece|\n #p v_col, ix_piece, k_pie, k_col\n @infosquare[v_col][ix_piece].setinfo(k_pie, k_col)\n #kk_p = key_color_array.pop\n @pieces[k_col] << @infosquare[v_col][ix_piece] \n end\n end#end pieces\n \n # now set pawn for this color\n ix_col = 1\n ix_col = 6 if k_col == :black\n [0,1,2,3,4,5,6,7].each do |ix_piece|\n #p ix_col, ix_piece\n @infosquare[ix_col][ix_piece].setinfo(:ped, k_col)\n #kk_p = key_color_array.pop\n @pieces[k_col] << @infosquare[ix_col][ix_piece] \n end\n end \n #p @pieces\n #p @infosquare\n #p @pieces.size\n #p @pieces[:white].first\n end",
"def update_board \n\t@the_board = Board.new(array[0].position, array[1].position, array[2].position, array[3].position, array[4].position, array[5].position, array[6].position, array[7].position, array[8].position) \n\t@the_board.display \n end",
"def computer_change_guess\n changed_board = @guess_board.state\n @guess_board.state.each_with_index do |x, i|\n if @feedback_board.state[i] == 'Black'\n changed_board[i] = x\n next\n elsif @feedback_board.state[i] == 'White'\n @feedback_board.state.each_with_index do |y, j|\n if y == nil\n changed_board[j] = x\n changed_board[i] = nil\n @feedback_board.state[j] = 1\n break\n end\n if y == 'White' && j != i\n changed_board[j] = x\n changed_board[i] = nil\n @feedback_board.state[j] = 1\n break\n end\n end\n else\n loop do\n random_num = rand(1..@color_count).to_s\n if !(changed_board.include?(random_num))\n changed_board[i] = random_num\n break\n end\n end\n @feedback_board.state[i] = 1\n end\n end\n changed_board.each_with_index do |z, k|\n if z == nil\n loop do\n random_num = rand(1..@color_count).to_s\n if !(changed_board.include?(random_num)) && !(@guess_board.state.include?(random_num))\n changed_board[k] = random_num\n break\n end\n end\n end\n end\n @guess_board.state = changed_board\n end",
"def populate_board\n #the six rows get updated\n players.each do |player|\n rows = player == players[0] ? [ 0,1,2 ] : [ 5,6,7 ]\n piece_count = 0\n col = 0\n\n player.pieces.each do |piece|\n\n rows.shift if piece_count % 4 == 0 and piece_count != 0\n\n col_start = rows[0] % 2 == 1 ? 0 : 1\n col = 0 if (col_start == 0 || col_start == 1) && piece_count % 4 == 0\n\n piece.position = [col + col_start, rows[0]]\n squares[[col + col_start, rows[0]]] = piece\n\n col += 2\n piece_count += 1\n\n end\n\n end\n\n end",
"def initialize_board\n # Building out white pieces\n (0..7).each do |x|\n Pawn.create(is_black: false, x_position: x, y_position: 1, game_id: id, user_id: user_id_white, status: 'active')\n end\n\n Rook.create(is_black: false, x_position: 0, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Rook.create(is_black: false, x_position: 7, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n Knight.create(is_black: false, x_position: 1, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Knight.create(is_black: false, x_position: 6, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n Bishop.create(is_black: false, x_position: 2, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Bishop.create(is_black: false, x_position: 5, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n King.create(is_black: false, x_position: 4, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Queen.create(is_black: false, x_position: 3, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n # Building out the black pieces\n (0..7).each do |x|\n Pawn.create(is_black: true, x_position: x, y_position: 6, game_id: id, user_id: user_id_black, status: 'active')\n end\n\n Rook.create(is_black: true, x_position: 0, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Rook.create(is_black: true, x_position: 7, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n Knight.create(is_black: true, x_position: 1, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Knight.create(is_black: true, x_position: 6, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n Bishop.create(is_black: true, x_position: 2, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Bishop.create(is_black: true, x_position: 5, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n King.create(is_black: true, x_position: 4, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Queen.create(is_black: true, x_position: 3, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n end",
"def build_board\n @original_board\n @working_board.collect! { |row|\n row.collect! { |cell|\n cell = @original_board.shift\n }\n }\n @working_board\n end",
"def update_board(board)\r\n @game_board = board\r\n end",
"def setup_board\n (1..64).each do |location|\n @@piece_locations[location] = {\"type\" => \" \", \"number\" => nil, \"color\" => nil}\n end\n\n # Black Pieces\n @@piece_locations[1] = {\"type\" => \"rook\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[2] = {\"type\" => \"knight\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[3] = {\"type\" => \"bishop\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[4] = {\"type\" => \"queen\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[5] = {\"type\" => \"king\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[6] = {\"type\" => \"bishop\", \"number\" => 2, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[7] = {\"type\" => \"knight\", \"number\" => 2, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[8] = {\"type\" => \"rook\", \"number\" => 2, \"color\" => \"black\", \"moved\" => false}\n (1..8).each do |col|\n @@piece_locations[col + 8] = {\"type\" => \"pawn\", \"number\" => col, \"color\" => \"black\", \"moved\" => false}\n end\n\n # White Pieces\n @@piece_locations[57] = {\"type\" => \"rook\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[58] = {\"type\" => \"knight\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[59] = {\"type\" => \"bishop\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[60] = {\"type\" => \"queen\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[61] = {\"type\" => \"king\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[62] = {\"type\" => \"bishop\", \"number\" => 2, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[63] = {\"type\" => \"knight\", \"number\" => 2, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[64] = {\"type\" => \"rook\", \"number\" => 2, \"color\" => \"red\", \"moved\" => false}\n (1..8).each do |col|\n @@piece_locations[col + 48] = {\"type\" => \"pawn\", \"number\" => col, \"color\" => \"red\", \"moved\" => false}\n end\n end",
"def update\n @grid.squares[params[:x]][params[:y]] = params[:color]\n\n render json: { status: \"OK\" }\n end",
"def format_board\n\n\t\t# formateamos la primera fila de negras\n\t\t@board[0][0] = \"bR\"\n\t\t@board[0][1] = \"bN\"\n\t\t@board[0][2] = \"bB\"\n\t\t@board[0][3] = \"bQ\"\n\t\t@board[0][4] = \"bK\"\n\t\t@board[0][5] = \"bB\"\n\t\t@board[0][6] = \"bN\"\n\t\t@board[0][7] = \"bR\"\n\n\t\t# formateamos los peones de negras\n\t\tfor column in (0..@height-1)\n\t\t\t\t@board[1][column] = \"bP\"\n\t\tend\n\n\t\t# formateamos los peones de blancas\n\t\tfor column in (0..@height-1)\n\t\t\t\t@board[6][column] = \"wP\"\n\t\tend\n\n\t\t# formateamos la primera fila de negras\n\t\t@board[7][0] = \"wR\"\n\t\t@board[7][1] = \"wN\"\n\t\t@board[7][2] = \"wB\"\n\t\t@board[7][3] = \"wQ\"\n\t\t@board[7][4] = \"wK\"\n\t\t@board[7][5] = \"wB\"\n\t\t@board[7][6] = \"wN\"\n\t\t@board[7][7] = \"wR\"\n\n\tend",
"def image_board(color_board) ; @board = color_board ; end",
"def image_board(color_board) ; @board = color_board ; end",
"def display_board\n row_idx = -1\n numera = [1,2,3,4,5,6,7,8,9]\n @display = @grid.map do |row|\n \n col_idx = -1\n row_idx += 1 \n row.map do |col| \n col_idx += 1 \n if @flag_pair.include? ((row_idx.to_s) + (col_idx.to_s))\n col = 'F'.orange\n elsif col == :B\n col = 'H'.green\n elsif (@known_empty.include? ((row_idx.to_s) + (col_idx.to_s))) && (numera.include? col)\n col = col.to_s.red\n elsif @known_empty.include? ((row_idx.to_s) + (col_idx.to_s))\n col = 'O'.blue\n else\n col = 'H'.green\n end \n end \n end\n end",
"def populate_board\n back_row = [Rook, Knight, Bishop, Queen, King, Bishop, Knight, Rook]\n\n black_back_row = []\n back_row.each_with_index do |piece_class, j|\n black_back_row << piece_class.new(self, :black, [0, j])\n end\n board[0] = black_back_row\n \n black_front_row = []\n (0..7).each {|idx| black_front_row << Pawn.new(self, :black, [1, idx])}\n board[1] = black_front_row\n \n (2..5).each do |row|\n board[row] = Array.new(8) {NullPiece.instance} \n end\n \n white_front_row = []\n 8.times {|idx| white_front_row << Pawn.new(self, :white, [6, idx])}\n board[6] = white_front_row\n \n white_back_row = []\n back_row.each_with_index do |piece_class, j|\n white_back_row << piece_class.new(self, :white, [7, j])\n end\n board[7] = white_back_row\n end",
"def update_board\n\t\t@board.spots.each do |spot|\n\t\t\tspot[1] = @empty\n\t\tend\n\t\t@board.spots.map do |spot|\n\t\t\t@player1.tokens.each do |pieces|\n\t\t\t\tpieces.each do |piece| # should update board with token positions\n\t\t\t\t\tspot[1] = piece if spot[0] == piece.position\n\t\t\t\tend\n\t\t\tend\n\t\t\t@player2.tokens.each do |pieces|\n\t\t\t\tpieces.each do |piece| # should update board with token positions\n\t\t\t\t\tspot[1] = piece if spot[0] == piece.position\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def reset_board\n # append nil to all cells to reset\n self.r1_c1 = nil\n self.r1_c2 = nil\n self.r1_c3 = nil\n self.r2_c1 = nil\n self.r2_c2 = nil\n self.r2_c3 = nil\n self.r3_c1 = nil\n self.r3_c2 = nil\n self.r3_c3 = nil\n end",
"def upload_state\n 0.upto(ROWS - 1) do |row|\n 0.upto(COLUMNS - 1) do |column|\n state = @cell_state[row * ROWS + column]\n @lp.set_led_colors(column, row, *@colors[state])\n end\n end\n @lp.set_led_colors(0, -1, *((@iteration % 2) == 0) ? [1,3] : [3,3])\n @lp.update\n @lp.flip_buffers\n end",
"def board_with_fen(fen_str)\r\n @log.debug \"Set board using fen: #{fen_str}\"\r\n reset_board_variables\r\n arr_cmd = fen_str.split(' ')\r\n if arr_cmd.size != 6\r\n @log.error(\"invalid fen string format\")\r\n return\r\n end\r\n arr_row = arr_cmd[0].split('/')\r\n row_num = 0\r\n arr_row.each do |row_info|\r\n #p row_info\r\n col_pos = 0\r\n row_info.each_byte do |row_byte|\r\n #p row_byte\r\n piece_type = :none\r\n piece_color = :none\r\n case row_byte\r\n when 'P'[0]\r\n piece_type = :ped\r\n piece_color = :white\r\n when 'N'[0]\r\n piece_type = :cav\r\n piece_color = :white\r\n when 'B'[0]\r\n piece_type = :alf\r\n piece_color = :white\r\n when 'R'[0]\r\n piece_type = :torr\r\n piece_color = :white\r\n when 'Q'[0]\r\n piece_type = :reg\r\n piece_color = :white\r\n when 'K'[0]\r\n piece_type = :re\r\n piece_color = :white\r\n when 'p'[0]\r\n piece_type = :ped\r\n piece_color = :black\r\n when 'n'[0]\r\n piece_type = :cav\r\n piece_color = :black\r\n when 'b'[0]\r\n piece_type = :alf\r\n piece_color = :black\r\n when 'r'[0]\r\n piece_type = :torr\r\n piece_color = :black\r\n when 'q'[0]\r\n piece_type = :reg\r\n piece_color = :black\r\n when 'k'[0]\r\n piece_type = :re\r\n piece_color = :black\r\n else\r\n if row_byte >= 49 and row_byte <= 56\r\n blank_num = row_byte - 48 \r\n col_pos += blank_num\r\n end \r\n end#end case\r\n if piece_type != :none\r\n if col_pos > 7\r\n @log.error \"fen format error column\"\r\n end\r\n @infosquare[row_num][col_pos].setinfo(piece_type, piece_color)\r\n @pieces[piece_color] << @infosquare[row_num][col_pos]\r\n col_pos += 1\r\n end\r\n \r\n end\r\n row_num += 1\r\n end# end arr_row each\r\n @color_on_turn = :black if arr_cmd[1] == 'b'\r\n p @color_on_turn\r\n end",
"def initializeBoard()\n #\n # TO DO: complete this method\n #\n for j in 0...@size\n for i in 0...@size\n @board[j][i]=EMPTY\n end\n end\n center = (@size/2)-1\n @board[center][center] = BLACK\n @board[center+1][center+1] = BLACK\n @board[center+1][center] = WHITE\n @board[center][center+1] = WHITE\n\n\n\n\n end",
"def board_refresh\n print_board(@@piece_locations)\n end",
"def draw_board\n # first, it updates the @board variables to get the current state of each case\n @board = [[@case_a1.case, @case_b1.case, @case_c1.case], [@case_a2.case, @case_b2.case, @case_c2.case], [@case_a3.case, @case_b3.case, @case_c3.case]]\n\n # then prints beautifully the board\n print \"\\n\" + \"=\".red * 33 + \"\\n\"\n print \"|| \".red + \" | \" + \" A | B | C \" + \" ||\".red + \"\\n\"\n print \"||\".red + \"_____\" + \"|_\" + \"______|_______|_______\" + \"||\".red + \"\\n\"\n print \"|| \".red + \" | \" + \" ||\".red\n print \"\\n\" + \"||\".red + \" 1 | #{@board[0][0]} | #{@board[0][1]} | #{@board[0][2]} \" + \" ||\".red + \"\\n\"\n print \"||\".red + \"_\" * 5 + \"| \" + \" ___ ___ ___\" + \" ||\".red + \"\\n\"\n print \"|| \".red + \" | \" + \" ||\".red\n print \"\\n\" + \"||\".red + \" 2 | #{@board[1][0]} | #{@board[1][1]} | #{@board[1][2]} \" + \" ||\".red + \"\\n\"\n print \"||\".red + \"_\" * 5 + \"| \" + \" ___ ___ ___\" + \" ||\".red + \"\\n\"\n print \"|| \".red + \" | \" + \" ||\".red\n print \"\\n\" + \"||\".red + \" 3 | #{@board[2][0]} | #{@board[2][1]} | #{@board[2][2]} \" + \" ||\".red + \"\\n\"\n print \"=\".red * 33 + \"\\n\"\n end",
"def drawBoard\n for i in (0...@board.squares.length)\n for j in (0...@board.squares.length)\n drawSquare(@board.squares[i][j].color, i, j)\n end\n end\n end",
"def board_with_fen(fen_str)\n @log.debug \"Set board using fen: #{fen_str}\"\n reset_board_variables\n arr_cmd = fen_str.split(' ')\n if arr_cmd.size != 6\n @log.error(\"invalid fen string format\")\n return\n end\n arr_row = arr_cmd[0].split('/')\n row_num = 0\n arr_row.each do |row_info|\n #p row_info\n col_pos = 0\n row_info.each_byte do |row_byte|\n #p row_byte\n piece_type = :none\n piece_color = :none\n case row_byte\n when 'P'[0]\n piece_type = :ped\n piece_color = :white\n when 'N'[0]\n piece_type = :cav\n piece_color = :white\n when 'B'[0]\n piece_type = :alf\n piece_color = :white\n when 'R'[0]\n piece_type = :torr\n piece_color = :white\n when 'Q'[0]\n piece_type = :reg\n piece_color = :white\n when 'K'[0]\n piece_type = :re\n piece_color = :white\n when 'p'[0]\n piece_type = :ped\n piece_color = :black\n when 'n'[0]\n piece_type = :cav\n piece_color = :black\n when 'b'[0]\n piece_type = :alf\n piece_color = :black\n when 'r'[0]\n piece_type = :torr\n piece_color = :black\n when 'q'[0]\n piece_type = :reg\n piece_color = :black\n when 'k'[0]\n piece_type = :re\n piece_color = :black\n else\n if row_byte >= 49 and row_byte <= 56\n blank_num = row_byte - 48 \n col_pos += blank_num\n end \n end#end case\n if piece_type != :none\n if col_pos > 7\n @log.error \"fen format error column\"\n end\n @infosquare[row_num][col_pos].setinfo(piece_type, piece_color)\n @pieces[piece_color] << @infosquare[row_num][col_pos]\n col_pos += 1\n end\n \n end\n row_num += 1\n end# end arr_row each\n @color_on_turn = :black if arr_cmd[1] == 'b'\n #p @color_on_turn\n end",
"def board\n puts \"PUTSING THE BOARD\"\n @current_board = @board_array.dup\n end",
"def connect_cells\n @grid.each_with_index do |columns, col_i|\n columns.each_with_index do |cell, cell_i|\n cell.left = @grid[col_i-1][cell_i] if col_i != 0 \n cell.up = @grid[col_i][cell_i+1] if cell_i + 1 < columns.length\n cell.right = @grid[col_i+1][cell_i] if col_i + 1 < @grid.length\n cell.down = @grid[col_i][cell_i-1] if cell_i != 0\n cell.lu = @grid[col_i-1][cell_i+1] if col_i != 0 && cell_i + 1 < columns.length\n cell.ld = @grid[col_i-1][cell_i-1] if col_i != 0 && cell_i != 0\n cell.ru = @grid[col_i+1][cell_i+1] if col_i + 1 < @grid.length && cell_i + 1 < columns.length\n cell.rd = @grid[col_i+1][cell_i-1] if col_i + 1 < @grid.length && cell_i != 0\n end\n end\n end",
"def fill_board\n\t\tfill_row_pieces(0, 'b')\n\t\tfill_row_pawn(1, 'b')\n\t\tfill_row_pieces(7, 'w')\n\t\tfill_row_pawn(6, 'w')\n\tend",
"def update_board(num, sign)\n @squares = @squares.map do |row|\n row.each do |item|\n item.each do |key, _value|\n item[key] = sign if key == :\"#{num}\"\n end\n end\n end\n\n show_board\n end",
"def chess_board(board)\n pieza = [ \"T-\", \"H-\", \"B-\", \"Q-\", \"K-\", \"B-\", \"H-\", \"T-\" ]\n color = [\"W\", \"B\"]\n peon = [\"P-\", \"P-\", \"P-\", \"P-\", \"P-\", \"P-\", \"P-\", \"P-\"]\n \n\n for i in 0..7\n for j in 0..7 \n if i == 0 \n (board[i][j] = pieza[j] + color[0])\n elsif i == 1 \n board[i][j] = peon[j] + color[0] \n elsif i == 6 \n board[i][j] = peon[j] + color[1] \n elsif i == 7 \n board[i][j] = pieza[j] + color[1] \n elsif i == 2..5 \n board[i][j] = \" * \" \n end \n end \n end\n board.each do |x|\n puts \"#{x}\"\n end \nend",
"def choose_color(row, column, cell, selected_hotel, player)\n tile = self.game_tiles.where(cell: cell).first\n placed_tiles = []\n self.game_tiles.where(placed: true).each do |game_tile|\n placed_tiles << game_tile.tile.column.to_s + game_tile.tile.row\n end\n sur_tiles = get_surrounding_tiles(row, column, cell)\n placed_sur_tiles = get_placed_surrounding_tiles(sur_tiles, placed_tiles)\n merger = false\n merger_three = false\n if placed_sur_tiles.length == 0 # no surrounding tiles\n # placed tile is an orphan tile\n color = \"grey\"\n elsif placed_sur_tiles.length == 1 # 1 surrounding tile\n if placed_sur_tiles[0].hotel == 'none' # surrounding tile is an orphan\n if selected_hotel == 'none'\n # need input from user for new chain\n raise 'Ambiguous color'\n else\n # new chain\n other_tiles = convert_tile_to_number({'row' => placed_sur_tiles[0].tile.row, 'column' => placed_sur_tiles[0].tile.column})\n color = HOTEL_COLORS[selected_hotel]\n # Update Game log\n msg = player.username + ' founded ' + selected_hotel + '.'\n LogEntry.create(message: msg, game_id: self.id)\n #save game hotel chain size\n chosen_game_hotel = self.game_hotels.where(name: selected_hotel).first\n chosen_game_hotel.chain_size = 2\n chosen_game_hotel.save\n chosen_game_hotel.update_share_price\n #update other tile hotel\n placed_sur_tiles[0].hotel = selected_hotel\n placed_sur_tiles[0].save\n #save placed tile hotel\n tile.hotel = selected_hotel\n tile.save\n end\n else\n # extending chain\n hotel = placed_sur_tiles[0].hotel\n color = HOTEL_COLORS[hotel]\n # Update Game log\n msg = player.username + ' extended ' + hotel + '.'\n LogEntry.create(message: msg, game_id: self.id)\n #save game hotel chain size\n hotel_chain = self.game_hotels.where(name: hotel).first\n hotel_chain.chain_size += 1\n hotel_chain.save\n hotel_chain.update_share_price\n #save placed tile hotel\n tile.hotel = hotel\n tile.save\n end\n elsif placed_sur_tiles.length == 2 # 2 surrounding tiles\n if (placed_sur_tiles[0].hotel == 'none') && (placed_sur_tiles[1].hotel == 'none') # both surrounding tiles are orphan\n #new chain with chain size 3\n if selected_hotel == 'none'\n # need input from user for new chain\n raise 'Ambiguous color'\n else\n # new chain\n color = HOTEL_COLORS[selected_hotel]\n orphan_tiles_info = [[placed_sur_tiles[0].tile.row, placed_sur_tiles[0].tile.column, 'grey'], [placed_sur_tiles[1].tile.row, placed_sur_tiles[1].tile.column, 'grey']]\n other_tiles = convert_tiles_to_numbers(orphan_tiles_info)\n # Update Game log\n msg = player.username + ' founded ' + selected_hotel + '.'\n LogEntry.create(message: msg, game_id: self.id)\n #save game hotel chain size\n chosen_game_hotel = self.game_hotels.where(name: selected_hotel).first\n chosen_game_hotel.chain_size = 3\n chosen_game_hotel.save\n chosen_game_hotel.update_share_price\n #save other tiles hotels\n placed_sur_tiles[0].hotel = selected_hotel\n placed_sur_tiles[1].hotel = selected_hotel\n placed_sur_tiles[0].save\n placed_sur_tiles[1].save\n #save placed tile hotel\n tile.hotel = selected_hotel\n tile.save\n end\n elsif (placed_sur_tiles[0].hotel != 'none') && (placed_sur_tiles[1].hotel != 'none') # both surrounding tiles are part of a chain\n if (placed_sur_tiles[0].hotel == placed_sur_tiles[1].hotel) # both surrounding tiles are part of the same chain\n # extension of chain by 1\n hotel = placed_sur_tiles[0].hotel\n color = HOTEL_COLORS[hotel]\n hotel_chain = self.game_hotels.where(name: hotel).first\n hotel_chain.chain_size += 1\n hotel_chain.save\n hotel_chain.update_share_price\n tile.hotel = hotel\n tile.save\n # Update Game log\n msg = player.username + ' extended ' + hotel + '.'\n LogEntry.create(message: msg, game_id: self.id)\n else\n #merger of 2 chains\n response = execute_merger(placed_sur_tiles, false, tile)\n other_tiles = convert_tiles_to_numbers(response[1])\n color = response[0]\n dominant_hotel = response[2]\n acquired_hotel = response[3]\n acquired_hotel_size = response[4]\n # Update Game log\n msg = player.username + ' caused a merger. ' + dominant_hotel.name + ' acquired ' + acquired_hotel.name + '.'\n LogEntry.create(message: msg, game_id: self.id)\n merger_stock(dominant_hotel, acquired_hotel, acquired_hotel_size)\n merger = true\n end\n elsif ((placed_sur_tiles[0].hotel == 'none') && (placed_sur_tiles[1].hotel != 'none')) || ((placed_sur_tiles[0].hotel != 'none') && (placed_sur_tiles[1].hotel == 'none'))\n # one surrounding tile is part of hotel chain and the other is an orphan\n # extend chain by 2\n if placed_sur_tiles[0].hotel != 'none'\n hotel = placed_sur_tiles[0].hotel\n color = HOTEL_COLORS[hotel]\n hotel_chain = self.game_hotels.where(name: hotel).first\n hotel_chain.chain_size += 2\n hotel_chain.save\n hotel_chain.update_share_price\n placed_sur_tiles[1].hotel = hotel\n placed_sur_tiles[1].save\n other_tiles = convert_tile_to_number({'row' => placed_sur_tiles[1].tile.row, 'column' => placed_sur_tiles[1].tile.column, 'current_color' => 'grey'})\n tile.hotel = hotel\n tile.save\n # Update Game log\n msg = player.username + ' extended ' + hotel + '.'\n LogEntry.create(message: msg, game_id: self.id)\n elsif placed_sur_tiles[1].hotel != 'none'\n hotel = placed_sur_tiles[1].hotel\n color = HOTEL_COLORS[hotel]\n hotel_chain = self.game_hotels.where(name: hotel).first\n hotel_chain.chain_size += 2\n hotel_chain.save\n hotel_chain.update_share_price\n placed_sur_tiles[0].hotel = hotel\n placed_sur_tiles[0].save\n tile.hotel = hotel\n tile.save\n other_tiles = convert_tile_to_number({'row' => placed_sur_tiles[0].tile.row, 'column' => placed_sur_tiles[0].tile.column, 'current_color' => 'grey'})\n # Update Game log\n msg = player.username + ' extended ' + selected_hotel + '.'\n LogEntry.create(message: msg, game_id: self.id)\n end\n end\n elsif placed_sur_tiles.length == 3 # 3 surrounding tiles\n if (placed_sur_tiles[0].hotel == 'none') && (placed_sur_tiles[1].hotel == 'none') && (placed_sur_tiles[2].hotel == 'none') # all surrounding tiles are orphans\n #new chain with chain size 4\n if selected_hotel == 'none'\n # need input from user for new chain\n raise 'Ambiguous color'\n else\n # new chain\n color = HOTEL_COLORS[selected_hotel]\n orphan_tiles_info = [[placed_sur_tiles[0].tile.row, placed_sur_tiles[0].tile.column, 'grey'], [placed_sur_tiles[1].tile.row, placed_sur_tiles[1].tile.column, 'grey'], [placed_sur_tiles[2].tile.row, placed_sur_tiles[2].tile.column, 'grey']]\n other_tiles = convert_tiles_to_numbers(orphan_tiles_info)\n #save game hotel chain size\n chosen_game_hotel = self.game_hotels.where(name: selected_hotel).first\n chosen_game_hotel.chain_size = 4\n chosen_game_hotel.save\n chosen_game_hotel.update_share_price\n #save other tiles hotels\n placed_sur_tiles[0].hotel = selected_hotel\n placed_sur_tiles[1].hotel = selected_hotel\n placed_sur_tiles[2].hotel = selected_hotel\n placed_sur_tiles[0].save\n placed_sur_tiles[1].save\n placed_sur_tiles[2].save\n #save placed tile hotel\n tile.hotel = selected_hotel\n tile.save\n # Update Game log\n msg = player.username + ' founded ' + selected_hotel + '.'\n LogEntry.create(message: msg, game_id: self.id)\n end\n elsif (placed_sur_tiles[0].hotel != 'none') && (placed_sur_tiles[1].hotel != 'none') && (placed_sur_tiles[2].hotel != 'none') # all surrounding tiles are part of hotel chains\n if [placed_sur_tiles[0].hotel, placed_sur_tiles[1].hotel, placed_sur_tiles[2].hotel].uniq.length == 1 # all surrounding tiles are part of same hotel chain\n #extension of chain by 1\n hotel = placed_sur_tiles[0].hotel\n color = HOTEL_COLORS[hotel]\n tile.hotel = hotel\n tile.save\n hotel_chain = self.game_hotels.where(name: hotel).first\n hotel_chain.chain_size += 1\n hotel_chain.save\n hotel_chain.update_share_price\n msg = player.username + ' extended ' + hotel + '.'\n LogEntry.create(message: msg, game_id: self.id)\n elsif ([placed_sur_tiles[0].hotel, placed_sur_tiles[1].hotel].uniq.length == 1) || ([placed_sur_tiles[0].hotel, placed_sur_tiles[2].hotel].uniq.length == 1) || ([placed_sur_tiles[1].hotel, placed_sur_tiles[2].hotel].uniq.length == 1)\n # 2 of the surrounding tiles are part of the same hotel chain\n # merger of 2 chains\n if ([placed_sur_tiles[0].hotel, placed_sur_tiles[1].hotel].uniq.length == 1)\n merger_tiles = [placed_sur_tiles[0], placed_sur_tiles[2]]\n else\n merger_tiles = [placed_sur_tiles[0], placed_sur_tiles[1]]\n end \n response = execute_merger(merger_tiles, false, tile)\n other_tiles = convert_tiles_to_numbers(response[1])\n color = response[0]\n dominant_hotel = response[2]\n acquired_hotel = response[3]\n acquired_hotel_size = response[4]\n # Update Game log\n msg = player.username + ' caused a merger. ' + dominant_hotel.name + ' acquired ' + acquired_hotel.name + '.'\n LogEntry.create(message: msg, game_id: self.id)\n merger_stock(dominant_hotel, acquired_hotel, acquired_hotel_size)\n merger = true\n else\n #merger of 3 chains\n response = big_merger(placed_sur_tiles, tile)\n other_tiles = convert_tiles_to_numbers(response[1])\n color = response[0]\n dominant_hotel = response[2]\n acquired_hotel1 = response[3]\n acquired_hotel1_size = response[4]\n acquired_hotel2 = response[5]\n acquired_hotel2_size = response[6]\n # Update Game log\n msg = player.username + ' caused a merger wit 3 chains. ' + dominant_hotel.name + ' acquired ' + acquired_hotel1.name + ' and ' + acquired_hotel1.name + '.'\n LogEntry.create(message: msg, game_id: self.id)\n merger_stock(dominant_hotel, acquired_hotel1, acquired_hotel1_size)\n merger_stock(dominant_hotel, acquired_hotel2, acquired_hotel2_size)\n merger_three = true\n end\n elsif ((placed_sur_tiles[0].hotel == 'none') && (placed_sur_tiles[1].hotel != 'none') && (placed_sur_tiles[2].hotel != 'none')) || ((placed_sur_tiles[0].hotel != 'none') && (placed_sur_tiles[1].hotel != 'none') && (placed_sur_tiles[2].hotel == 'none')) || ((placed_sur_tiles[0].hotel != 'none') && (placed_sur_tiles[1].hotel == 'none') && (placed_sur_tiles[2].hotel != 'none'))\n # 1 of the surrounding tiles is an orphan and the other 2 are part of hotel chains\n if ((placed_sur_tiles[0].hotel == placed_sur_tiles[1].hotel) || (placed_sur_tiles[0].hotel == placed_sur_tiles[2].hotel) || (placed_sur_tiles[2].hotel == placed_sur_tiles[1].hotel))\n # 2 of the surrounding tiles are part of the same hotel chain and the other is an orphan\n # extension of chain by 2\n if placed_sur_tiles[0].hotel != 'none'\n hotel = placed_sur_tiles[0].hotel\n color = HOTEL_COLORS[hotel]\n if placed_sur_tiles[1].hotel != 'none'\n orphan_tile = placed_sur_tiles[2]\n else\n orphan_tile = placed_sur_tiles[1]\n end\n orphan_tile.hotel = hotel\n orphan_tile.save\n other_tiles = convert_tile_to_number({'row' => orphan_tile.tile.row, 'column' => orphan_tile.tile.column, 'current_color' => 'grey'})\n tile.hotel = hotel\n tile.save\n # Update Game log\n msg = player.username + ' extended ' + hotel + '.'\n LogEntry.create(message: msg, game_id: self.id)\n elsif placed_sur_tiles[1].hotel != 'none'\n hotel = placed_sur_tiles[0].hotel\n color = HOTEL_COLORS[hotel]\n if placed_sur_tiles[0].hotel != 'none'\n orphan_tile = placed_sur_tiles[2]\n else\n orphan_tile = placed_sur_tiles[0]\n end\n orphan_tile.hotel = hotel\n orphan_tile.save\n other_tiles = convert_tile_to_number({'row' => orphan_tile.tile.row, 'column' => orphan_tile.tile.column, 'current_color' => 'grey'})\n tile.hotel = hotel\n tile.save\n # Update Game log\n msg = player.username + ' extended ' + hotel + '.'\n LogEntry.create(message: msg, game_id: self.id)\n end\n hotel_chain = self.game_hotels.where(name: hotel).first\n hotel_chain.chain_size += 2\n hotel_chain.save\n hotel_chain.update_share_price\n else\n # 2 surrounding tiles are from different hotel chains and the other is an orphan\n # merger of 2 chains and 1 orphan\n response = merger_and_orphan(placed_sur_tiles, tile)\n other_tiles = convert_tiles_to_numbers(response[1])\n color = response[0]\n dominant_hotel = response[2]\n acquired_hotel = response[3]\n acquired_hotel_size = response[4]\n # Update Game log\n msg = player.username + ' caused a merger. ' + dominant_hotel.name + ' acquired ' + acquired_hotel.name + '.'\n LogEntry.create(message: msg, game_id: self.id)\n merger_stock(dominant_hotel, acquired_hotel, acquired_hotel_size)\n merger = true\n end\n elsif ((placed_sur_tiles[0].hotel == 'none') && (placed_sur_tiles[1].hotel == 'none') && (placed_sur_tiles[2].hotel != 'none')) || ((placed_sur_tiles[0].hotel == 'none') && (placed_sur_tiles[1].hotel != 'none') && (placed_sur_tiles[2].hotel == 'none')) || ((placed_sur_tiles[0].hotel != 'none') && (placed_sur_tiles[1].hotel == 'none') && (placed_sur_tiles[2].hotel == 'none'))\n # 1 of the surrounding tiles is part of a hotel chain and the others are orphans\n # extension of chain with 2 orphans\n if placed_sur_tiles[0].hotel != 'none'\n hotel = placed_sur_tiles[0].hotel\n color = HOTEL_COLORS[hotel]\n hotel_chain = self.game_hotels.where(name: hotel).first\n hotel_chain.chain_size += 3\n hotel_chain.save\n hotel_chain.update_share_price\n placed_sur_tiles[1].hotel = hotel\n placed_sur_tiles[1].save\n placed_sur_tiles[2].hotel = hotel\n placed_sur_tiles[2].save\n tile.hotel = hotel\n tile.save\n orphan_tiles_info = [[placed_sur_tiles[1].tile.row, placed_sur_tiles[1].tile.column, 'grey'], [placed_sur_tiles[2].tile.row, placed_sur_tiles[2].tile.column, 'grey']]\n other_tiles = convert_tiles_to_numbers(orphan_tiles_info)\n elsif placed_sur_tiles[1].hotel != 'none'\n hotel = placed_sur_tiles[1].hotel\n color = HOTEL_COLORS[hotel]\n hotel_chain = self.game_hotels.where(name: hotel).first\n hotel_chain.chain_size += 3\n hotel_chain.save\n hotel_chain.update_share_price\n placed_sur_tiles[0].hotel = hotel\n placed_sur_tiles[0].save\n placed_sur_tiles[2].hotel = hotel\n placed_sur_tiles[2].save\n tile.hotel = hotel\n tile.save\n orphan_tiles_info = [[placed_sur_tiles[0].tile.row, placed_sur_tiles[0].tile.column, 'grey'], [placed_sur_tiles[2].tile.row, placed_sur_tiles[2].tile.column, 'grey']]\n other_tiles = convert_tiles_to_numbers(orphan_tiles_info)\n elsif placed_sur_tiles[2].hotel != 'none'\n hotel = placed_sur_tiles[2].hotel\n color = HOTEL_COLORS[hotel]\n hotel_chain = self.game_hotels.where(name: hotel).first\n hotel_chain.chain_size += 3\n hotel_chain.save\n hotel_chain.update_share_price\n placed_sur_tiles[0].hotel = hotel\n placed_sur_tiles[0].save\n placed_sur_tiles[1].hotel = hotel\n placed_sur_tiles[1].save\n tile.hotel = hotel\n tile.save\n orphan_tiles_info = [[placed_sur_tiles[0].tile.row, placed_sur_tiles[0].tile.column, 'grey'], [placed_sur_tiles[1].tile.row, placed_sur_tiles[1].tile.column, 'grey']]\n other_tiles = convert_tiles_to_numbers(orphan_tiles_info) \n end\n # Update Game log\n msg = player.username + ' extended ' + hotel + '.'\n LogEntry.create(message: msg, game_id: self.id)\n end\n elsif placed_sur_tiles.length == 4 # 4 surrounding tiles\n if (placed_sur_tiles[0].hotel == 'none') && (placed_sur_tiles[1].hotel == 'none') && (placed_sur_tiles[2].hotel == 'none') && (placed_sur_tiles[3].hotel == 'none')\n # all surrounding tiles are orphans\n # new chain of 5\n if selected_hotel == 'none'\n # need input from user for new chain\n raise 'Ambiguous color'\n else\n # new chain\n color = HOTEL_COLORS[selected_hotel]\n orphan_tiles_info = [[placed_sur_tiles[0].tile.row, placed_sur_tiles[0].tile.column, 'grey'], [placed_sur_tiles[1].tile.row, placed_sur_tiles[1].tile.column, 'grey'], [placed_sur_tiles[2].tile.row, placed_sur_tiles[2].tile.column, 'grey'], [placed_sur_tiles[3].tile.row, placed_sur_tiles[3].tile.column, 'grey']]\n other_tiles = convert_tiles_to_numbers(orphan_tiles_info)\n #save game hotel chain size\n chosen_game_hotel = self.game_hotels.where(name: selected_hotel).first\n chosen_game_hotel.chain_size = 5\n chosen_game_hotel.save\n chosen_game_hotel.update_share_price\n #save other tiles hotels\n placed_sur_tiles[0].hotel = selected_hotel\n placed_sur_tiles[1].hotel = selected_hotel\n placed_sur_tiles[2].hotel = selected_hotel\n placed_sur_tiles[3].hotel = selected_hotel\n placed_sur_tiles[0].save\n placed_sur_tiles[1].save\n placed_sur_tiles[2].save\n placed_sur_tiles[3].save\n #save placed tile hotel\n tile.hotel = selected_hotel\n tile.save\n # Update Game log\n msg = player.username + ' founded ' + selected_hotel + '.'\n LogEntry.create(message: msg, game_id: self.id)\n end\n elsif ([placed_sur_tiles[0].hotel, placed_sur_tiles[1].hotel, placed_sur_tiles[2].hotel].uniq.length == 1 && placed_sur_tiles[3].hotel == 'none') || ([placed_sur_tiles[0].hotel, placed_sur_tiles[1].hotel, placed_sur_tiles[3].hotel].uniq.length == 1 && placed_sur_tiles[2].hotel == 'none') || ([placed_sur_tiles[0].hotel, placed_sur_tiles[3].hotel, placed_sur_tiles[2].hotel].uniq.length == 1 && placed_sur_tiles[1].hotel == 'none') || ([placed_sur_tiles[3].hotel, placed_sur_tiles[1].hotel, placed_sur_tiles[2].hotel].uniq.length == 1 && placed_sur_tiles[0].hotel == 'none')\n # 3 of surrounding tiles are of same chain and the other is an orphan\n # extension of chain by 2\n if placed_sur_tiles[0].hotel != 'none'\n hotel = placed_sur_tiles[0].hotel\n color = HOTEL_COLORS[hotel]\n if placed_sur_tiles[1].hotel == 'none'\n orphan_tile = placed_sur_tiles[1]\n elsif placed_sur_tiles[2].hotel == 'none'\n orphan_tile = placed_sur_tiles[2]\n else\n orphan_tile = placed_sur_tiles[3]\n end\n orphan_tile.hotel = hotel\n orphan_tile.save\n other_tiles = convert_tile_to_number({'row' => orphan_tile.tile.row, 'column' => orphan_tile.tile.column, 'current_color' => 'grey'})\n tile.hotel = hotel\n tile.save\n # Update Game log\n msg = player.username + ' extended ' + hotel + '.'\n LogEntry.create(message: msg, game_id: self.id)\n elsif placed_sur_tiles[1].hotel != 'none'\n hotel = placed_sur_tiles[0].hotel\n color = HOTEL_COLORS[hotel]\n if placed_sur_tiles[0].hotel == 'none'\n orphan_tile = placed_sur_tiles[0]\n elsif placed_sur_tiles[2].hotel == 'none'\n orphan_tile = placed_sur_tiles[2]\n else\n orphan_tile = placed_sur_tiles[3]\n end\n orphan_tile.hotel = hotel\n orphan_tile.save\n other_tiles = convert_tile_to_number({'row' => orphan_tile.tile.row, 'column' => orphan_tile.tile.column, 'current_color' => 'grey'})\n tile.hotel = hotel\n tile.save\n # Update Game log\n msg = player.username + ' extended ' + hotel + '.'\n LogEntry.create(message: msg, game_id: self.id)\n end\n hotel_chain = self.game_hotels.where(name: hotel).first\n hotel_chain.chain_size += 2\n hotel_chain.save\n hotel_chain.update_share_price\n end \n else\n # tile placement not valid\n return false \n end\n\n if !merger && !merger_three\n return [color, other_tiles, merger, merger_three]\n else\n if merger\n return [color, other_tiles, merger, merger_three, acquired_hotel.name]\n else\n return [color, other_tiles, merger, merger_three, acquired_hotel1.name, acquired_hotel2.name]\n end\n end\n end",
"def update args\n\n\t\t# Normalise the mouse position to the board origin\n\t\tmouse_x = ( ( args.inputs.mouse.x - @board_x ) / @cell_size ).floor\n\t\tmouse_y = ( ( args.inputs.mouse.y - @board_y ) / @cell_size ).floor\n\n\t\t# Handle if there's been a click, if we're still playing\n\t\tif !@victorious && ( @burniation == -1 ) && args.inputs.mouse.click\n\n\t\t\t# Save me some typing later on... ;-)\n\t\t\tcell_idx = (mouse_y*@width) + mouse_x\n\n\t\t\t# The user can do one of three things; click left, click right,\n\t\t\t# or click both. Somwhow we have to handle all of this!\n\t\t\tif mouse_x.between?( 0, @width-1 ) && mouse_y.between?( 0, @height-1 ) && args.inputs.mouse.button_left && args.inputs.mouse.button_right\n\n\t\t\t\t# Clear around an already-cleared cell\n\t\t\t\tif @cell_status[cell_idx] == :status_revealed\n\t\t\t\t\tuncover mouse_y, mouse_x, true\n\t\t\t\tend\n\n\t\t\t# If the user wants to add a gold pile to a covered cell, that's easy\n\t\t\telsif args.inputs.mouse.button_right\n\n\t\t\t\t# Needs to be on the board, and over a covered cell\n\t\t\t\tif mouse_x.between?( 0, @width-1 ) && mouse_y.between?( 0, @height-1 ) && @cell_status[cell_idx] != :status_revealed\n\n\t\t\t\t\t# We maintain a list of gold pile co-ordinates, and just toggle\n\t\t\t\t\t@cell_status[cell_idx] = ( @cell_status[cell_idx] == :status_gold ) ? :status_covered : :status_gold\n\n\t\t\t\tend\n\n\t\t\t# If the user clicks on the board, work out where.\n\t\t\telsif args.inputs.mouse.button_left\n\n\t\t\t\t# Obviously can only act if they're over the board\n\t\t\t\tif mouse_x.between?( 0, @width-1 ) && mouse_y.between?( 0, @height-1 )\n\n\t\t\t\t\t# If this is the first cell, spawn dragons!\n\t\t\t\t\tif !@spawned\n\t\t\t\t\t\tspawn_dragons mouse_y, mouse_x\n\t\t\t\t\tend\n\n\t\t\t\t\t# And then simply uncover the cell here\n\t\t\t\t\tuncover mouse_y, mouse_x\n\n\t\t\t\tend\n\n\t\t\tend\n\n\t\t\t# Redraw the board\n\t\t\trender_board\n\n\t\tend\n\n\n\t\t# Check to see if they clicked on the restart button instead\n\t\tif args.inputs.mouse.x.between?( @label_x, @label_x + @label_width ) &&\n\t\t args.inputs.mouse.y.between?( @label_restart_y, @label_restart_y + @size_restart.y )\n\n\t\t\t# If the mouse is clicked down, we've clicked the button\n\t\t \tif args.inputs.mouse.down\n\t\t \t\t@restart_clicked = true\n\t\t \tend\n\n\t\t \tif @restart_clicked && args.inputs.mouse.up\n\t\t \t\t@restart_clicked = false\n\t\t \t\tsize\n\t\t \t\trender_board\n\t\t \tend\n\n\t\tend\n\n\t\t# Now check for end conditions; have we flagged all the dragons we seek?\n\t\tif ( @spawned ) && ( !@victorious) && ( @burniation == -1 ) &&\n\t\t ( @cell_status.count( :status_gold ) == @dragon_count )\n\n\t\t\t# Then automagically reveal all non-flagged cells\n\t\t\t@end_tick = args.tick_count\n\t\t\t@victorious = true\n\t\t\t@cell_status.map! { |cell|\n\t\t\t\tcell == :status_covered ? :status_revealed : cell\n\t\t\t}\n\n\t\t\t# Redraw the board\n\t\t\trender_board\n\n\t\tend\n\n\t\t# Have we revealed a dragon?!\n\t\tif @burniation == -1\n\t\t\t@dragons.each_with_index { |dragon, index|\n\t\t\t\tif ( dragon == DRAGON ) && ( @cell_status[index] == :status_revealed )\n\t\t\t\t\t@burniation = index\n\t\t\t\t\t@victorious = false\n\t\t\t\t\t@end_tick = args.tick_count\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\tend",
"def update_board(turn)\n @board[turn][0] = @matches\n @board[turn][1] = @code_breaker_input\n end",
"def get_board(width,height,finished_game_counter,current_score)\n board = Array.new(height) { Array.new(width, 0)}\n (0..(height-1)).each do |row|\n (0..(width-1)).each do |column| \n \n #generate a random number between 1 and 6 inclusive, in order to create an array\n #of randomly coloured fields\n array_element = rand(1..6)\n \n #allocates a number to each colour\n if array_element == 1 \n board[row][column] = :red\n elsif array_element == 2\n board[row][column] = :green\n elsif array_element == 3\n board[row][column] = :blue\n elsif array_element == 4\n board[row][column] = :yellow\n elsif array_element == 5\n board[row][column] = :magenta\n elsif array_element == 6\n board[row][column] = :cyan\n end\n end\n end\n \n #sets count to 0\n count = 0\n choose_colour(board,width,height,count,finished_game_counter,current_score)\nend",
"def populate\n @board[7][0] = ChessPiece.new \"w_rook_1\", \"\\u2656\"\n @board[7][1] = ChessPiece.new \"w_knight_1\", \"\\u2658\"\n @board[7][2] = ChessPiece.new \"w_bishop_1\", \"\\u2657\"\n @board[7][3] = ChessPiece.new \"w_queen\", \"\\u2655\"\n @board[7][4] = ChessPiece.new \"w_king\", \"\\u2654\"\n @board[7][5] = ChessPiece.new \"w_bishop_2\", \"\\u2657\"\n @board[7][6] = ChessPiece.new \"w_knight_2\", \"\\u2658\"\n @board[7][7] = ChessPiece.new \"w_rook_2\", \"\\u2656\"\n @board[0][0] = ChessPiece.new \"b_rook_1\", \"\\u265C\"\n @board[0][1] = ChessPiece.new \"b_knight_1\", \"\\u265E\"\n @board[0][2] = ChessPiece.new \"b_bishop_1\", \"\\u265D\"\n @board[0][3] = ChessPiece.new \"b_queen\", \"\\u265B\"\n @board[0][4] = ChessPiece.new \"b_king\", \"\\u265A\"\n @board[0][5] = ChessPiece.new \"b_bishop_2\", \"\\u265D\"\n @board[0][6] = ChessPiece.new \"b_knight_2\", \"\\u265E\"\n @board[0][7] = ChessPiece.new \"b_rook_2\", \"\\u265C\"\n (0..7).each do |id|\n @board[6][id] = ChessPiece.new \"w_pawn_#{id+1}\", \"\\u2659\"\n @board[1][id] = ChessPiece.new \"b_pawn_#{id+1}\", \"\\u265F\"\n end \n end",
"def drawBoard\n\t$firstRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\n\t$secondRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\n\t$thirdRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\nend",
"def starting_board\n init_rows([0, 2], :black)\n init_rows([5, 7], :red)\n end",
"def flood_fill(image, sr, sc, new_color)\r\n queue = [[sr, sc]]\r\n old_color = image[sr][sc]\r\n until queue.empty? do \r\n start = queue.pop\r\n x, y = start\r\n image[x][y] = new_color\r\n queue << [x, y+1] if y+1 < image[x].length && image[x][y+1] == old_color\r\n queue << [x, y-1] if y-1 >= 0 && image[x][y-1] == old_color\r\n queue << [x+1, y] if x+1 < image.length && image[x+1][y] == old_color\r\n queue << [x-1, y] if x-1 >= 0 && image[x-1][y] == old_color\r\n end\r\n image\r\nend",
"def update_canvas()\n for x in 0...$width\n for y in 0...$height\n \n neighbor_count = count_neighbors(x, y)\n\n if $canvas[x][y] == 1\n if neighbor_count < 2 or neighbor_count > 3\n $canvas[x][y] = 0\n end\n else\n if neighbor_count == 3\n $canvas[x][y] = 1\n end\n end\n end\n end\nend",
"def setup_board\n gameboard.build_board\n build_white_side\n build_black_side\n end",
"def board_state(coordinates)\n #Nested hashes with board locations\n #ToDo: Look at creating this automatically based on user requested board size\n board_coordinates = [{y: 5, x: 1}, {y: 5, x: 2}, {y: 5, x: 3}, {y: 5, x: 4}, {y: 5, x: 5},\n {y: 4, x: 1}, {y: 4, x: 2}, {y: 4, x: 3}, {y: 4, x: 4}, {y: 4, x: 5},\n {y: 3, x: 1}, {y: 3, x: 2}, {y: 3, x: 3}, {y: 3, x: 4}, {y: 3, x: 5},\n {y: 2, x: 1}, {y: 2, x: 2}, {y: 2, x: 3}, {y: 2, x: 4}, {y: 2, x: 5},\n {y: 1, x: 1}, {y: 1, x: 2}, {y: 1, x: 3}, {y: 1, x: 4}, {y: 1, x: 5}]\n current_board = \"\"\n board_coordinates.each do |square|\n #if the square matches the coordinates array, add an X for the location of robot.\n #or else add a O to show that no robot is is in that location.\n if square[:y] == coordinates[0] && square[:x] == coordinates[1]\n current_board << \"X\"\n else\n current_board << \"O\"\n end\n if current_board.length == 5\n puts current_board\n current_board = \"\"\n end\n end\n puts\n puts \"Current Coordinates: #{coordinates}\"\n puts current_board\n end",
"def update(packet)\n if packet.match(/^c([-\\.\\d]+) (.+)/)\n new_b = Board.new($2, Float($1))\n remaining = self.boards.reject{ |b| b.x_y == new_b.x_y }\n self.boards = remaining << new_b\n self.fill_boards\n end\n end",
"def initializeBoard()\n\n # TO DO: COMPLETE THIS METHOD\n maxMid = @size / 2\n minMid = @size / 2 - 1\n for i in 0..size-1\n for j in 0..size-1\n if i == maxMid && j == maxMid\n @board[i][j] = \"B\"\n elsif i == minMid && j == minMid\n @board[i][j] = \"B\"\n elsif (i == minMid || i == maxMid) && (j == maxMid || j == minMid)\n @board[i][j] = \"W\"\n else\n @board[i][j] = \"-\";\n end\n end\n end\n end",
"def team_update\n data = {\n row: params[:row],\n col: params[:col],\n letter: params[:letter],\n solver_id: params[:solver_id],\n red: params[:red],\n green: params[:green],\n blue: params[:blue]\n }\n\n Pusher.trigger(params[:channel], 'change_cell', data)\n\n render nothing: true\n end",
"def populate_board\n black = \"black\"\n white = \"white\"\n\n white_pawns = [\"A2\", \"B2\", \"C2\", \"D2\", \"E2\", \"F2\", \"G2\", \"H2\"]\n black_pawns = [\"A7\", \"B7\", \"C7\", \"D7\", \"E7\", \"F7\", \"G7\", \"H7\"]\n\n # create white pawns\n white_pawns.each do |pos|\n @board.nodes[pos].piece = create_pawn(white, pos)\n end\n\n # create white pieces\n @board.nodes[\"E1\"].piece = create_king(white, \"E1\")\n @board.nodes[\"D1\"].piece = create_queen(white, \"D1\")\n @board.nodes[\"C1\"].piece = create_bishop(white, \"C1\")\n @board.nodes[\"F1\"].piece = create_bishop(white, \"F1\")\n @board.nodes[\"B1\"].piece = create_knight(white, \"B1\")\n @board.nodes[\"G1\"].piece = create_knight(white, \"G1\")\n @board.nodes[\"A1\"].piece = create_rook(white, \"A1\")\n @board.nodes[\"H1\"].piece = create_rook(white, \"H1\")\n\n # create black pawns\n black_pawns.each do |pos|\n @board.nodes[pos].piece = create_pawn(black, pos)\n end\n\n # create black pieces\n @board.nodes[\"E8\"].piece = create_king(black, \"E8\")\n @board.nodes[\"D8\"].piece = create_queen(black, \"D8\")\n @board.nodes[\"C8\"].piece = create_bishop(black, \"C8\")\n @board.nodes[\"F8\"].piece = create_bishop(black, \"F8\")\n @board.nodes[\"B8\"].piece = create_knight(black, \"B8\")\n @board.nodes[\"G8\"].piece = create_knight(black, \"G8\")\n @board.nodes[\"A8\"].piece = create_rook(black, \"A8\")\n @board.nodes[\"H8\"].piece = create_rook(black, \"H8\")\n\n end",
"def floodFill(col, row)\r\n (col > @columns-1 || col < 0 || row > @rows-1 || row < 0) && return #Returns if the tile index is outside of the grid bounds.\r\n @tile[col][row].revealed && return #Returns if the tile is already revealed.\r\n\r\n @tile[col][row].revealed = true #Marks the tile as revealed.\r\n @hiddenCount -= 1\r\n adjacent = @tile[col][row].adjacent #Gets the adjacent count for the tile.\r\n\r\n #Reveal the adjacent count of the tile.\r\n old = @tile[col][row].btn\r\n newStyle = old.style.dup\r\n old.parent.before(old) do\r\n @btn = button(adjacent.to_s, newStyle)\r\n end\r\n old.remove\r\n\r\n #Recursively calls flood fill for the surrounding tiles.\r\n if (@tile[col][row].adjacent == 0)\r\n floodFill(col+1,row+1)\r\n floodFill(col+1,row)\r\n floodFill(col+1,row-1)\r\n floodFill(col,row+1)\r\n floodFill(col,row-1)\r\n floodFill(col-1,row+1)\r\n floodFill(col-1,row)\r\n floodFill(col-1,row-1)\r\n end\r\n\r\nend",
"def populate_board!\n # white pieces\n # creates the 8 pawn pieces across the board\n 8.times do |i|\n # sets game_id in Piece model to current id in Game\n # color is boolean - true for white, false for black\n Pawn.create(game_id: id, x_coord: i, y_coord: 1, color: true, captured: false)\n end\n # creates the 2 rook, knight, and bishop pieces on opposite sides of the board\n (0..7).step(7) do |i|\n Rook.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n (1..7).step(5) do |i|\n Knight.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n (2..7).step(3) do |i|\n Bishop.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n\n Queen.create(game_id: id, x_coord: 3, y_coord: 0, color: true, captured: false)\n King.create(game_id: id, x_coord: 4, y_coord: 0, color: true, captured: false)\n\n # black pieces\n 8.times do |i|\n Pawn.create(game_id: id, x_coord: i, y_coord: 6, color: false, captured: false)\n end\n (0..7).step(7) do |i|\n Rook.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n (1..7).step(5) do |i|\n Knight.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n (2..7).step(3) do |i|\n Bishop.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n Queen.create(game_id: id, x_coord: 3, y_coord: 7, color: false, captured: false)\n King.create(game_id: id, x_coord: 4, y_coord: 7, color: false, captured: false)\n end",
"def initializeBoard()\n\t\tfor i in (0...@board.length)\n\t\t\tfor j in (0...@board.length)\n\t\t\t\t@board[i][j] = EMPTY\n\t\t\tend\n\t\tend\n\n\t\t@board[@size/2][@size/2] = BLACK\n\t\t@board[@size/2 - 1][@size/2 - 1] = BLACK\n\t\t@board[@size/2 - 1][@size/2] = WHITE\n\t\t@board[@size/2][@size/2 - 1] = WHITE\n\n end",
"def setup_easier\n (1...ROWS).each do |row|\n (1...COLUMNS).each do |col|\n set_neighbour_colour(col, row) if rand(-1...COLOR_TABLE.size) == -1\n end\n end\n end",
"def update(board)\n current_captures(board)\n current_moves(board)\n end",
"def update_board\n board = current_user.user_chessboard || current_user.build_user_chessboard\n board.update_attributes! board_params\n redirect_to \"/\"\n end",
"def setFigureOnBoard(posx, posy, value)\r\n @board[posx][posy] = value\r\n @sumCol[posx] += value\r\n @sumRow[posy] += value\r\n @sumDiag[0] += value if posx == posy\r\n @sumDiag[1] += value if posx + posy == 2\r\n end",
"def refresh_board(board_type, board_row, hide_secret, row_number = 0)\n\t\tcase board_type\n\t\twhen :secret then update_secret_board(board_row)\n\t\twhen :decoding then update_decoding_board(board_row, row_number)\n\t\twhen :rating then update_rating_board(board_row, row_number)\n\t\tend\n\n\t\tdisplay_board(hide_secret)\n\tend",
"def draw_board\n @board = stack do\n fill rgb(210,105,30)\n rect BOARD_SQUARE_POS[:board_start], BOARD_SQUARE_POS[:board_start], BLOCK_DIMENTION*CHECKERS_WIDTH , BLOCK_DIMENTION*CHECKERS_HEIGHT\n fill rgb(245,222,179)\n CHECKERS_HEIGHT.times do |x|\n CHECKERS_WIDTH.times do |y|\n rect BOARD_SQUARE_POS[:board_start] + BLOCK_DIMENTION*x, BOARD_SQUARE_POS[:board_start] + BLOCK_DIMENTION*y, BLOCK_DIMENTION,BLOCK_DIMENTION if x.even? && y.even?\n rect BOARD_SQUARE_POS[:board_start] + BLOCK_DIMENTION*x, BOARD_SQUARE_POS[:board_start] + BLOCK_DIMENTION*y, BLOCK_DIMENTION,BLOCK_DIMENTION if !x.even? && !y.even?\n end\n end\n end\nend",
"def update\n if @board.recheck\n #@board.compact_pieces\n @board.clear_matches\n elsif @board.pieces_removed != 0\n adjust_score(@board.pieces_removed)\n @board.pieces_removed = 0 \n #end game if no legal moves left \n if not @board.any_moves?\n stop_anim\n stop_update\n stop_timer\n @game_over = true\n draw\n $app.alert(\"Game over: no more moves\")\n end \n end\n #end game if out of time\n if @time_remaining && (@time_remaining < 0)\n stop_anim\n stop_update\n stop_timer\n @game_over = true\n draw\n $app.alert(\"Game over: out of time.\") \n end\n end",
"def populate_board!\n\n # Populate Pawns\n (0..7).each do |x|\n Pawn.create(x_coordinates: x, y_coordinates: 1, game_id: self.id, color: 'white', image: 'white-pawn.png', status: 'active') # White\n Pawn.create(x_coordinates: x, y_coordinates: 6, game_id: self.id, color: 'black', image: 'blk-pawn.png', status: 'active') # Black\n end\n\n # Populate Rook\n Rook.create(x_coordinates: 0, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-rook.png', status: 'active') # White\n Rook.create(x_coordinates: 7, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-rook.png', status: 'active') # White\n Rook.create(x_coordinates: 0, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-rook.png', status: 'active') # Black\n Rook.create(x_coordinates: 7, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-rook.png', status: 'active') # Black\n\n # Populate Knight\n Knight.create(x_coordinates: 1, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-knight.png', status: 'active' ) # White\n Knight.create(x_coordinates: 6, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-knight.png', status: 'active' ) # White\n Knight.create(x_coordinates: 1, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-knight.png', status: 'active' ) # Black\n Knight.create(x_coordinates: 6, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-knight.png', status: 'active' ) # Black\n\n # Populate Bishop\n Bishop.create(x_coordinates: 2, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-bishop.png', status: 'active') # White\n Bishop.create(x_coordinates: 5, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-bishop.png', status: 'active') # White\n Bishop.create(x_coordinates: 2, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-bishop.png', status: 'active') # Black\n Bishop.create(x_coordinates: 5, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-bishop.png', status: 'active') # Black\n\n # Populate Queen\n Queen.create(x_coordinates: 3, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-queen.png', status: 'active') # White\n Queen.create(x_coordinates: 3, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-queen.png', status: 'active') # Black\n\n # Populate King\n King.create(x_coordinates: 4, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-king.png', status: 'active') # White\n King.create(x_coordinates: 4, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-king.png', status: 'active') # Black\n end",
"def draw_board(new_board)\n new_board.each_with_index do |row, i|\n row.each_with_index do |cell, j|\n print new_board[i][j] + ' '\n end\n puts ''\n end\nend",
"def populate_grid\n start_rows = { red: (0..2), black: (5..7) }\n\n 8.times do |x|\n 8.times do |y|\n [:red, :black].each do |color|\n if (x + y).even? && start_rows[color].include?(y)\n self[[x, y]] = Piece.new(color, [x, y], self)\n end\n end\n end\n end\n\n grid.each_with_index do |row, y|\n row.each_with_index do |cell, x|\n puts \"x=#{x}, y=#{y}, cell.class=#{cell.class}\"\n end\n end\n end",
"def drawBoard() \n #1. prepare the default board\n @height.times do |y|\n @width.times do |x|\n print EMPTY_MARKER\n end\n puts\n end\t\n @squares = []\n @width.times do |x|\n column = []\n @height.times do |y|\n column << EMPTY_MARKER\n end\n @squares << column\n end\t\n # 2. fill the mine marker\n @mines.each do |mine|\n x,y = mine\n @squares[x][y] = MINE_MARKER\n end\t\t\n #puts @squares;\n\n end",
"def populate_board\n\t\t8.times{|x|\t@board[x][6] = Pawn.new([x, 6], \"black\", @board)}\n\t\t@board[0][7] = Rook.new([0, 7], \"black\", @board)\t\n\t\t@board[1][7] = Knight.new([1, 7], \"black\", @board)\n\t\t@board[2][7] = Bishop.new([2, 7], \"black\", @board)\n\t\t@board[3][7] = Queen.new([3, 7], \"black\", @board)\n\t\t@board[4][7] = King.new([4, 7], \"black\", @board)\t\t\n\t\t@board[5][7] = Bishop.new([5, 7], \"black\", @board)\n\t\t@board[6][7] = Knight.new([6, 7], \"black\", @board)\n\t\t@board[7][7] = Rook.new([7, 7], \"black\", @board)\n\t\t\t\t\n\t\t 8.times{|x|\t@board[x][1] = Pawn.new([x, 1], \"white\", @board)}\n\t\t@board[0][0] = Rook.new([0, 0], \"white\", @board)\t\n\t\t@board[1][0] = Knight.new([1, 0], \"white\", @board)\n\t\t@board[2][0] = Bishop.new([2, 0], \"white\", @board)\n\t\t@board[3][0] = Queen.new([3, 0], \"white\", @board)\n\t\t@board[4][0] = King.new([4, 0], \"white\", @board)\t\t\n\t\t@board[5][0] = Bishop.new([5, 0], \"white\", @board)\n\t\t@board[6][0] = Knight.new([6, 0], \"white\", @board)\n\t\t@board[7][0] = Rook.new([7, 0], \"white\", @board)\n\tend",
"def paint_fill(screen, point, new_color)\n seen = {}\n old_color = color(point, screen)\n to_fill = [point]\n\n until to_fill.empty? do\n current_point = to_fill.shift\n screen[current_point[0]][current_point[1]] = new_color\n neighbors(current_point, screen.length, screen.first.length).each do |neighbor|\n if !seen[neighbor] && color(neighbor, screen) == old_color\n to_fill.push(neighbor)\n seen[neighbor] = true\n end\n end\n end\n\n render screen\nend",
"def populate_board!\n # QUEENS - the user who created the game will be black, the opponent will be white\n Queen.create(game_id: id, user_id: user_id, position_x: 3, position_y: 7, color: \"black\", name: \"black queen\")\n Queen.create(game_id: id, user_id: opponent, position_x: 3, position_y: 0, color: \"white\", name: \"white queen\")\n # KINGS\n King.create(game_id: id, user_id: user_id, position_x: 4, position_y: 7, color: \"black\", name: \"black king\")\n King.create(game_id: id, user_id: opponent, position_x: 4, position_y: 0, color: \"white\", name: \"white king\")\n # BISHOPS\n # black bishops\n Bishop.create(game_id: id, user_id: user_id, position_x: 2, position_y: 7, color: \"black\", name: \"black bishop 1\")\n Bishop.create(game_id: id, user_id: user_id, position_x: 5, position_y: 7, color: \"black\", name: \"black bishop 2\")\n # white bishops\n Bishop.create(game_id: id, user_id: opponent, position_x: 2, position_y: 0, color: \"white\", name: \"white bishop 1\")\n Bishop.create(game_id: id, user_id: opponent, position_x: 5, position_y: 0, color: \"white\", name: \"white bishop 2\")\n # KNIGHTS\n # black knights\n Knight.create(game_id: id, user_id: user_id, position_x: 1, position_y: 7, color: \"black\", name: \"black knight 1\")\n Knight.create(game_id: id, user_id: user_id, position_x: 6, position_y: 7, color: \"black\", name: \"black knight 2\")\n # white knights\n Knight.create(game_id: id, user_id: opponent, position_x: 1, position_y: 0, color: \"white\", name: \"white knight 1\")\n Knight.create(game_id: id, user_id: opponent, position_x: 6, position_y: 0, color: \"white\", name: \"white knight 2\")\n # rooks\n # black rooks\n Rook.create(game_id: id, user_id: user_id, position_x: 0, position_y: 7, color: \"black\", name: \"black rook 1\")\n Rook.create(game_id: id, user_id: user_id, position_x: 7, position_y: 7, color: \"black\", name: \"black rook 2\")\n # white rooks\n Rook.create(game_id: id, user_id: opponent, position_x: 0, position_y: 0, color: \"white\", name: \"white rook 1\")\n Rook.create(game_id: id, user_id: opponent, position_x: 7, position_y: 0, color: \"white\", name: \"white rook 2\")\n # PAWNS\n # populate black pawns\n black_pawn_x = 0\n black_pawn_number = 1\n 8.times do\n Pawn.create(game_id: id, user_id: user_id, position_x: black_pawn_x, position_y: 6, color: \"black\", name: \"black pawn #{black_pawn_number}\")\n black_pawn_x += 1\n black_pawn_number += 1\n end\n # populate white pawns\n white_pawn_x = 0\n white_pawn_number = 1\n 8.times do\n Pawn.create(game_id: id, user_id: opponent, position_x: white_pawn_x, position_y: 1, color: \"white\", name: \"white pawn #{white_pawn_number}\")\n white_pawn_x += 1\n white_pawn_number += 1\n end\n end",
"def update_block_view(block)\n # Update visual of passsed in block\n cell = @blocks[block]\n delete_mark(block)\n if block.color != :mark\n cell.fill(block.color.to_s)\n else\n cell.fill(\"white\")\n mark = []\n mark << TkcLine.new(@board_window, cell.coords[0], cell.coords[1], cell.coords[2], cell.coords[3], { 'width' => 2 })\n mark << TkcLine.new(@board_window, cell.coords[2], cell.coords[1], cell.coords[0], cell.coords[3], { 'width' => 2 })\n mark.map { |line| line.bind(\"ButtonPress-1\", proc do\n block.color_cycle(@board.colors)\n update_block_view(block)\n end) }\n mark.map { |line| line.bind(\"ButtonPress-3\", proc do\n block.color_cycle(@board.colors)\n update_block_view(block)\n end) }\n # Save the lines used for marking so they can be removed\n @marks[block] = mark\n end\n\n # Tick Behaviour: Update passing clues\n @board.update_passing(block.coords[:x], block.coords[:y])\n\n # Update passing marks\n @passing.each { |pass| pass.remove() }\n @passing = draw_passing(@board.clues)\n\n # Test entire puzzle\n if @board.test_puzzle\n Tk.messageBox( type: 'ok', title: 'Puzzle Complete!', message: 'Puzzle Complete!' )\n end\n end",
"def update\n if @step_count == 20 # 3 times / s\n @board.step!\n @step_count = 0\n else\n @step_count += 1\n end\n end",
"def update(position,val)\n\t\tcase position \n\t\t\twhen 1 then @board[0][0] = val\n\t\t\twhen 2 then @board[0][1] = val\n\t\t\twhen 3 then @board[0][2] = val\n\t\t\twhen 4 then @board[1][0] = val\n\t\t\twhen 5 then @board[1][1] = val\n\t\t\twhen 6 then @board[1][2] = val\n\t\t\twhen 7 then @board[2][0] = val\n\t\t\twhen 8 then @board[2][1] = val\n\t\t\twhen 9 then @board[2][2] = val\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\tend\n\t\t@move_count = @move_count + 1\n\tend",
"def solve!\n\n until solved?\n\n\n @cell_array.each do |cell_object|\n cell_object.refresh_possible_values(@cell_array)\n if cell_object.value == 0 && cell_object.possible_values.length == 1\n cell_object.value = cell_object.possible_values[0]\n end\n end\n\n end\n\n board\n\n end",
"def bucket_paint(x_index = nil, y_index = nil)\n if x_index.nil? || y_index.nil?\n x_index = @x_index\n y_index = @y_index\n end\n\n # Checks if the adjacent cell's color is same the current cell.\n # On success, it paints the current cell and moves to the next adjacent cells.\n return if @input_2d_array[x_index].nil? || @input_2d_array[x_index][y_index] != @old_color\n\n @input_2d_array[x_index][y_index] = @new_color\n\n # Paint right\n bucket_paint(x_index+1, y_index)\n # Paint bottom\n bucket_paint(x_index, y_index+1)\n # Paint left\n bucket_paint(x_index-1, y_index) if x_index-1 >= 0\n # Paint top\n bucket_paint(x_index, y_index-1) if y_index-1 >= 0\n end",
"def update_board_state(username)\n \n end",
"def board_updates\n if under_populated? \n dead\n elsif over_populated?\n dead\n elsif to_be_reproduced?\n rebirth\n end \n end",
"def start_game(columns, rows, best_score)\n #init\n board = get_board(columns,rows)\n turns = 0\n player_color = board[0][0]\n # Gameplay loop untill the board has only one color\n loop do\n system \"clear\" or system \"cls\"\n display_board(board)\n puts \"Number of turns: #{turns}\"\n current_completion = color_in_board(board,player_color)*100/(columns*rows).to_f\n puts \"Current completion: #{current_completion.to_i}%\"\n # Check if the game is over\n if is_over?(board)\n if best_score[0] == -1\n best_score[0] = turns\n else\n best_score[0] = [best_score[0], turns].min\n end\n puts \"You won after #{turns} turns\"\n gets\n system \"clear\" or system \"cls\"\n break\n end\n # Take user's input and update the board respectively\n puts \"Possible inputs: q for quit, r for red/ b for blue/ g for green/ y for yellow/ c for cyan/ m for magenta\"\n print \"Choose a color: \"\n input = auto_complete(gets.chomp.to_sym)\n if is_a_color?(input) && input != player_color\n board = update(board, player_color, input, 0, 0)\n turns += 1\n player_color = input\n elsif input == :quit\n break\n end\n end\nend",
"def change_grid(x:, y:, color:)\n return if (x > max_x) || (x < 0)\n return if (y > max_y) || (y < 0)\n col = effective_color(x: x, y: y, color: color)\n grid_apply_color(x, y, col)\n end",
"def setup_board\n @startup = true\n @board = @board.map{|col| col.map{|piece| Piece.new if piece.nil?}}\n clear_matches\n @startup = false\n @pieces_removed = 0\n end",
"def change_colour(colour)\n # Return false if the top-left colour is already the colour requested\n\n return false if @tlc == colour\n\n build_block_list\n\n # Debugging 'Auto' button\n\n colour = best_colour if colour >= COLOR_TABLE.size\n\n @tl_list.each { |col, row| @blocks[row][col] = colour }\n @tlc = @blocks[0][0]\n\n true # Changed colours\n end",
"def set_neighbour_colour(col, row)\n xd = rand(2)\n @blocks[row][col] = @blocks[row - (1 - xd)][col - xd]\n end",
"def fill_neighbouring(x, y, color)\n # tmp var to store the original color of the targeted pixel\n original_color = grid[y.to_i - 1][x.to_i - 1]\n\n # Color the original pixel as a starting point\n color_pixel(x, y, color)\n\n # Find all neighbours that match the original color\n find_neighbours(x.to_i - 1, y.to_i - 1, original_color, color)\n end",
"def update_clear_neighbours(cell)\n all_directions = [\n [-1, 1], [0, 1], [1, 1],\n [-1, 0], [1, 0],\n [-1, -1], [0, -1], [1, -1]\n ]\n\n all_directions.each do |adj_cell|\n neighbour = [adj_cell[0] + cell[0], adj_cell[1] + cell[1]]\n\n puts \"#{neighbour}\"\n next unless (0..9).include?(neighbour[0]) && (0..9).include?(neighbour[1])\n\n add_to_board(neighbour, \"C\")\n end\n end",
"def initialize_board\n # Non-pawns for black player:\n Rook.create(x_position: 1, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Knight.create(x_position: 2, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Bishop.create(x_position: 3, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Queen.create(x_position: 4, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n King.create(x_position: 5, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Bishop.create(x_position: 6, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Knight.create(x_position: 7, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Rook.create(x_position: 8, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n\n # Non-pawns for white player:\n Rook.create(x_position: 1, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Knight.create(x_position: 2, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Bishop.create(x_position: 3, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Queen.create(x_position: 4, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n King.create(x_position: 5, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Bishop.create(x_position: 6, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Knight.create(x_position: 7, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Rook.create(x_position: 8, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n\n # Pawns for both players:\n for i in 1..8\n Pawn.create(color: \"black\", x_position: i, y_position: 2, game_id: id, player_id: black_player_id)\n Pawn.create(color: \"white\", x_position: i, y_position: 7, game_id: id, player_id: white_player_id)\n end\n\n self.counter = 0\n # Saves the counter to the database.\n self.save\n end",
"def populate\n black = [\n Rook.new(:black, self, [0,0], \" ♜ \"),\n Knight.new(:black, self, [0,1], \" ♞ \"),\n Bishop.new(:black, self, [0,2], \" ♝ \"),\n Queen.new(:black, self, [0,3], \" ♛ \"),\n King.new(:black, self, [0,4], \" ♚ \"),\n Bishop.new(:black, self, [0,5], \" ♝ \"),\n Knight.new(:black, self, [0,6],\" ♞ \"),\n Rook.new(:black, self, [0,7], \" ♜ \")\n ]\n white = [\n Rook.new(:white, self, [7,0], \" ♖ \"),\n Knight.new(:white, self, [7,1], \" ♘ \"),\n Bishop.new(:white, self, [7,2], \" ♗ \"),\n Queen.new(:white, self, [7,3], \" ♕ \"),\n King.new(:white, self, [7,4], \" ♔ \"),\n Bishop.new(:white, self, [7,5], \" ♗ \"),\n Knight.new(:white, self, [7,6], \" ♘ \"),\n Rook.new(:white, self, [7,7], \" ♖ \")\n ]\n\n @grid.each_with_index do |row, i|\n row.each_with_index do |column, j|\n pos = [i, j]\n if i == 0\n self[pos]= black[j]\n @black_pieces << black[j]\n elsif i == 7\n self[pos]= white[j]\n @white_pieces << white[j]\n elsif i == 1\n black_pawn = Pawn.new(:black, self, pos, \" ♟ \")\n self[pos]= black_pawn\n @black_pieces << black_pawn\n elsif i == 6\n white_pawn = Pawn.new(:white, self, pos, \" ♙ \")\n self[pos] = white_pawn\n @white_pieces << white_pawn\n end\n end\n end\n\n @grid\n end",
"def compact_pieces\n @recheck = false\n for i in (0..@width-1)\n for j in (0..@height-1)\n if @board[i][j] and @board[i][j+1].nil? #drop pieces down\n @recheck = true\n @board[i][j+1] = @board[i][j]\n @board[i][j] = nil \n elsif j == 0 and @board[i][j].nil? #replace pieces at top\n @recheck = true\n @board[i][j] = Piece.new\n end\n end\n end\n if @startup and @recheck #fast setup of board before update + anim loops start\n compact_pieces\n clear_matches\n end \n end",
"def start_game(columns, rows, best_score)\n cur_board = get_board(columns, rows)\n cur_completed = 0\n no_of_turns = 0\n\n while !check_win? cur_board\n # Display the current board\n print_board cur_board\n\n # In-game messages\n puts \"Current completion: #{ cur_completed }%\"\n puts \"Number of turns: #{ no_of_turns }\"\n\n # User chooses color by entering the first letter of that color\n print \"Choose a color: \"\n cur_color = gets.chomp\n\n # Convert the letter entered into a color symbol\n cur_color = to_color cur_color\n\n # Return to main menu if \"q\" entered\n if cur_color == \"q\"\n display_menu columns, rows, best_score\n end\n\n # Check if color entered is different to the previous color entered\n if cur_color != cur_board[0][0]\n # Update color of top left square and any squares connected to it\n update_adjacent cur_board, 0, 0, cur_color\n end\n\n # Update number of turns\n no_of_turns += 1\n\n # Update percentage of board completed\n cur_completed = get_amount cur_board, cur_color\n\n # Clear the screen\n clear\n end\n\n # Display message when board is completed\n puts \"You won after #{ no_of_turns } turns\"\n print \"<Press enter to continue>\"\n gets\n\n # Check if score is better than the \"best_score\"\n if no_of_turns < best_score || best_score == 0\n display_menu columns, rows, no_of_turns\n else \n display_menu columns, rows, best_score\n end\nend",
"def print_board\n 6.times do |y|\n y = 5 - y # To print from top to bottom\n 7.times do |x|\n if @board[[x, y]] == nil\n x == 6 ? (puts \"( )\") : (print \"( )\")\n else\n # Prints only the 3 first letters of each color to keep board alignment\n x == 6 ? (puts \"(#{@board[[x, y]].color[0, 3]})\") : (print \"(#{@board[[x, y]].color[0, 3]})\")\n end\n end\n end\n end",
"def solve!\n \t# keep looping if previous board doesn't match current board (new grids are being solved)\n\t \twhile true do\n\t\t \t@sudoku.each_with_index do |row, rowindex|\n\t\t \t\trow.each_with_index do |cell, cellindex|\n\t\t \t\t\t# duplicate sudoku board to solve grids and compare with previous board\n\t\t \t\t\t@sudokudup = @sudoku.dup\n\t\t \t\t\t# get the array of numbers from current column \n\t\t \t\t\tcol = @sudoku.transpose[cellindex]\n\t\t \t\t\t# find unsolved grids\n\t\t \t\t\tnext if cell != 0\n\t\t \t\t\t# form an array of possible solutions, starting with all numbers from 1 to 9\n\t\t \t\t\tsolutions=(1..9).to_a\n\t\t \t\t\t# loop through numbers from 1 to 9, delete the number from solutions if it appears in current row/column\n\t\t \t\t\t1.upto(9) {|x| solutions.delete(x) if row.include?(x)}\n\t\t \t\t\t1.upto(9) {|x| solutions.delete(x) if col.include?(x)}\n\n\t\t \t\t\t# get the numbers from current box(3x3 grid)\n\t\t \t\t\t# example (number in each grids represent column index):\n\t\t \t\t\t# | 0 1 2 | - 0 (row/array index)\n\t\t \t\t\t# | 0 1 2 | - 1\n\t\t \t\t\t# | 0 1 2 | - 2\n\t\t \t\t\t# ---------\n\t\t \t\t\t# box_x returns the array/row index of the top left number of current box (refer to sample board)\n\t\t \t\t\tbox_x = (rowindex./3)*3\n\t\t \t\t\tbox = []\n\t\t \t\t\t# loop through the 3 rows in the box\n\t\t \t\t\t3.times do\n\t\t \t\t\t\t# box_y returns the column index of the top left number of current box (refer to sample board)\n\t\t \t\t\t\tbox_y=(cellindex./3)*3\n\t\t \t\t\t\t# loop through the 3 columns for each rows\n\t\t \t\t\t\t3.times do\n\t\t \t\t\t\t\t# insert current number into the 'box' array\n\t\t \t\t\t\t\tbox << @sudoku[box_x][box_y]\n\t\t \t\t\t\t\t# get the next column index from the current row\n\t\t \t\t\t\t\tbox_y += 1\n\t\t \t\t\t\tend\n\t\t \t\t\t\t# get the next row/array index\n\t\t \t\t\t\tbox_x += 1\n\t\t \t\t\tend\n\t\t \t\t\t# delete number from solutions if it appears in current box\n\t\t \t\t\t1.upto(9) {|x| solutions.delete(x) if box.include?(x)}\n\t\t \t\t\t# if solutions contain only 1 number, the current grid will be replaced with the number\n\t\t \t\t\t@sudoku[rowindex][cellindex] = solutions[0] if solutions.length == 1\n\t\t \t\tend\n\t\t \tend\n\t\t \tif @sudoku == @sudokudup\n\t\t \t\tguess\n\t\t \t\treturn @sudoku.flatten.join\n\t\t \t\tbreak\n\t\t \tend\n\t\tend\n end",
"def update_board(board, position, marker)\n\tboard[position] = marker\n\tboard\nend",
"def clear(row, col)\n if !@field[row][col].contains_mine?\n @field[row][col].reveal!\n if row == 0 && col == 0\n if !@field[row][col + 1].contains_mine? && !@field[row + 1][col].contains_mine? && !@field[row + 1][col + 1].contains_mine?\n @field[row][col + 1].reveal!\n @field[row + 1][col].reveal!\n @field[row + 1][col + 1].reveal!\n end\n elsif row == 0 && col == @column_count - 1\n if !@field[row][col - 1].contains_mine? && !@field[row + 1][col - 1].contains_mine? && !@field[row + 1][col].contains_mine? &&\n @field[row][col - 1].reveal!\n @field[row + 1][col - 1].reveal!\n @field[row + 1][col].reveal!\n end\n elsif row == @row_count - 1 && col == 0\n if !@field[row][col + 1].contains_mine? && !@field[row - 1][col + 1].contains_mine? && !@field[row - 1][col].contains_mine? &&\n @field[row][col + 1].reveal!\n @field[row - 1][col + 1].reveal!\n @field[row - 1][col].reveal!\n end\n elsif row == @row_count - 1 && col == @column_count - 1\n if !@field[row][col - 1].contains_mine? && !@field[row - 1][col - 1].contains_mine? && !@field[row - 1][col].contains_mine? &&\n @field[row][col - 1].reveal!\n @field[row - 1][col - 1].reveal!\n @field[row - 1][col].reveal!\n end\n elsif row == 0\n if !@field[row][col - 1].contains_mine? && !@field[row][col + 1].contains_mine? && !@field[row + 1][col - 1].contains_mine? && !@field[row + 1][col].contains_mine? && !@field[row + 1][col + 1].contains_mine? &&\n @field[row][col - 1].reveal!\n @field[row][col + 1].reveal!\n @field[row + 1][col - 1].reveal!\n @field[row + 1][col].reveal!\n @field[row + 1][col + 1].reveal!\n end\n elsif col == 0\n if !@field[row - 1][col].contains_mine? && !@field[row - 1][col + 1].contains_mine? && !@field[row][col + 1].contains_mine? && !@field[row - 1][col].contains_mine? && !@field[row - 1][col + 1].contains_mine? &&\n @field[row - 1][col].reveal!\n @field[row - 1][col + 1].reveal!\n @field[row][col + 1].reveal!\n @field[row - 1][col].reveal!\n @field[row - 1][col + 1].reveal!\n end\n elsif row == @row_count - 1\n if !@field[row][col - 1].contains_mine? && !@field[row][col + 1].contains_mine? && !@field[row - 1][col - 1].contains_mine? && !@field[row - 1][col].contains_mine? && !@field[row - 1][col + 1].contains_mine? &&\n @field[row][col - 1].reveal!\n @field[row][col + 1].reveal!\n @field[row - 1][col - 1].reveal!\n @field[row - 1][col].reveal!\n @field[row - 1][col + 1].reveal!\n end\n elsif col == @column_count - 1\n if !@field[row - 1][col].contains_mine? && !@field[row - 1][col - 1].contains_mine? && !@field[row][col - 1].contains_mine? && !@field[row - 1][col].contains_mine? && !@field[row - 1][col - 1].contains_mine? &&\n @field[row - 1][col].reveal!\n @field[row - 1][col - 1].reveal!\n @field[row][col - 1].reveal!\n @field[row - 1][col].reveal!\n @field[row - 1][col - 1].reveal!\n end\n elsif row > 0 && row < @row_count && col > 0 && col < @column_count\n adjacent_cells(row, col).each do |cell|\n if !cell.contains_mine?\n cell.reveal!\n end\n end\n end\n else @field[row][col].reveal!\n end\n end"
] | [
"0.7696163",
"0.7116067",
"0.7082177",
"0.7061606",
"0.6974447",
"0.69378155",
"0.6806526",
"0.65437865",
"0.65291166",
"0.64986086",
"0.64369404",
"0.63301635",
"0.629596",
"0.6283609",
"0.6259597",
"0.6253917",
"0.62289274",
"0.6198834",
"0.6178496",
"0.61703223",
"0.6122843",
"0.60733753",
"0.60728407",
"0.60523975",
"0.60462075",
"0.6020388",
"0.6017239",
"0.5977906",
"0.5977403",
"0.5977403",
"0.5960451",
"0.59428823",
"0.594084",
"0.59397715",
"0.58844644",
"0.58577716",
"0.58509886",
"0.58299804",
"0.5821695",
"0.5817451",
"0.580612",
"0.5794512",
"0.5788924",
"0.5777014",
"0.5764295",
"0.5763495",
"0.57533",
"0.57495475",
"0.5722817",
"0.57052153",
"0.5695542",
"0.56938124",
"0.5686899",
"0.56809783",
"0.56793404",
"0.56673056",
"0.5647233",
"0.5645524",
"0.5617293",
"0.5591874",
"0.5590263",
"0.5589632",
"0.5585562",
"0.5578949",
"0.5576808",
"0.557618",
"0.55518866",
"0.5532774",
"0.55324787",
"0.55322164",
"0.5531414",
"0.5519302",
"0.5518097",
"0.55161613",
"0.5514814",
"0.55115575",
"0.55001736",
"0.54973966",
"0.54910445",
"0.5488275",
"0.54804593",
"0.5477162",
"0.54756033",
"0.5466527",
"0.54609644",
"0.5455335",
"0.5452588",
"0.5451741",
"0.54468626",
"0.5442355",
"0.54379714",
"0.5433939",
"0.5424925",
"0.54206216",
"0.54193467",
"0.5412466",
"0.54073906",
"0.5404795",
"0.5404101",
"0.54038256"
] | 0.8346162 | 0 |
Method used to display the menu | def display_menu
# print the options
puts "Main menu:"
puts "s = Start game"
puts "c = Change size"
puts "q = Quit"
# print the best score
# if there is no best score yet a message is displayed instead
if $best_score == 0
puts "No games played yet"
else
puts "Best game: #{$best_score} turns"
end
# Then ask for input for one of the options
print "Please enter your choice: "
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show # Show method\n menu # Show menu method above\n end",
"def displaymenu # Console only\r\n\t\t @output.puts \"Menu: (1) Play | (2) New | (3) Analysis | (9) Exit\"\r\n\t\t end",
"def menu\n \n \n\nend",
"def menu\n \nend",
"def list_menu\n puts \"\\nMain Menu\"\n puts \"1. Daily Prophet - News!\"\n puts \"2. Evanesco - Exit\"\n end",
"def menu\nend",
"def main()\n main_menu(SHOW_HEADER);\n end",
"def print_menu\n puts \"1. List patients\"\n # ....\n end",
"def display_menu\n system('clear')\n arr = ['My List', 'Recommendations', 'Playlist', 'Account Details', 'Exit']\n @prompt.select(\"》 MAIN MENU 《\\n\".colorize(:light_green), arr)\n end",
"def view_menu\n h = {\n f: :select_from_visited_files,\n d: :select_from_used_dirs,\n b: :view_bookmarks,\n s: :list_selected_files,\n c: :child_dirs,\n r: :recent_files,\n t: :tree,\n e: :dirtree\n }\n menu 'View Menu', h\nend",
"def menu # can do custom methods within a method/class\n end",
"def menu\n # This uses a HEREDOC for multiline listing\n puts \"-------------------------\".colorize(:green) \n puts <<-MENU\n\nChoose a how you would like to see a card. You can view by name, creature, enchantment or sorcery:\n1. See cards by Name \n2. See cards by Creature \n3. See cards by Enchantment \n4. See cards by Sorcery\n\nOr type 'exit' at any time to leave the program. Type 'menu' to return to the main menu.\n MENU\n end",
"def display_menu\n puts \"Choose from the following options: \\n\n to find a candidate, type 'find id' (ex. find 1)\n to view all candidates, type 'all'\n to view all qualified candidates, type 'qualified'\n to exit, type 'quit' \n to view menu, type 'menu' \\n\\n\"\nend",
"def display_menu(menu)\n puts menu.title\n menu.menu_items.each_with_index { |item| puts \"#{item.key_user_returns}.\\t #{item.user_message}\" }\n end",
"def display_menu()\n return 'Welcome to the Chicken Farm Simulator'\nend",
"def show_main_menu\n puts \"What would you like do next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" delete - Delete a contact\"\n puts \" show - Display contact details\"\n # puts \" find - Find a contact\"\n print \"> \"\n end",
"def menu\n puts '1) Promedio de notas'\n puts '2) Inasistencia alumnos'\n puts '3) Alumnos aprobados'\n puts '4) Salir'\nend",
"def display_main_menu(clear_screen = false)\n clear if clear_screen\n title_header(TITLES[:main_menu],\"_\",\"-\",false)\n\n Api.main_topics.each_with_index do |type, i|\n puts \"#{(\" \" * (PROFILE_SIDE / 2))}#{i+1}\".green + \". #{type}\" \n end\n\n puts \"\\n NAVIGATE: \".black.on_green + \" #{nav_main}\".on_black\n input_menu\n end",
"def main_menu\n puts \"Here is a list of available commands:\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" show - Show a contact\"\n puts \" search - Search contacts\"\n puts \" delete - Deletes a contact\"\n end",
"def Mostrar_menu\n puts \"______________________________\"\n puts \"\\n-----[[ RUBY ARITMETICO]]-----\"\n puts \"______________________________\"\n puts \"1) Suma\"\n puts \"2) Resta\"\n puts \"3) División\"\n puts \"4) Multiplicación\"\n puts \"5) Potencia\"\n puts \"6) Residuo\"\n puts \"7) Volver al Menu Principal\"\n puts \"______________________________\"\n print \"Opcion: \"\n end",
"def show(screen)\n\n screen.set_pos_by_point(Point.zeroPoint)\n\n if @selected\n screen.attron(A_REVERSE)\n else\n screen.attron(A_UNDERLINE)\n end\n\n @menu_items.each do |menu_item|\n screen.addstr( \"#{menu_item} \")\n end\n\n p = screen.cur_point\n\n screen.addstr( ' ' * (screen.width - p.x) )\n\n if @selected\n screen.attroff(A_REVERSE)\n else\n screen.attroff(A_UNDERLINE)\n end\n\n end",
"def print_menu\n\t\tsystem ('cls') or system ('clear')\n\t\t@todo_list.print_list\n\t\tprint_menu_options\n\tend",
"def menu_display\n system(\"clear\")\n\t\tputs \"##############################\"\n\t\tputs \"# #\"\n\t\tputs \"# Select a number #\"\n\t\tputs \"# from below #\"\n\t\tputs \"# #\"\n\t\tputs \"# 1. Balance #\"\n\t\tputs \"# 2. Deposit #\"\n\t\tputs \"# 3. Withdraw #\"\n\t\tputs \"# 4. History #\"\n\t\tputs \"# 5. Exit #\"\n\t\tputs \"# #\"\n\t\tputs \"# #\"\n\t\tputs \"##############################\"\n end",
"def printMenu\n\t\tself.report(\"\n\t\tEscolha uma opção\n\t\t1 - Trocar palavra-chave.\n\t\t2 - Ver palavra-chave.\n\t\t3 - Ver arquivo.\n\t\t4 - Sair.\n\t\t? \", 1)\t\t\n\tend",
"def main_menu\r\n puts \"\\nMain Menu.\"\r\n puts \"A. List Buildings\"\r\n puts \"B. List Machines\"\r\n puts \"C. List Snacks\"\r\n puts \"D. List Users\"\r\n puts \"E. Find a Snack\"\r\n puts \"F. Add a New Snack\"\r\n puts \"G. Create New User\"\r\n puts \"H. List Favorites\"\r\n puts \"I. Find Favorites\"\r\n puts \"J. Add Favorites\"\r\n puts \"Q. Quit\"\r\nend",
"def print_menu\n output.puts \"Madden's Car Selection Tool-\"\n \n # Print Current Model Info\n print_model_info\n\n # Print Menu Choices\n print_menu_choices\n\n # Get User Choice\n output.print \"Enter choice: \"\n end",
"def show_main_menu\n puts \" Welcome to the app. What's next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" list important - List all contacts\"\n puts \" show :id - Display contact details\"\n puts \" delete - Delete an entry\"\n puts \" find - Find an entry\"\n print \"> \"\n end",
"def menu\n\t\t@map.redrawSection(0, 0, 11, 3)\n\t\t@dialogueText.draw\n\t\t@menuStack.each { |menu|\n\t\t\tmenu.draw\n\t\t}\n\t\tBATTLE_BACKGROUND.blit(@screen, [188, 106], nil)\n\t\t@battleStack.draw\n\tend",
"def display_menu\n puts \"Welcome to Lorrayne and Sherwin's coffee emporium!\\n\\n\"\n puts \"1) Add item - $5.00 - Light Bag\"\n puts \"2) Add item - $7.50 - Medium Bag\"\n puts \"3) Add item - $9.75 - Bold Bag\"\n puts \"4) Complete Sale\"\n end",
"def Mostrar_menu\n puts \"______________________________\"\n puts \"\\n-----[[ RUBY RANGOS]-----\"\n puts \"______________________________\"\n puts \"1) Generación numérica\"\n puts \"2) Generación de letras\"\n puts \"3) Volver al Menu Principal\"\n puts \"______________________________\"\n print \"Opcion: \"\n end",
"def build_menu(application_name, method_names)\n #take array of method names and turn into menu\n puts \"#{application_name.humanize}\"\n method_names.each_with_index {|method_name, index| puts \"#{index + 1}: #{method_name.to_s.humanize}\"}\n puts \"\\nPlease enter your selection:\"\nend",
"def main_menu\n name_selector\n puts \"Okay #{@name}, what would you like to do?\"\n loop do\n case menu_arrows\n when '1'\n @recommendation.recommendation_menu\n when '2'\n puts 'you have the following number of games in your library: '\n @game_library.game_instances\n puts 'your custom list of games:'\n @game_library.user_games_lister\n when '3'\n puts 'add a game:'\n @game_library.add_title\n when '4'\n @game_library.delete_games\n when '5'\n @time_used.time_wasted\n when '6'\n @game_library.write_games\n puts 'thanks for your time!'\n exit\n end\n end\n end",
"def show_main_menu\n puts \"Welcome to the app. What's next?\".yellow\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" show - display details via index\"\n puts \" find - find someone by name\"\n puts \" quit - Exit Application\"\n print \"> \"\n end",
"def menu\n system('clear')\n selection = @prompt.select('》 PLAYLIST 《', ['Display', 'Add', 'Remove', 'Export To File', 'Back'])\n case selection\n when 'Display'\n list\n else\n case_menu(selection)\n end\n end",
"def getMenu(menu)\n end",
"def main_menu\n h = {\n a: :ag,\n z: :z_interface,\n # f: :file_actions,\n b: :bookmark_menu,\n c: :create_menu,\n f: :filter_menu,\n o: :order_menu,\n s: :selection_menu,\n t: :toggle_menu,\n v: :view_menu,\n '`' => :goto_parent_dir,\n x: :extras\n }\n menu 'Main Menu', h\nend",
"def show_main_menu\n puts \"Welcome to the app. What would you like to do?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" quit - Exit Application\"\n puts \" show - shows contact with specific id\"\n puts \" find - find a user\"\n print \"> \"\n end",
"def show_menu\n planet_list = \"\"\n i = 1\n @solar_system.length.times do |n|\n planet_list << \"\\n#{i}. #{@solar_system[n].name}\"\n i += 1\n end\n return \"\\nPlanet List#{planet_list}\\nOther: Exit\\n\\n\"\n end",
"def menu\n puts \"\\n************************************************************\".colorize(:magenta).blink\n puts \"Select an option (1-5) from the menu below:\".colorize(:blue).bold\n puts \"------------------------------------------------------------\".colorize(:cyan)\n puts \"1. Don't want to think about what to cook? \\n Spin the RANDOM WHEEL OF RECIPES!\".colorize(:blue)\n puts \"------------------------------------------------------------\".colorize(:cyan)\n puts \"2. Need some inspiration for cooking? \\n Find recipe by name OR \\n if you have leftover ingredients search your ingredients!\".colorize(:blue)\n puts \"------------------------------------------------------------\".colorize(:cyan)\n puts \"3. Feeling creative? \\n Write and save your own recipe!\".colorize(:blue)\n puts \"------------------------------------------------------------\".colorize(:cyan)\n puts \"4. View ALL your favorite recipes in 1 place!\".colorize(:blue)\n puts \"------------------------------------------------------------\".colorize(:cyan)\n puts \"5. You're done? Time to exit...\".colorize(:blue)\n puts \"************************************************************\\n \".colorize(:magenta).blink\n end",
"def show_main_menu\n puts \"Welcome to the app. What's next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" find - Find by name\"\n puts \" quit - Exit Application\"\n print \"> \"\n end",
"def show_main_menu\n puts \"\\e[H\\e[2J\"\n puts \"Welcome to the app. What's next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" quit - Exit Application\"\n print \"> \"\n end",
"def sub_menu\n puts \"\\n***********************************************\".colorize(:magenta).blink\n puts \"Type the following letters to do...\".colorize(:blue)\n puts \"-----------------------------------------------\".colorize(:cyan).bold\n puts \"s = Save Recipe to My Favorites\".colorize(:blue)\n puts \"r = Rate Recipe\".colorize(:blue)\n puts \"a = See Average Recipe Rating\".colorize(:blue)\n puts \"o = Open Link to See the Steps for This Recipe\".colorize(:blue)\n puts \"m = Back to Main Menu\".colorize(:blue)\n puts \"***********************************************\\n \".colorize(:magenta).blink\n end",
"def menu\n @menu ||= Interface::Menu.new(self)\n end",
"def show_main_menu\n puts \"Welcome to the app. What's next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" find - Find by name\"\n puts \" delete - Delete by ID\"\n puts \" quit - Exit Application\"\n print \"> \"\n end",
"def menu\n puts \"Menu\"\n puts \"1. List Channels\"\n puts \"2. List Users\"\n puts \"3. Select User\"\n puts \"4. Select Channel\"\n puts \"5. Send Message\"\n puts \"6. Quit\"\nend",
"def create_menu\n h = { f: :create_a_file,\n d: :create_a_dir,\n s: :create_dir_with_selection,\n b: :create_bookmark }\n _, menu_text = menu 'Create Menu', h\nend",
"def print_menu\n isFinished = true\n while (isFinished)\n puts @menu_description\n @menu_items.each_pair { |key, value|\n puts \"(#{key}) #{value}\"\n }\n\n isFinished = determine_action(get_entry(\"Select option: \"))\n end\n end",
"def getMenu(menu)\n menu.add_item(\"Done\") {self.done}\n menu.add_item(\"Edit Camera...\") {self.edit}\n menu.add_item(\"Reset Tilt\") {self.reset_tilt}\nend",
"def show_main_menu\n puts \"Welcome to the app. What's next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" show id - Show info for contact id number\"\n puts \" quit - Exit Application\"\n print \"> \"\n end",
"def display_menu\n title_print\n puts \"Hi #{@todays_hero.name}!\"\n puts \"***************************\"\n selection = TTY::Prompt.new.select(\"What would you like to do?\", per_page: 10, cycle: true) do |menu|\n menu.enum '>'\n\n menu.choice 'Start a fight', 1\n menu.choice 'Train for battle', 2\n menu.choice 'Go on a Quest', 3\n menu.choice 'Show Stats', 4\n menu.choice 'Display Instructions', 5\n menu.choice 'Display Leaderboard', 6\n menu.choice 'Exit', 7\n end\n self.start_game_loop(selection)\n end",
"def show_menu\n clear_screen\n\n puts \"[+] #{FreelancerFinder::Job.all.count} Jobs Scraped [+]\".magenta\n puts \"_____________________________________________________________\"\n return @prompt.select(\"Please Select a Menu Option: \") do |menu|\n menu.choice \"show recent\"\n menu.choice \"scrape more\"\n menu.choice \"search\"\n menu.choice \"search by pay\"\n if @last_results\n menu.choice \"results\"\n end\n menu.choice \"exit\"\n end\n\n end",
"def print_menu\n puts \"Which action [list|add|delete|mark|idea|quit]?\"\nend",
"def display_menu\n if project?\n content_tag(:div, :id => 'menu') do\n render :partial => 'layouts/menu_nav'\n end\n end\n end",
"def main_menu\n h = { \n :a => :ack,\n \"/\" => :ffind,\n :l => :locate,\n :v => :viminfo,\n :z => :z_interface,\n :d => :child_dirs,\n :r => :recent_files,\n :t => :dirtree,\n \"4\" => :tree,\n :s => :sort_menu, \n :F => :filter_menu,\n :c => :command_menu ,\n :B => :bindkey_ext_command,\n :M => :newdir,\n \"%\" => :newfile,\n :x => :extras\n }\n menu \"Main Menu\", h\nend",
"def call_menu\n return if $game_system.menu_disabled\n Sound.play_open_menu\n @spriteset.clear_banners\n#~ if @spriteset.banners?\n#~ bs = @spriteset.title_banners ? @spriteset.title_banners : []\n#~ pb = @spriteset.party_banners ? @spriteset.party_banners : []\n#~ rb = @spriteset.red_banners ? @spriteset.red_banners : []\n#~ $game_temp.remember_banners = [[bs],[pb],[rb]]\n#~ $game_temp.remember_banner_phase = [@spriteset.tickdown,@spriteset.banner_phase]\n#~ $game_temp.remember_joiners = @spriteset.joiners\n#~ $game_temp.remember_leavers = @spriteset.leavers\n#~ $game_temp.remember_removed = @spriteset.removed\n#~ $game_temp.remember_header = @spriteset.header_banner\n#~ $game_temp.remember_posx = @spriteset.posx\n#~ end\n SceneManager.call(Scene_Menu)\n Window_MenuCommand::init_command_position\n end",
"def menu\n response[\"menu\"]\n end",
"def interactive_menu\n loop do\n print_menu\n selection\n end\nend",
"def print_menu menu_level= '0'\n print_menu_header menu_level\n\n 20.times do |counter|\n lvl = \"#{menu_level}.#{counter}\"\n puts \" #{counter} : \" + @menu_map[lvl][0] if @menu_map.has_key?(lvl)\n end\n puts \"Make a choice between those items. (X to exit)\"\n puts \"Use left arrow to go back\"\n end",
"def show_menu element\n element.perform :show_menu\n end",
"def display_main_menu\n puts '################################'\n puts '# {N}- Network Stuff #'\n puts '# {RF}- Read File #'\n # puts '# {GF}- Generate File #'\n # puts '# {D}- Run as Daemon #'\n # puts '# {TD}- Run as Trigger Daemon #'\n puts '# {Q}- Quit #'\n puts '################################'\nend",
"def main_menu\n h = { \n \"1\" => :view_article,\n \"2\" => :view_comments,\n :f => :display_forum,\n :v => :view_menu,\n :r => :reload,\n :m => :fetch_more,\n :R => :reddit_options,\n :H => :hacker_options,\n :s => :sort_menu, \n :C => :config_menu,\n :a => :view_article,\n :c => :view_comments,\n :x => :extras\n }\n=begin\n :a => :ack,\n \"/\" => :ffind,\n :l => :locate,\n :v => :viminfo,\n :z => :z_interface,\n :d => :child_dirs,\n :r => :recent_files,\n :t => :dirtree,\n \"4\" => :tree,\n :F => :filter_menu,\n :c => :command_menu ,\n :B => :bindkey_ext_command,\n :M => :newdir,\n \"%\" => :newfile,\n=end\n\n menu \"Main Menu\", h\nend",
"def run_normal\n welcome_header\n main_menu \n end",
"def print_menu\n # 1. print the menu and ask the user what to do\n puts \"1. Input the students\"\n puts \"2. Show the students\"\n puts \"9. Exit\" # '9' because we'll be adding more items later\nend",
"def display_game_menu\n @output.puts '-----------------------'.center(WIDTH)\n @output.puts '| 1) Blackjack |'.center(WIDTH)\n @output.puts '| 2) Stud Poker |'.center(WIDTH)\n @output.puts \"| 3) Texas Hold 'em |\".center(WIDTH)\n @output.puts '| A) Add AI Player |'.center(WIDTH)\n @output.puts '| D) Debug Console |'.center(WIDTH)\n @output.puts '| P) Setup Player |'.center(WIDTH)\n @output.puts '| Q) Quit |'.center(WIDTH)\n @output.puts '-----------------------'.center(WIDTH)\n @output.puts # spacer\n @output.print 'Command: '\n end",
"def print_menu\n puts \"\\nMAIN MENU\"\n puts \"add (+)\"\n puts \"subtract (-)\"\n puts \"multiply (*)\"\n puts \"divide (/)\"\n puts \"modulo (%)\"\n puts \"exponify (^)\"\nend",
"def createMenu\n\n # File menu\n recordAction = @actions.addNew(i18n('Start Download'), self, \\\n { :icon => 'arrow-down', :triggered => :startDownload })\n reloadStyleAction = @actions.addNew(i18n('&Reload StyleSheet'), self, \\\n { :icon => 'view-refresh', :shortCut => 'Ctrl+R', :triggered => :reloadStyleSheet })\n clearStyleAction = @actions.addNew(i18n('&Clear StyleSheet'), self, \\\n { :icon => 'list-remove', :shortCut => 'Ctrl+L', :triggered => :clearStyleSheet })\n quitAction = @actions.addNew(i18n('&Quit'), self, \\\n { :icon => 'application-exit', :shortCut => 'Ctrl+Q', :triggered => :close })\n\n updateScheduleAction = @actions.addNew(i18n('Update Schedule'), @scheduleWin, \\\n { :shortCut => 'Ctrl+U', :triggered => :updateAllFilters })\n\n fileMenu = KDE::Menu.new('&File', self)\n fileMenu.addAction(recordAction)\n fileMenu.addAction(reloadStyleAction)\n fileMenu.addAction(clearStyleAction)\n fileMenu.addAction(updateScheduleAction)\n fileMenu.addAction(quitAction)\n\n\n # settings menu\n playerDockAction = @playerDock.toggleViewAction\n playerDockAction.text = i18n('Show Player')\n configureAppAction = @actions.addNew(i18n('Configure %s') % APP_NAME, self, \\\n { :icon => 'configure', :shortCut => 'F2', :triggered => :configureApp })\n\n settingsMenu = KDE::Menu.new(i18n('&Settings'), self)\n settingsMenu.addAction(playerDockAction)\n settingsMenu.addSeparator\n settingsMenu.addAction(configureAppAction)\n\n\n # Help menu\n aboutDlg = KDE::AboutApplicationDialog.new(KDE::CmdLineArgs.aboutData)\n openAboutAction = @actions.addNew(i18n('About %s') % APP_NAME, self, \\\n { :icon => 'irecorder', :triggered =>[aboutDlg, :exec] })\n openDocUrlAction = @actions.addNew(i18n('Open Document Wiki'), self, \\\n { :icon => 'help-contents', :triggered =>:openDocUrl})\n openReportIssueUrlAction = @actions.addNew(i18n('Report Bug'), self, \\\n { :icon => 'tools-report-bug', :triggered =>:openReportIssueUrl })\n openRdocAction = @actions.addNew(i18n('Open Rdoc'), self, \\\n { :icon => 'help-contents', :triggered =>:openRdoc })\n openSourceAction = @actions.addNew(i18n('Open Source Folder'), self, \\\n { :icon => 'document-open-folder', :triggered =>:openSource })\n\n\n helpMenu = KDE::Menu.new(i18n('&Help'), self)\n helpMenu.addAction(openDocUrlAction)\n helpMenu.addAction(openReportIssueUrlAction)\n helpMenu.addAction(openRdocAction)\n helpMenu.addAction(openSourceAction)\n helpMenu.addSeparator\n helpMenu.addAction(openAboutAction)\n\n # insert menus in MenuBar\n menu = KDE::MenuBar.new\n menu.addMenu( fileMenu )\n menu.addMenu( settingsMenu )\n menu.addSeparator\n menu.addMenu( helpMenu )\n setMenuBar(menu)\n end",
"def menuScreen\n @levelNo=1\n clearScreen\n puts \"You are at the menu for Sokoban\"\n puts \"To quick play: Press 'p'\"\n puts \"To choose a level: Press 'c'\"\n puts \"To stop: Press 'q'\"\n charPressedInMenu\nend",
"def print_menu\n puts \"User's Menu\\n-----------\"\n puts \"1. Input the students\"\n puts \"2. Show the students\"\n puts \"3. Save the list to a file\"\n puts \"4. Load the list from a file\"\n puts \"9. Exit\" # 9 because we'll be adding more items\nend",
"def ivr_menu\n begin\n _call = direction\n if _call.present?\n urls = _call.ivr_menu(params) if defined?(_call.ivr_menu)\n end\n rescue => e\n logger.error e.message\n logger.error e.backtrace.join(\"\\n\")\n end\n render :plain => urls, content_type: \"text/plain\", :status => 200\n end",
"def print_menu\n self.menu_items.each do |item|\n p \"#{item.dish_name.upcase} 😋 $#{item.price}\"\n end\n end",
"def show_in_menu?\n true\n end",
"def menu_options\n system \"clear\"\n puts \"~~~ Welcome #{@user.username} to the Main Menu ~~~\\n\\n\" \n puts \"{1} Continue from previous story \"\n puts \"{2} Create new story\"\n puts \"{3} Delete a story\"\n puts \"{4} Tutorial\"\n puts \"{5} End My Session\"\nend",
"def menu\n draw_line\n puts \" _______________________________________________________ \"\n puts \" | |\"\n puts \" | ~~THE QUEST~~ |\"\n puts \" | |\"\n puts \" | >>>>>>>>>>> 1. Thebes |\"\n puts \" | >>> | 2. Troy |\"\n puts \" | | = | 3. Hades |\"\n puts \" | | __| 4. GO HOME |\"\n puts \" | | -| |\"\n puts \" | |______| |\"\n puts \" | |\"\n puts \" |_______________________________________________________|\"\nend",
"def menu_selection \nend",
"def menu\n puts \"- Type in a #{\"Nintendo Character\".colorize(:red)} | #{\"Game Series\".colorize(:blue)} | #{\"Amiibo Series\".colorize(:green)}\\n\\n\"\n puts \"- Type #{'1'.colorize(:yellow)} for a list of all the Game Series included in the Amiibo collection\"\n puts \"- Type #{'2'.colorize(:yellow)} for a list of all the Amiibo Series included in the Amiibo collection\"\n puts \"- Type #{'3'.colorize(:yellow)} for a list of all the Characters included in Amiibo collection\"\n puts \"- Type #{'4'.colorize(:yellow)} for a list of ALL Amiibos collection\\n\\n\"\n puts \"- Type #{'exit'.colorize(:yellow)} to exit the CLI\\n\\n\"\n puts \"--------------------------------------------------------------------------------\\n\\n\"\n sleep(2)\n end",
"def showCommandingMenu _args\n \"showCommandingMenu _args;\" \n end",
"def main_menu\n puts\"(b) - basic calculator\"\n puts\"(a) - advanced calculator\"\n puts\"(bmi) - body mass index\"\n puts\"(t) - trip calculator\"\n puts\"(m) - morgage\"\n puts\"(q) - quit\"\nend",
"def main_menu\n puts \"Main Menu\"\n puts \"(a) - Basic calculator\"\n puts \"(b) - Advanced calculator\"\n puts \"(c) - Special calculators\"\n puts \"(q) - Quit\"\nend",
"def menu_items\n\n menu.items(self)\n\n end",
"def main_menu()\n system 'clear'\n loop do\n headline(\"My Petsitter App\")\n puts \"#{@emoji[:smiling_cat_face_with_open_mouth]} Welcome! #{@emoji[:dog_face]}\".colorize(:bold)\n puts @headline\n input = @prompt.select('Menu:') do |menu|\n menu.choice name: 'Pet Sitters', value: \"PET_SITTERS\"\n menu.choice name: 'Clients', value: \"CLIENTS\"\n menu.choice name: 'Jobs', value: \"JOBS\"\n menu.choice name: 'Logout', value: \"EXIT\"\n end\n puts '-' * 20\n go_to(input)\n end\n end",
"def menu _command\n send_cmd(\"menu #{_command}\")\n end",
"def main_menu\n\t\tputs '################################'\n\t\tputs '######### Tic Tac Toe ##########'\n\t\tputs '################################'\n\t\tputs '================================'\n\t\tputs '== Choose your weapon warrior =='\n\t\tputs '================================'\n\t\tputs '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'\n\t\tputs '^^^^^^ Type Your Choice: ^^^^^^^'\n\t\tputs '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'\n\t\tputs '$$$$$$$$$$$ 1. \"X\" $$$$$$$$$$$$$'\n\t\tputs '$$$$$$$$$$$ 2. \"O\" $$$$$$$$$$$$$'\n\t\tputs '--------------------------------'\n\tend",
"def menu ()\n menu_string = \"1. Show Menu\\n\"\n menu_string += \"2. Add Numbers\\n\"\n menu_string += \"3. Subtract Numbers\\n\"\n menu_string += \"4. Quit\\n\"\n return menu_string\nend",
"def show_main_menu\n puts \"Welcome to Contacts APP, What's next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" show - Enter ID to show detail of a contact\"\n puts \" find - Find contacts by name\"\n puts \" add - Add phone numbers\"\n puts \" save - Save contact to CSV file\"\n puts \" quit - Save & Exit Application\"\n print \"> \"\n end",
"def start_menu\n printf \"\\nPrograma para a disciplina de LPD\\n\"\n printf \"Choose one option\\n\"\n printf \"------------------------------------\\n\"\n printf \"1) Insert user\\n\"\n printf \"2) Login user\\n\"\n printf \"3) Delete user\\n\"\n printf \"0) Exit\\n\"\nend",
"def print_menu\n MENU.each do |i| \n # in general, avoid printing things.\n # Return them instead and let the code that called it\n # to return it\n puts \"#{i[:name]} costs #{i[:price]}\"\n end\n end",
"def menu_router\n selection = display_menu\n case selection\n when 'My List'\n my_list\n when 'Recommendations'\n recommendations_menu\n else\n case_menu(selection)\n end\n end",
"def show_main_menu\n puts \"Welcome to Contacts APP, What's next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" update - Enter ID to update a contact\"\n puts \" show - Enter ID to show detail of a contact\"\n puts \" find - Find contacts by name\"\n puts \" save - Save contact to CSV file\"\n puts \" quit - Save & Exit Application\"\n print \"> \"\n end",
"def assigned_menu\n\n end",
"def render_menu\n output = []\n\n @paginator.paginate(@choices, @page_active, @per_page) do |choice, index|\n num = (index + 1).to_s + @enum + \" \"\n selected = num.to_s + choice.name.to_s\n output << if index + 1 == @active && !choice.disabled?\n (\" \" * 2) + @prompt.decorate(selected, @active_color)\n elsif choice.disabled?\n @prompt.decorate(@symbols[:cross], :red) + \" \" +\n selected + \" \" + choice.disabled.to_s\n else\n (\" \" * 2) + selected\n end\n output << \"\\n\"\n end\n\n output.join\n end",
"def action\n puts \"\\nHelp menu\"\n puts '=' * 'Help menu'.length + \"\\n\\n\"\n puts \" Command \\t Description\"\n puts \" \" + '-' * 'Command'.length + \" \\t \" + '-' * 'Description'.length\n commands.map {|cmd , desc| puts \" #{cmd} \\t #{desc}\"}\n puts \"\\n\\n\"\n end",
"def display_and_run\n\n # prints the menu name and waits briefly\n @dp.d_print(@menu_name + \":^^\")\n i = 1\n\n # displays the options\n @options.each do |option|\n print(i.to_s + ' ')\n puts(option.get_name)\n i += 1\n end\n\n # prompt and get valid input from the player\n print(@prompt_string)\n action = get_action\n\n # runs the selected action\n action.call :menu_select\n\n # some test code\n print(\"here\")\n end",
"def display_menu\n puts \"\\nEnter option: \"\n puts '1. List Existing Threads'\n puts '2. List Single Thread'\n puts '3. Create new Thread'\n puts 'Q. Quit'\n end",
"def main_menu\n puts \"---------------Animal shelter 4.5A-----------\"\n puts\n puts \"[1] List clients\"\n puts \"[2] List animals for adoption\"\n puts \"[3] Add a new client\"\n puts \"[4] Add a new animal\"\n puts\n puts\n puts \"[5] exit\"\n puts \"---------------------------------------------\"\nend",
"def render_menus \n# student_menu = add_menu('#{@studentb.full_name}')\n student_menu = add_menu('#{image_tag(@studentb.thumb_image,:style=>\";float:left;height:25px;margin-right:10px;\") + \" \" + @studentb.full_name + \" \"}',:action=>'profile')\n student_menu.add_submenu('Profile',:action=>'profile')\n student_menu.add_submenu('Photos',:action=>'photo',:if=>\"@studentb.visible_album_counts(@me) > 0\") \n student_menu.add_submenu('Binder',:action=>'show_notes',:if=>\"@studentb.notes.not_anonymous.size > 0\") \n \n end",
"def generate_menu\n @items = []\n @x = @window.width / 3 + Const::FONT_SMALL_SIZE\n @y = @title_image.height * @img_size_factor + Const::GAME_WIN_GAP\n n_g = proc { @window.state = GameState.new(@window, @window.width / 3, 40) }\n cr_n = proc { @window.state = NetSetupState.new(@window) }\n j_n = proc { @window.state = NetJoinState.new(@window) }\n exit = proc { @window.close }\n @items << MenuItem.new(@window, Const::MENU_NEW, 0, n_g, @font, @x, @y)\n @items << MenuItem.new(@window, Const::MENU_CREATE, 1, cr_n, @font, @x, @y)\n @items << MenuItem.new(@window, Const::MENU_JOIN, 2, j_n, @font, @x, @y)\n @items << MenuItem.new(@window, Const::MENU_QUIT, 3, exit, @font, @x, @y)\n end",
"def display\n again = false\n message = ''\n puts \"\\n\" * 100\n # Ruby is magic in this respect. The ljust() (left justify), rjust (right justify), and center() methods\n # are fantastical. It's so easy to build a nice looking menu that there really isn't any reason not to.\n begin\n # This section deals with the top line, title, and separator line\n puts \"\\t\\t╔\".ljust(@max_width, '═') + '╗'\n puts \"\\t\\t║#{@title.center(@max_width-3)}║\"\n puts \"#{\"\\t\\t╠\".ljust(@max_width, '═')}╣\"\n puts \"#{\"\\t\\t║\".ljust(@max_width)}║\"\n\n # This section prints out the strings in the array and enumerates them and then puts an exit option\n # as the last item.\n (0..@num_items).each { |i|\n if i < @num_items\n puts \"\\t\\t║ #{(i+1).to_s} #{'.' * 10} #{@choices[i]}\".ljust(@max_width) + '║'\n else\n puts \"#{\"\\t\\t║ #{(i+1).to_s} #{'.' * 10} Exit\".ljust(@max_width)}║\"\n end\n }\n\n # This section pads the bottom and puts in the bottom line and corners.\n puts \"#{\"\\t\\t║\".ljust(@max_width)}║\"\n puts \"#{\"\\t\\t╚\".ljust(@max_width, '═')}╝\"\n print \"#{\"\\n\" * 20}\"\n\n # If the user entered an invalid response (previously), print out a message\n if again\n puts message\n again = false\n end\n\n # Get the user response and convert it to an integer.\n print 'Your choice: '\n choice = gets.to_i\n\n # Validate the response. If invalid, set a message, clear the screen, and make it so the menu\n # displays again by setting the again bool flag to true.\n if choice < 1 or choice > @num_items + 1\n message = \"Invalid choice. Please enter a value between 1 and #{@num_items+1}\"\n puts \"\\n\" * 100\n again = true\n end\n\n # If the again flag is set to true, display the menu again.\n end while again\n\n # Return choice to the caller\n choice\n end",
"def display_menu\n print \"---------------------------------------------------------------------------------\\n\"\n print \"\\nChoose an option below by entering its corresponding number or type the name\"\n print \" of a job to get more details about it: \\n\"\n print \"1. Sort the jobs by minimum salary\\n\"\n print \"2. Sort the jobs by maximum salary\\n\"\n print \"3. Sort the jobs by upcoming application deadline\\n\"\n print \"4. Sort the jobs by posting start date\\n\"\n print \"5. Sort the jobs by posting end date\\n\"\n print \"6. Sort the jobs by positions available\\n\"\n print \"7. Print the job full time/ part time information\\n\"\n print \"8. Print the job temporary/regular information\\n\"\n print \"9. Compare two jobs by typing the first job, and then second job\\n\"\n print \"10. To enter a new keyword to search for a new list of jobs\\n\"\n print \"Type 'quit' to end the program.\\n\"\n end",
"def show_menu\n\n menu_pick = @prompt.select('Please select a menu option: ') do |menu|\n menu.choice 'Show Events by Country', 'find by country'\n menu.choice 'Show Events by City', 'find by city'\n menu.choice 'Show Events By Date', 'find by date'\n menu.choice 'Get Event Info By Name', 'find by name'\n menu.choice 'Exit', 'exit'\n end\n\n return menu_pick if menu_pick == 'exit'\n\n event = handle_input(menu_pick)\n\n display_info(event) if event\n\n end",
"def print_main_menu\n puts \"1. Add a contact\"\n puts \"2. Modify a contact\"\n puts \"3. Display all contacts\"\n puts \"4. Display a contact\"\n puts \"5. Display contact attributes\"\n puts \"6. Delete a contact\"\n puts \"7. Exit\"\n end",
"def build_menu\n build_menu_title\n build_menu_body\n build_application\n end"
] | [
"0.7839964",
"0.7779688",
"0.7712035",
"0.7701799",
"0.76952076",
"0.76749206",
"0.7627202",
"0.74744934",
"0.7403855",
"0.74017036",
"0.7373082",
"0.7348887",
"0.7304579",
"0.72313625",
"0.7227436",
"0.71691966",
"0.71471554",
"0.7143775",
"0.7114401",
"0.708735",
"0.70659804",
"0.7061614",
"0.70601434",
"0.70486337",
"0.7037377",
"0.7032427",
"0.7031568",
"0.7028904",
"0.7023099",
"0.7014815",
"0.70119053",
"0.7010111",
"0.6999988",
"0.69974047",
"0.6996563",
"0.6943942",
"0.6936496",
"0.6933225",
"0.69214463",
"0.69176954",
"0.688698",
"0.68837196",
"0.6882274",
"0.6876526",
"0.6850726",
"0.68427134",
"0.6836603",
"0.68298835",
"0.6820978",
"0.68168765",
"0.6816355",
"0.6808358",
"0.680653",
"0.6796682",
"0.67941964",
"0.67725885",
"0.6771664",
"0.6763255",
"0.6761758",
"0.67589605",
"0.67487025",
"0.67453295",
"0.673092",
"0.6727373",
"0.6724369",
"0.672182",
"0.6720126",
"0.6718156",
"0.671459",
"0.67064214",
"0.66941136",
"0.6693836",
"0.6693571",
"0.66866106",
"0.66696346",
"0.6663172",
"0.6662068",
"0.66592216",
"0.66592026",
"0.6658112",
"0.66399854",
"0.66347754",
"0.6631424",
"0.6630954",
"0.6622905",
"0.6621232",
"0.6605776",
"0.6605141",
"0.6602943",
"0.65909684",
"0.6576702",
"0.65744656",
"0.65699655",
"0.65669286",
"0.65664375",
"0.6563179",
"0.6560906",
"0.655373",
"0.6552447",
"0.65296394",
"0.65260905"
] | 0.0 | -1 |
Method used to find the option selected by the user in main menu | def get_choice input
if input == "s"
# clear the screen
system "clear"
# start game
start_game
elsif input == "c"
change_size
elsif input == "q"
# terminate the program
exit
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_option\n print_menu\n @choice = gets.chomp\n perform_selection\n end",
"def selected\r\n assert_exists\r\n #@option.selected\r\n option_selected\r\n end",
"def menu_selection \nend",
"def object_value_of_selected_item\n if @options_menu.nil?\n return nil\n end\n\n @options[@options_menu.selection]\n end",
"def menu_selection\n PROMPT.select('Please make a selection!'.colorize(:magenta)) do |menu|\n menu.choice({ name: \"Track Today's Mood\", value: '1' })\n menu.choice({ name: 'View Tracked Moods', value: '2' })\n menu.choice({ name: 'Good Vibes Please', value: '3' })\n menu.choice({ name: 'Exit', value: '4' })\n end\n end",
"def main_menu\n @ui.input_1_change\n @ui.user_input1.downcase\n unless %w[trains routes stations cars].include? @ui.user_input1\n puts 'There is no such option in the main menu.'\n end\n main_menu_choose_option(@ui.user_input1)\n end",
"def main_menu_selection\n puts \"\"\n PROMPT.select(\"What would you like to do?\") do |menu|\n menu.choice \"Download this week's quiz\", 1\n menu.choice \"Download last week's quiz\", 2\n menu.choice \"Exit app\", 3\n end\n end",
"def main_menu_prompt\n welcome\n menu = [\n { name: \"View list of Recipes\", value: 1},\n { name: \"Input a new recipe into the recipe book\", value: 2},\n { name: \"Edit a recipe from the recipe book\", value: 3},\n { name: \"Display Help information\", value: 4},\n { name: \"Exit\", value: 5}\n ]\nmm_choice = $prompt.select(\"Please select an option\", menu)\nreturn mm_choice\nend",
"def main_menu\n main_menu_options = {'Interact with Existing Kits' => :list_and_select_kit,\n 'Create a new Kit' => :prompt_kit_params, \n 'Quit' => :quit}\n \n op = @io.select_from_options(\"What would you like to do?\", main_menu_options)\n @operation_stack.unshift op\n \n # return nil, because there's nothing to pass onto the next method\n return\n end",
"def get_selected(key)\n option = find(key)\n\n if option.is_a?(Option)\n _debug(\"get_selected: found Option #{option}\")\n option\n elsif option\n _debug(\"get_selected: found OptionCollection #{option}\")\n option\n else\n raise MyRailsHelpers::ParamsHelper::Error, \"Option for '#{key}' not found in (#{@opts.inspect})\"\n end\n end",
"def select_option\n return $prompt.select(\"What's your option?\",\n [\"Ladder\", \"Team's info\", \"Play a game!\", \"Training\", \"Exit\"])\n \nend",
"def main_menu\n selection = input(@menu) {|o| (1..2) === o.to_i }.to_i\n \n if 1 == selection\n :continue\n elsif 2 == selection\n :quit\n end\n end",
"def wiki_menu_select\n wiki_menu\n prompt = TTY::Prompt.new\n menu_choices = [\n \" [1] Search by Character\",\n \" [2] Search by House\",\n \" [3] Main Menu\",\n \" [4] Exit App\"\n ]\n prompt.select(\" \", menu_choices)\nend",
"def main_menu\n options = [\"View recipe book\", \"Search by ingredient\", \"Quit app\"]\n answer = @prompt.select(\"Choose an option:\".colorize(:color => :blue), (options))\n if answer == options[0]\n select_recipe_from_book(@user.view_recipe_book)\n elsif answer == options[1]\n find_recipe\n elsif answer == options[2]\n puts ''\n puts \"Thanks for using Feed. See you next time!\".colorize(:color => :blue)\n system exit\n end\nend",
"def user_select(items)\n h.choose do |menu|\n menu.index = :number\n menu.prompt = 'Please Choose One:'\n menu.select_by = :index_or_name\n items.each do |item|\n menu.choice item.to_sym do |command|\n ui.msg \"Using: #{command}\"\n selected = command.to_s\n end\n end\n menu.choice :all do return :all end\n menu.choice :exit do exit 1 end\n end\n end",
"def select_menu_item app, *path\n app.application.select_menu_item *path\n end",
"def user_select(items)\n choose do |menu|\n menu.index = :number\n menu.prompt = \"Please Choose One:\"\n menu.select_by = :index_or_name\n items.each do |item|\n menu.choice item.to_sym do |command| \n say \"Using: #{command}\" \n selected = command.to_s\n end\n end\n menu.choice :exit do exit 1 end\n end\n end",
"def get_menu_choice\n\t\tchoices = [\"1. Play Hangman\", \"2. Load Saved Game\", \"3. Delete Saved Game\",\n\t\t\t\"4. List Saved Games\", \"5. Quit\"]\n\t\tdisplay_menu choices\n\n\t\twhile true\n\t\t\tprint \"Enter Selection (1 - #{ choices.length }): \"\n\t\t\tchoice = gets.chomp.to_i\n\t\t\treturn choice if choice.between?(1, choices.length)\n\t\tend\n\tend",
"def selected\n find(&:selected?)\n end",
"def case_menu(selection)\n case selection\n when 'Playlist'\n @playlist.menu\n when 'Account Details'\n account_details\n when 'Exit'\n p \"Is this exiting?\"\n end\n end",
"def main_menu\n prompt.select(\"What would you like to do today #{user.name}?\") do |menu|\n menu.choice \"Choose Protein\", -> {choose_protein}\n menu.choice \"Exit!\", -> {exit_helper}\n menu.choice \"Delete Account!?!?\", -> {delete_account_helper}\n end\n end",
"def find_item(selected_item)\n return find(selected_item)\n end",
"def get_user_selection\n puts 'Choice (Press enter for first choice):'\n loop do\n choice = STDIN.gets.strip.to_i\n if !choice.nil? && possible_moves.each_index.to_a.include?(choice)\n return choice\n else\n puts \"Please select valid choice.\"\n end\n end\n end",
"def display_menu\n puts \"Choose from the following options: \\n\n to find a candidate, type 'find id' (ex. find 1)\n to view all candidates, type 'all'\n to view all qualified candidates, type 'qualified'\n to exit, type 'quit' \n to view menu, type 'menu' \\n\\n\"\nend",
"def situation_selection\n $prompt.select(\"Welcome to Ticket Master! What would you like to do?\") do |menu|\n menu.choice 'Sign up'\n menu.choice 'Login'\n menu.choice 'Terminate program'\n end\nend",
"def menu\n\toption = gets.chomp.downcase\nend",
"def selection_menu\n h = {\n a: :select_all,\n u: :unselect_all,\n s: :toggle_select,\n '*' => 'toggle_multiple_selection',\n 'x' => 'toggle_visual_mode',\n 'm' => 'toggle_selection_mode',\n v: :view_selected_files\n }\n menu 'Selection Menu', h\nend",
"def get_selection(message, options, board, opponent)\n loop do\n puts \"#{message}#{options}\"\n user_input = gets.chomp.downcase\n if options.keys.include?(user_input.to_i)\n puts \"you chose #{options[user_input.to_i]}\"\n return user_input\n else\n handle_non_move_choice(user_input, board, opponent)\n end\n end\n end",
"def selection(choice)\n case choice\n when 1\n view_entries\n when 2\n manual_add_entry\n when 3\n puts 'Awaiting Build...'\n hold_screen\n # search_menu\n when 4\n puts 'Awaiting Build...'\n hold_screen\n # file_selection\n end\n end",
"def present_menu\n puts \"-------------------\"\n puts t('select_features')\n puts t('feature_one')\n puts t('feature_two')\n puts t('feature_three')\n puts t('exit_option')\n\n selected_feature = gets.to_i\n\n case selected_feature\n when FEATURE_OPTION_MAJOR_STATES\n print_major_states\n when FEATURE_OPTION_AVERAGE_POP\n print_average_population_for_state\n when FEATURE_OPTION_BOUNDARY_CITIES\n print_boundary_cities_for_state\n when FEATURE_OPTION_EXIT\n return\n else\n puts t('invalid_option', option: selected_feature)\n run\n end\n end",
"def choice\n @choice\n end",
"def show_menu\n\n menu_pick = @prompt.select('Please select a menu option: ') do |menu|\n menu.choice 'Show Events by Country', 'find by country'\n menu.choice 'Show Events by City', 'find by city'\n menu.choice 'Show Events By Date', 'find by date'\n menu.choice 'Get Event Info By Name', 'find by name'\n menu.choice 'Exit', 'exit'\n end\n\n return menu_pick if menu_pick == 'exit'\n\n event = handle_input(menu_pick)\n\n display_info(event) if event\n\n end",
"def manage_account_menu\n choice = @prompt.select(\"Please choose from the following options:\") do |menu|\n menu.choice 'Change my name'\n menu.choice 'Change my password'\n menu.choice 'Delete my account'.blue\n menu.choice \"Back to Main Menu\"\n end\n\n if choice == \"Change my name\"\n change_name\n elsif choice == \"Change my password\"\n change_password\n elsif choice == \"Delete my account\".blue\n delete_account\n elsif choice == \"Back to Main Menu\"\n start_menu\n end\nend",
"def main_menu\n @active = 0\n @prompt.select(\"\\nWhat would you like to do?\\n\".blue) do |menu|\n menu.choice \"Check out what's on today\", -> {today_menu} \n menu.choice \"Check out things to do on the weekend\", -> {weekend_menu}\n menu.choice \"Look at my favourites\", -> {display_favorites}\n menu.choice \"Exit\".red, -> {leave_app} \n end \n end",
"def list_option\n list_politicians\n list_voters\n puts\n puts \"(R)eturn to the main menu?\".center(80).green\n menu_return = gets\n end",
"def display_options_menu\n prompt = TTY::Prompt.new\n display_options_menu = prompt.select('Please select an option:') do |menu| \n menu.choice 'Add Code'\n menu.choice 'Edit Code'\n menu.choice 'Remove Code'\n menu.choice 'Search'\n menu.choice 'Help'\n menu.choice 'Exit'\n end\nend",
"def selected_text\n send_command_to_control(\"GetSelected\")\n end",
"def find_game\n prompt = TTY::Prompt.new\n prompt.select(\"Would you like to search by..\") do |menu|\n menu.choice \"System\", -> {view_by_system}\n menu.choice \"Category\", -> {view_by_category}\n menu.choice \"Back to Main Menu\", -> {welcome}\n end\n end",
"def selection(input, user)\n case input\n when 1\n get_number_of_random_recipes(user)\n when 2\n recipe_hash = run_option_find_recipe_by_name\n run_sub_menu_option(user, recipe_hash)\n when 3\n run_option_create(user)\n when 4\n run_option_view_favs(user)\n end\n end",
"def find_selected #:nodoc:\n ret = DcBigMenu.find( @parent.page.menu_id ) if @parent.page.menu_id\n while ret and ret.parent != nil\n ret = DcBigMenu.find( ret.parent )\n end\n# return first if not found (something is wrong)\n# p ret\n ret ||= DcBigMenu.where(dc_site_id: @site._id, parent: nil, active: true).limit(1).first\nend",
"def selection\n eval_param(:selection)\n end",
"def selected_item\n get_content()[focussed_index()]\n end",
"def user_choice_of_object_in_class(class_object)\n create_menu = Menu.new(\"Which #{class_object.name} do you want to look up?\")\n all = class_object.all\n all.each_with_index do |object, x|\n create_menu.add_menu_item({key_user_returns: x + 1, user_message: object.to_s, do_if_chosen: \n [object]})\n end\n return run_menu(create_menu)[0]\n end",
"def selected\n @selected\n end",
"def main_menu\n while true\n print_main_menu\n user_selected =gets.to_i\n call_option(user_selected)\n end\n end",
"def search(shelters)\n\n while true\n\n search_choice = TTY::Prompt.new.select(\"Please select from the kitty search menu:\\n\".colorize(:magenta), \n cycle: true, marker: '>', echo: false) do |menu| \n \n menu.choice('Location', 1)\n menu.choice('Cat Feature', 2)\n menu.choice('Return to main menu', 3)\n\n #puts \"Checking for the value of search_choice inside search method #{search_choice}\"\n\n case search_choice\n when 1\n puts \"Selected option 1\"\n search_by_location(shelters)\n\n when 2\n search_by_feature(shelters)\n\n when 3\n puts \"menu\"\n return false\n\n end # of case statement\n \n end # of do |menu|\n end # of while loop\nend",
"def selected_item\n get_content()[focussed_index()]\n end",
"def main_menu\n while true\n print_main_menu\n user_selected = gets.chomp.to_s\n call_option(user_selected)\n end\n end",
"def get_minimenu_item(minimenu, selection_type = nil)\r\n #initialize selection_type if needed\r\n selection_type = 0 if selection_type == nil\r\n #flag window as waiting\r\n @waiting = true\r\n #create the minimenu sprite\r\n menu = Sprite_ZeldaCMS_Minimenu.new(minimenu, @cursor)\r\n menu.x, menu.y = @xy_pos[@index]\r\n #loop until an item has been selected or cancelled\r\n loop do\r\n Graphics.update\r\n Input.update\r\n menu.update\r\n break if Input.trigger(InputC) Input.trigger(InputB) \r\n Input.trigger(XAS_COMMANDITEM_ACTION[0]) \r\n Input.trigger(XAS_COMMANDITEM_ACTION[1]) \r\n Input.trigger(XAS_COMMANDITEM_ACTION[2])\r\n end\r\n #get the item\r\n item = menu.item\r\n item = nil if Input.trigger(InputB)\r\n selection_type = 0 if Input.trigger(XAS_COMMANDITEM_ACTION[0])\r\n selection_type = 1 if Input.trigger(XAS_COMMANDITEM_ACTION[1])\r\n selection_type = 2 if Input.trigger(XAS_COMMANDITEM_ACTION[2])\r\n #dispose the menu\r\n menu.dispose\r\n #move menu cursor\r\n @cursor.x, @cursor.y = @xy_pos[@index][0], @xy_pos[@index][1]\r\n #return the item\r\n return item, selection_type\r\n end",
"def get_selection\n # get input from user convert to int\n puts \"Select a value\"\n input = gets.strip\n # if input is not a valid integer it will go to rescue\n selection = Integer(input)\n # check if input is int, maybe check is a valid int ie if we four option in our menu the value 1,2,3,4\n if (selection >= 1 && selection <= @menu[:options].size)\n return selection\n else\n puts \"#{selection} need to be in between 1 and #{@menu[:options].size}, please try again\"\n self.get_selection\n end\n rescue ArgumentError\n #if a ArgumentError occurs above than ruby will come here instead of throwing error\n puts \"#{input} is not a integer please select a integer\"\n self.get_selection\n end",
"def main_menu\n menu_options = [\"Start exploring\", \"Check Inventory\", \"Check Your Score\", \"Go to Pokemon Center\", \"Quit\"]\n menu_prompt = Interactivity.mainMenu \n \n if user.pokemon == nil\n menu_options.shift()\n menu_options.unshift(\"Choose a Pokemon and start exploring\")\n elsif self.user_current_location\n menu_options.shift()\n menu_options.unshift(\"Keep Exploring\")\n end\n \n choice = prompt.select(menu_prompt, menu_options) \n if choice == \"Start exploring\" || choice == \"Choose a Pokemon and start exploring\" || choice == \"Keep Exploring\"\n self.trainer_chooses_pokemon if user.pokemon == nil \n self.trainer_chooses_town\n self.exploring_town\n elsif choice == \"Check Inventory\"\n puts \"MANAGE INVENTORY - CHANGE POKEMONS AROUND\"\n elsif choice == \"Go to Pokemon Center\"\n self.pokemon_center\n elsif choice == \"Check Your Score\"\n puts \"CHECK YOUR SCORE\"\n else\n Interactivity.quit\n end\n end",
"def select_for_item(item)\n @cursor_fix = item.for_user?\n @cursor_all = item.for_all?\n if @cursor_fix\n select($game_party.menu_actor.index)\n elsif @cursor_all\n select(0)\n else\n select_last\n end\n end",
"def option_select \n require \"tty-prompt\"\n prompt = TTY::Prompt.new\n\n puts \"\\n \\n\"\n\n prompt.select(\"What would you like to do? Choose from the options below:\") do |menu|\n menu.choice 'View my favorite players' #MAIN MENU OPTION 1 - SHOWS USER'S FAVORITE PLAYERS\n menu.choice 'Add a new favorite player to my account' #MAIN MENU OPTION 2\n menu.choice 'Delete a favorite player from my account' #MAIN MENU OPTION 3\n menu.choice 'View all fans of a specifc player' #MAIN MENU OPTION 4\n menu.choice 'View favorite players of another fan' #MAIN MENU OPTION 5\n menu.choice 'View players from a specific club' #MAIN MENU OPTION 6\n menu.choice 'View most expensive player from a specifc premier league team' #MAIN MENU OPTION 7\n menu.choice 'I just got a season ticket. Update my club season ticket status.' #MAIN MENU OPTION 8\n menu.choice 'exit' #MAIN MENU OPTION EXIT\n end\n\nend",
"def getSelectedItem()\n # ennek mindig az elso oszlop itemjet kell visszaadni\n #midx = @tv.selectionModel.currentIndex\n mi = @treeview.selectionModel.selectedRows.first\n return unless mi\n item = mi.model.itemFromIndex mi\n #puts \"getSelectedItem:\", mi, item\n return item, mi\n end",
"def choice\n @choice\n end",
"def selected?; end",
"def selected?; end",
"def selected; end",
"def menu(selected)\n @menu = selected\n end",
"def menu_select(name, values)\n result = false\n say(\"\\n#{name.capitalize} Selection\")\n choose do |menu|\n menu.prompt = \"Please select #{name}: \"\n menu.index = :number\n menu.index_suffix = ') '\n menu.choice(:quit, 'Quit') {result = false}\n menu.choices(*(values.collect{|v| field_name_choice(v)})) do |command, details|\n result = command.split(\" \").first\n end\n end\n result\n end",
"def present_menu_options\n space(1)\n puts \"Choose an option from the list below.\"\n space(1)\n puts '1. Search for events by city'\n puts '2. Search for events by artist or sports team'\n puts '3. See what I have coming up'\n puts '4. Delete my account'\n puts '5. Exit'\n space(1)\n pick_option\nend",
"def main_menu_choose_option(user_input)\n case user_input\n when 'trains'\n manage_trains\n when 'routes'\n manage_routes\n when 'stations'\n manage_stations\n when 'cars'\n manage_cars\n else\n @ui.wrong_input_msg\n end\n end",
"def select_menu(path)\r\n menu_item(path).click\r\n end",
"def options() @page.find(input_elements[:options]) end",
"def display_main_menu_choice\n #The disabled choice will be displayed with a cross ✘ character next to it and followed by an explanation:\n menu_choices = [\n 'First Time User, Want To Register',\n 'Already A Registered User, Want To Login',\n # { name: 'Goro', disabled: '(injury)' },\n 'Do Not Wish To Register, Just Browsing',\n 'Looking For Info About The App',\n 'Nothing Really, Spare Me Your @?%#&?|%!'\n ]\n choice_msg = 'What Will It Be, We Offer A Great Many Choices!'\n # system \"say #{choice_msg}\"\n main_menu_choice = prompt.select('What Will It Be, We Offer A Great Many Choices!'.colorize(:color => :light_blue), menu_choices)\nend",
"def option_selected\n puts \"Your option has been selected successfully!\"\nend",
"def get_selected_item\n @items[@selected_slot]\n end",
"def display_guest_options_menu\n prompt = TTY::Prompt.new\n display_options_menu = prompt.select('Please select an option:') do |menu| \n menu.choice 'Search'\n menu.choice 'Favourites'\n menu.choice 'Help'\n menu.choice 'Exit'\n end\nend",
"def interface\r\n clear\r\n menu_banner\r\n puts\r\n options = [\r\n { name: 'New Game', value: -> { get_user_selection } },\r\n { name: 'Custom quiz collections', value: -> { custom_collection } },\r\n { name: 'History', value: -> { history_select } },\r\n { name: 'Exit', value: lambda {\r\n clear\r\n exit_banner\r\n exit\r\n } }\r\n ]\r\n option = @prompt.select(\"Please select from the following options.\\n\\n\", options,\r\n help: \"(Select with pressing ↑/↓ arrow keys, and then pressing Enter)\\n\\n\", show_help: :always)\r\n end",
"def main_menu\n\tputs \"\\n1 Library\\n2 Staff Members\\n3 Books\\n4 Patrons\\n0 Exit\\n\"\n\tselect = make_selection\n\n\twhile select != \"1\" && select != \"2\" && select != \"3\" && select != \"4\" && select != \"0\"\n\t\tputs \"\\nInvalid choice selected\\n\"\t\t \t\t\n\t\tselect = make_selection\n\tend\n\n\tif select == \"1\"\n\t\tlibrary_choice = \"9\"\n\t\twhile library_choice != \"0\"\n\t\t\tlibrary_choice = select_choice_library\n\t\tend\n\n \telsif select == \"2\"\n\t\tstaff_member_choice = \"9\"\n\t\twhile staff_member_choice != \"0\"\n\t\t\tstaff_member_choice = select_choice_staff_member\n\t\tend\n\n\n\telsif select == \"3\"\n\t\tbook_choice = \"9\"\n\t\twhile book_choice != \"0\"\n\t\t\tbook_choice = select_choice_book\n\t\tend\n\n\n\telsif select == \"4\"\n\t\tpatron_choice = \"9\"\n\t\twhile patron_choice != \"0\"\n\t\t\tpatron_choice = select_choice_patron\n\t\tend\n\n\n\telsif select == \"0\"\n\t\tputs \"\\nGoodbye\"\t\t \t\t\n\tend\n\tselect \nend",
"def first_opt\n prompt = TTY::Prompt.new\n\n puts \"\\n\"\n\n selector = prompt.select(\"What would you like to do?\") do |menu|\n menu.choice \"Study\"\n menu.choice \"Start quiz\"\n menu.choice \"Add a new Q&A\"\n menu.choice \"Exit\"\n end\n\n case selector\n when \"Study\"\n show_categories\n study(@category_input_push)\n when \"Start quiz\"\n\n show_categories\n quiz(@category_input_push)\n\n when \"Add a new Q&A\"\n another_qa_opt\n when \"Exit\"\n exit\n end\nend",
"def getMenu(menu)\n end",
"def main_menu\n menu = [\n \"My Stats\",\n \"My Hikes\",\n \"Trails\",\n \"Quit\"]\n choice = nil\n while choice != \"Quit\"\n system 'clear'\n puts \"------MAIN MENU------\"\n choice = @prompt.select(\"What would you like to do #{@current_user.name}?\", menu)\n\n case choice\n when \"My Stats\"\n user_stats\n when \"My Hikes\"\n hike_options\n when \"Trails\"\n trail_options\n end\n end\n end",
"def main_selector\n print \"What would you like to do? Create, List, Update, or Vote: \"\n main_decision = gets.chomp.downcase\n main_decision = main_decision[0]\n case main_decision\n when \"c\"\n create_person_or_politician\n when \"l\"\n list_characters_created\n when \"u\"\n update_character\n when \"v\"\n vote\n else\n puts \"That is not a valid entry please try again!\"\n main_selector\n end\n end",
"def check_main_menu_choice(given_choice)\n if given_choice == \"First Time User, Want To Register\"\n choice = 1\n end\n if given_choice == \"Already A Registered User, Want To Login\"\n choice = 2\n end\n if given_choice == \"Do Not Wish To Register, Just Browsing\"\n choice = 3\n end\n if given_choice == \"Looking For Info About The App\"\n choice = 4\n end\n if given_choice == \"Nothing Really, Spare Me Your @?%#&?|%!\"\n choice = 5\n end\n choice\nend",
"def main_menu\n choice = self.prompt.select(\"Hi there, #{self.user.name}! What would you like to do today?\", [\"Create a new post\", \"Find a book\", \"View or edit my posts\", \"Delete my account\", \"Logout\"])\n\n case choice\n when \"Create a new post\"\n self.new_post\n when \"Find a book\"\n self.find_book\n when \"View or edit my posts\"\n self.view_edit_posts\n when \"Delete my account\"\n self.delete_account\n when \"Logout\"\n self.spinner(\" ✌️✌️✌️ \")\n self.greet\n end\n end",
"def main_menu_nav(main_menu_item)\n main_menu_items.each do |item|\n if item.text == main_menu_item\n item.click\n break\n end\n end\n end",
"def getRoutMenu\n puts 'Option 1: Add Route'\n puts 'Option 2: Exit'\n \n option = gets\n option = checkEndCon(option.to_i, 1, 2)\n \n return option.to_i\n end",
"def selected\r\n #TODO: find a way to not need to expand and collapse before getting the selected item\r\n expand_combo\r\n collapse_combo\r\n #get_selection.first\r\n get_selection.first\r\n end",
"def select_item\n @selected = @current\n\n items\n end",
"def select\n self[:select]\n end",
"def select\n self[:select]\n end",
"def main_menu\n @@prompt.select(\"What would you like to do today?\".colorize(:yellow)) do |menu|\n menu.choice \"Read Reviews\", -> {self.read_reviews}\n menu.choice \"Write a review\", -> { self.writing }\n menu.choice \"Update a review\", -> { self.update_reviews }\n menu.choice \"Delete a review\", -> { self.deleting }\n menu.choice \"Log Out\", -> { self.log_out }\n end\n end",
"def select_current\n ## vp is local there, so i can do $vp[0]\n #open_file $view[$sta] if $view[$sta]\n if $mode == \"forum\"\n display_forum $view[$cursor]\n else\n on_enter get_current_title\n end\nend",
"def find_book\n choice = self.prompt.select(\"Please provide me with the title, author, or ISBN of the book you are searching for: \", [\"Title\", \"Author\", \"ISBN\", \"Back to main menu\"])\n if choice != \"Back to main menu\"\n find_book_open_posts(choice)\n end\n self.main_menu\n end",
"def menu\n ([[0, 'Choisir l’icarien…']] + User.values_select(type_icarien => true)).in_my_select(id: 'opuser_user_id', name: 'opuser[user_id]', selected: param_opuser[:user_id])\n end",
"def menu_rainfall\r\n clear\r\n puts \"Please select from the following options: \"\r\n puts\r\n puts \"1. View rainfall details\"\r\n puts \"2. Add rainfall details\"\r\n # puts \"3. Delete rainfall details\"\r\n puts\r\n puts \"x. to exit \"\r\n menuoption = $stdin.gets.chomp.upcase\r\n return menuoption\r\nend",
"def pick_option\n input = get_input\n if input == '1'\n events_array = search_by_city\n display_events_by_city(events_array)\n save_event_or_main_menu(events_array)\n elsif input == '2'\n attractions_array = search_by_keyword\n display_by_keyword(attractions_array)\n save_event_or_main_menu(attractions_array)\n elsif input == '3'\n display_user_events\n elsif input == '4'\n delete_account\n elsif input == '5'\n space(1)\n puts \"#{$logged_in.username}, thanks for checking us out. See ya later!\"\n exit\n else\n space(1)\n invalid_input\n pick_option\n end\nend",
"def secret_menu\n puts \"\"\n options = [\"View Character Dictionary\", \"View Spellbook\", \"View House\", \"View Classmates\", \"Quit\"]\n choice = PROMPT.select(\"Welcome to Hogwarts. Feel free to explore the following:\", options)\n case choice\n when options[0]\n character_dictionary\n when options[1]\n which_user_spellbook_and_path?\n secret_menu_or_quit\n when options[2]\n house_info\n secret_menu_or_quit\n when options[3]\n user_classmates\n when options[4]\n goodbye\n end\n end",
"def select_menu(menuitems, keystroke=nil)\n $marathon.selectMenu(menuitems, keystroke)\nend",
"def main_menu\n puts \"===============\"\n puts \"Make a selection\"\n puts \"===============\"\n puts \"1: Command line\"\n puts \"2: Atom\"\n puts \"3: Search?\"\n puts \"4: Quit\"\n puts \"===============\"\n\n case gets.strip\n when \"1\"\n command_line_menu\n when \"2\"\n atom_menu\n when \"3\"\n search_function\n reset\n when \"4\"\n exit 0\n else\n bad_choice\n main_menu\n end\nend",
"def trail_options\n menu = [\"View All Trails\", \n \"Search for Trail\", \n \"Exit\"]\n system 'clear'\n puts \"------TRAILS------\"\n choice = @prompt.select(\"Which action would you like to take?\", menu)\n case choice\n when \"View All Trails\"\n print_trail_info(Trail.all)\n when \"Search for Trail\"\n search_for_trail(Trail.all)\n end\n @prompt.keypress(\"Press any key to continue\")\nend",
"def add_back_to_menu_and_select_choice(array)\n back_to_menu = \"Back to menu\"\n array << back_to_menu \n @selected_choice = @prompt.select(\"Your To-Dos\", array)\n # binding.pry\n # 0\nend",
"def first_selected_option\n option = options.find { |e| e.selected? }\n option or raise \"no options are selected\"\n end",
"def show\n @current_selection = params[:current_selection] or \"activities\"\n end",
"def display_menu\n system('clear')\n arr = ['My List', 'Recommendations', 'Playlist', 'Account Details', 'Exit']\n @prompt.select(\"》 MAIN MENU 《\\n\".colorize(:light_green), arr)\n end",
"def today_return_menu\n today_return_selection = @prompt.select(\"\\nSave to your favourites list or go back\\n\".blue) do |menu|\n menu.choice \"Save to favourites\", 1\n menu.choice \"Go back\", 2\n end \n today_return_selection(today_return_selection) \n end",
"def find_selected(name)\r\n array = instantiate_array_from_hashes(@params[name])\r\n selected = @params[\"#{name}_selected\"]\r\n selected_object = array.find { |o| o.class.name == selected }\r\n unless selected_object\r\n Log.error \"No selected object among '#{name}'\"\r\n Log.error \"params: #{@params[name].inspect}\"\r\n Log.error \"array: #{array.inspect}\"\r\n Log.error \"selected: #{selected}\"\r\n raise \"No selected object found. See log for details.\"\r\n end\r\n def selected_object.selected?\r\n true\r\n end\r\n selected_object\r\n end",
"def options_menu(noteboard)\n @start_prompt = TTY::Prompt.new\n @start_prompt.select(\"What do you want to do now?\") do |menu|\n menu.choice \"Load existing noteboards\", -> {noteboard_menu}\n menu.choice \"Add new note\", -> {Noteboard.noteboard_add(add_note)}\n menu.choice \"Delete note\", -> {Noteboard.noteboard_delete(delete_note)}\n menu.choice \"Back\", -> {StartMenu.new}\n end\nend",
"def item_selected\n if @last_frame < Graphics.frame_count\n @option_window.item.value = popup.selected_value\n @option_window.refresh\n @help_window.refresh\n close_popup\n else\n popup.activate\n end\n end",
"def weekend_menu\n active = 2\n if @alive == true\n weekend_header\n else\n offline_header\n end\n @selected_activity = []\n chosen_weekend_activity = @prompt.select(\"\\nSelect an activity to find out more\\n\".blue, @processed_weekend.push({name: \"--Back to Menu--\", value: 11}).uniq) \n weekend_selection(chosen_weekend_activity) \n end"
] | [
"0.6969514",
"0.69674706",
"0.6882983",
"0.683777",
"0.6820131",
"0.6818304",
"0.6800789",
"0.6790584",
"0.6784321",
"0.6749808",
"0.6729305",
"0.6708531",
"0.668289",
"0.6673356",
"0.6627128",
"0.66109484",
"0.6586145",
"0.6578587",
"0.6479397",
"0.64680403",
"0.6424982",
"0.63989544",
"0.6390895",
"0.63900054",
"0.6369142",
"0.63612634",
"0.63567173",
"0.6352921",
"0.6343848",
"0.6340402",
"0.63307166",
"0.63294464",
"0.63121104",
"0.63094604",
"0.6304617",
"0.6300704",
"0.62934655",
"0.6289177",
"0.6270834",
"0.6245349",
"0.6239755",
"0.622183",
"0.6207346",
"0.620544",
"0.6196781",
"0.61896604",
"0.6189645",
"0.6179932",
"0.6178275",
"0.6173664",
"0.61548525",
"0.6154302",
"0.6153877",
"0.61500156",
"0.6137325",
"0.6131813",
"0.6131813",
"0.6113292",
"0.6112895",
"0.60911083",
"0.60874146",
"0.6086803",
"0.6082866",
"0.606962",
"0.60587305",
"0.605722",
"0.60506773",
"0.6038356",
"0.6038049",
"0.6034283",
"0.60056955",
"0.5999894",
"0.5998245",
"0.5997215",
"0.5996449",
"0.5992423",
"0.5984584",
"0.5982196",
"0.598143",
"0.59811807",
"0.5978336",
"0.5977908",
"0.5976422",
"0.5954806",
"0.59411466",
"0.5938588",
"0.593284",
"0.59268546",
"0.5926003",
"0.5924188",
"0.59217274",
"0.5919852",
"0.5912425",
"0.59091246",
"0.5907779",
"0.5899992",
"0.58949226",
"0.5894096",
"0.5891775",
"0.5891649",
"0.5891097"
] | 0.0 | -1 |
Method used to calculate the completion of the game Count all the blocks the have the same colour as the topleft corner The completion is then calculated by diving the counter by the total number of blocks 100 The result is then converted to an integer | def get_progress(board)
counter = 0
total = $board_width * $board_height
board.each do |row|
row.each do |cell|
if cell == board[0][0]
counter+=1
end
end
end
return (counter/total.to_f * 100).to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def completion(boardGame, oldColor)\n count = 0.0;\n (0..boardGame.length - 1).each do |i|\n (0..boardGame[i].length - 1).each do |j|\n if boardGame[i][j] == oldColor then\n count += 1\n end\n end \n end\n return ((count/(boardGame.length*boardGame[0].length))*100.0).floor\nend",
"def completion(board,width,height,count,finished_game_counter,current_score)\n \n #define individual counters for each colour\n counter_red = 0\n counter_green = 0\n counter_blue = 0\n counter_yellow = 0\n counter_magenta = 0\n counter_cyan = 0\n \n #iterate through array and add 1 to the counter of the colour\n board.each do |row|\n row.each do |column| \n if column == :red\n counter_red += 1\n elsif column == :green\n counter_green += 1\n elsif column == :blue\n counter_blue += 1\n elsif column == :yellow\n counter_yellow += 1\n elsif column == :magenta\n counter_magenta += 1\n elsif column == :cyan\n counter_cyan += 1\n end \n end\n end\n \n #calculates the percentage of the game completed depending on which colour is in the top left element\n if board[0][0] == :red\n percentage = (counter_red*100)/(width*height)\n elsif board[0][0] == :green\n percentage = (counter_green*100)/(width*height)\n elsif board[0][0] == :blue\n percentage = (counter_blue*100)/(width*height)\n elsif board[0][0] == :yellow\n percentage = (counter_yellow*100)/(width*height)\n elsif board[0][0] == :magenta\n percentage = (counter_magenta*100)/(width*height)\n elsif board[0][0] == :cyan\n percentage = (counter_cyan*100)/(width*height)\n end\n puts \"#{percentage}%\"\n \n #the if statement below lets the program know if the user has finished a game yet or not\n if percentage == 100\n finished_game_counter += 1\n if finished_game_counter == 1\n current_score = count\n high_score(current_score,finished_game_counter)\n \n #if the user has finished more than 1 game, then the program will compare its previous score with \n #its current score.\n elsif finished_game_counter > 1\n if count < current_score\n current_score = count\n high_score(current_score,finished_game_counter)\n end\n end\n congratulation(percentage,count,current_score,finished_game_counter,width,height)\n end\nend",
"def get_amount(board, color)\n total_squares = board.length * board[0].length\n no_of_squares = 0\n height = board.length\n width = board[0].length\n\n # Loop through each square of the board\n (0...height).each do |row|\n (0...width).each do |column|\n # Increment counter if square matches selected color\n no_of_squares += 1 if color == board[row][column]\n end\n end\n\n # Calculate the percentage of squares that match the selected color\n return (no_of_squares.to_f / total_squares.to_f * 100).round.to_i\nend",
"def countBoxes(backGround,pixColors,totalBoxes)\r\n \r\n rows = @image.file.rows\r\n cols = @image.file.cols\r\n \r\n # initialize working variables\r\n \r\n boxCounts = {}\r\n boxMasses = {}\r\n pixColors.each do | pixColor |\r\n boxCounts[pixColor] = {}\r\n boxMasses[pixColor] = {}\r\n @steps.each do | stepSize |\r\n totBoxes = (rows-stepSize+1) * (cols-stepSize+1)\r\n boxCounts[pixColor][stepSize] = {}\r\n boxMasses[pixColor][stepSize] = Array.new(totBoxes,0)\r\n totalBoxes[stepSize] = totBoxes\r\n end\r\n end\r\n\r\n # now figure box masses\r\n \r\n rows.times do | row |\r\n cols.times do | col |\r\n pixColor = @image.file.getCell(row,col)\r\n if (backGround == -1) or (pixColor != backGround)\r\n @steps.each do | stepSize |\r\n boxesPresent = enumerateBoxes(stepSize, row, col, rows, cols)\r\n boxesPresent.each do | boxNumber |\r\n boxMasses[pixColor][stepSize][boxNumber] += 1\r\n end\r\n end\r\n end\r\n end\r\n end\r\n \r\n # calculate boxCounts from boxMasses\r\n \r\n boxMasses.each_pair do | pixColor, byPixHash |\r\n byPixHash.each_pair do | stepSize, boxMassArray |\r\n boxMassArray.each do | boxMass |\r\n if (boxMass > 0)\r\n # boxCounts[pixColor][stepSize][boxMass] += 1 if boxMass > 0\r\n boxMassHash = boxCounts[pixColor][stepSize]\r\n if boxMassHash[boxMass]\r\n boxMassHash[boxMass] += 1\r\n else\r\n boxMassHash[boxMass] = 1\r\n end\r\n end\r\n end\r\n end\r\n end\r\n\r\n # debugging aid: dump box counts\r\n if false\r\n boxCounts.each_pair do | pixColor, byPixHash |\r\n byPixHash.each_pair do | stepSize, boxCountHash |\r\n boxCountHash.each_pair do | boxMass, boxCount |\r\n print \"boxCounts[#{pixColor}][#{stepSize}][#{boxMass}] = #{boxCount}\\n\"\r\n end\r\n end\r\n end\r\n end\r\n\r\n # return values\r\n boxCounts\r\n end",
"def climb_count\n self.climbs.inject(0) do |sum, climb|\n sum += climb.block_1 if climb.block_1\n sum += climb.block_2 if climb.block_2\n sum += climb.block_3 if climb.block_3\n sum += climb.block_4 if climb.block_4\n sum\n end\n end",
"def block_count; @data[17].to_i; end",
"def getblockbycount(height)\n coind.getblockbycount height\n end",
"def completion\n\t\t@cards[0..TOTAL_UNIQUE_CARDS-1].reduce(0) {|memo, card| card.complete? ? memo + 1 : memo} / TOTAL_UNIQUE_CARDS.to_f\n\tend",
"def tiles_remaining\n # still not sure why or how this is working. TODO: may take out later\n total_num_tiles = @default_set.inject(0) { |letter, letter_quantity| letter += letter_quantity[1] }\n p \"++++TEST++++\"\n p total_num_tiles\n return total_num_tiles\n end",
"def place_mine_indicators\n @board.each_with_index do |r, row|\n r.each_with_index do |_c, col|\n unless @board[row][col].is_a_mine\n count = 0\n if row - 1 >= 0\n count += 1 if col - 1 >= 0 && @board[row - 1][col - 1].is_a_mine\n count += 1 if @board[row - 1][col].is_a_mine\n count += 1 if col + 1 < @board.size && @board[row - 1][col + 1].is_a_mine\n end\n count += 1 if col - 1 >= 0 && @board[row][col - 1].is_a_mine\n count += 1 if col + 1 < @board.size && @board[row][col + 1].is_a_mine\n if row + 1 < @board.size\n count += 1 if col - 1 >= 0 && @board[row + 1][col - 1].is_a_mine\n count += 1 if @board[row + 1][col].is_a_mine\n count += 1 if col + 1 < @board.size && @board[row + 1][col + 1].is_a_mine\n end\n @board[row][col].set_value(count)\n end\n end\n end\n end",
"def total_blocks\n weapon_class_ids = self.equipped_weapons.reduce([]) do |acc, weapon|\n acc + weapon.weapon_class_ids\n end\n skills_hash = skills_ranks_hash\n total = self.equipped_weapons.length + skills_bonus(skills_hash, :bonus_blocks, weapon_class_ids)\n \"#{total} + #{self.equipped_weapons.length} panic block(s) for half your next offense budget\"\n end",
"def count_correct_colors\n colors_by_difficulty.each do |color|\n if @code_guess.count(color) < @secret_code.count(color)\n @white_peg += @code_guess.count(color)\n else\n @white_peg += @secret_code.count(color)\n end\n end\n end",
"def count_evaluate(player) # true for white player, false for black\n if player\n RState.hamming(@white_positions) - RState.hamming(@black_positions)\n else\n RState.hamming(@black_positions) - RState.hamming(@white_positions)\n end\n end",
"def calculate_score\n statuses = Tile::STATUSES\n missed_shots = starting_shots - shots_remaining\n hit_shots = board.board.flatten.select do |tile|\n [statuses[:hit], statuses[:sunk]].include?(tile.status)\n end\n hit_shots = hit_shots.count\n total_time = (Time.now - starting_time).round\n ((500 * hit_shots) - (50 * missed_shots)) / total_time\n end",
"def score\n self.tiles.inject(0){|sum,num| sum+=TileBag.points_for(num)}\n end",
"def sync_progress\n response = rpc(:block_count, _coerce: Hash)\n\n count = response[:count]\n unchecked = response[:unchecked]\n total = count + unchecked\n\n count.to_f * 100 / total.to_f\n end",
"def num_of_correct(crct)\n if self.total.nil?\n self.total = 1\n else\n self.total += 1\n end\n \n if crct == 1\n if self.correct.nil?\n self.correct = 1\n else\n self.correct += 1\n end \n else\n self.correct = 0\n end\n end",
"def total\n # Each square has 1 << (n-1) grains of rice, one more than all squares\n # before it combined. The total number of grains on a chess board can\n # thus be calculated by subtracting one from the number of grains on a\n # theoretical 65th square.\n square(65)-1\n end",
"def self_percent_complete\n if !self.self_check_count.blank?\n if self.designer_completed_checks <= self.self_check_count\n self.designer_completed_checks * 100.0 / self.self_check_count\n else\n 100.0\n end\n else\n 0\n end\n end",
"def display\n if @count.to_f/@tries.to_f < .33\n print @progress.join.green\n puts\n elsif @count.to_f/@tries.to_f > .33 && @count.to_f/@tries.to_f < .66\n print @progress.join.orange\n puts\n elsif @count.to_f/@tries.to_f > .66\n print @progress.join.red\n end\n\nend",
"def getblockcount\n coind.getblockcount\n end",
"def create_board(board, board_checked, width, height, turns_taken, highest_score)\n #clears the terminal contents\n system \"clear\"\n #Sets the top left corner of the board_checked array to true as this block should automatically be completed\n board_checked[0][0] = \"t\"\n \n #Loops through the rows and columns of the board array and prints the contents of each position using the colorize gem\n (0..height-1).each do |row|\n\t(0..width-1).each do |column| \n\t print \" \".colorize(:background => board[row][column])\n end\n\tputs \"\"\n end\n \n #sets the number of completed board positions by looping through all the rows and columns of the board_checked array and incrementing by 1 \n #each time a \"t\" is detected\n completion_count = 0\n (0..height-1).each do |row|\n\t(0..width-1).each do |column|\n\t if board_checked[row][column] == \"t\"\n\t\tcompletion_count +=1 \n\t end\n\tend\n end\n \n #Calculates a percentage of the board completed\n completion_percentage = ((completion_count*100)/(width*height)).to_i\n #Everytime this method is called i run a completion check to see if the game has finished\n if (completion_percentage == 100) then\n #If the highest score has not already been set then it is set as the number of turns taken\n\tif highest_score == 0 then\n\t highest_score = turns_taken\n #however if the high score has been set but it is lower than the current number of turns it is not set\n #as the latest number of turns taken\n\telsif highest_score != 0 && turns_taken < highest_score then\n\t highest_score = turns_taken\n\tend\n #a congratualtions message is dislayed and the main menu method is called after the player presses enter\n\tputs \"You won after #{turns_taken} turns\"\n #the main menu is then displayed after the user presses enter\n gets()\n\tdisplay_main_menu(highest_score, width, height)\n end\n\t\t\n #outouts the turns taken and the completion percentage to the screen\n puts \"Number of Turns: #{turns_taken}\"\n puts \"Game completion: #{completion_percentage}%\"\n print \"choose a colour: \"\n #stores the users colour response\n colour_response = gets.chomp.downcase\n colour_block = \"\"\n \n #sets the value of the variable colourblock to the corresponding colorize value of the user's input\n if colour_response == \"r\" then\n\tcolour_block = :red\n elsif colour_response == \"b\" then\n\tcolour_block = :blue\n elsif colour_response == \"c\" then\n\tcolour_block = :cyan\n elsif colour_response == \"m\" then\n\tcolour_block = :magenta\n elsif colour_response == \"g\" then\n\tcolour_block = :green\n elsif colour_response == \"y\" then\n\tcolour_block = :yellow\n #if the user enters q they will return to the main menu\n elsif colour_response == \"q\" then\n\tdisplay_main_menu(highest_score, width, height)\n else\n #If the user tyes any unaccepted values then this method is recalled and they will be asked to enter a choice again\n create_board(board, board_checked, width, height, turns_taken, highest_score) \n end\n \n #loops through the board checked array to find any positions that are marked as completed\n (0..height-1).each do |row|\n\t(0..width-1).each do |column|\n #if a position is marked as completed then the contents of the board array position above, right, left and below of the completed array position are\n #checked to see if they match the colour the user has chosen as their input.\n #If they do match the users input choice then their board position is set as completed in the boardchecked array.\n\t if board_checked[row][column] == \"t\"\n\t\tif board[row][column+1] == colour_block && column != (width-1) then\n\t\t board_checked[row][column+1] = \"t\"\n\t\tend\n\t\tif board[(row-(height-1))][column] == colour_block && row != (height-1) then\n\t\t board_checked[(row-(height-1))][column] = \"t\"\n\t\tend\n\t\tif board[row][column-1] == colour_block && column != 0 then\n\t\t board_checked[row][column-1] = \"t\"\n\t\tend\n\t\tif board[row-1][column] == colour_block && row != 0 then\n\t\t board_checked[row-1][column] = \"t\"\n\t\tend\n\t end\n\tend\n end \n\n #loops through the board checked array and sets the value of the corresponding board array position where there is a position marked as \n #completed completed in the board checked array \n (0..height-1).each do |row|\n\t(0..width-1).each do |column|\n\t if board_checked[row][column] == \"t\"\n\t board[row][column] = colour_block\n\t end\n\tend\n end \n #increments the run counter and re-calls this method \n turns_taken +=1\n create_board(board, board_checked, width, height, turns_taken, highest_score) \nend",
"def count_correct_colors\r\n total_correct_color_count = Hash.new(0)\r\n guess.length.times do |i|\r\n total_correct_color_count[guess[i]] += 1 if total_correct_color_count[guess[i]] < code_count[guess[i]]\r\n end\r\n total_correct_sum = 0\r\n total_correct_color_count.each { |k,v| total_correct_sum += v }\r\n total_correct_sum\r\n end",
"def score_complete(i)\t\t\n if i == 9\t\t\t\t\t\t\t\t# last frame\n frame_score = @frame_scores[player - 1][i].reduce(:+)\n # puts frame_score\n # puts @game_scores[player - 1][-1]\n @game_scores[player - 1] << @game_scores[player - 1][-1] + frame_score\n\t\t\n elsif i == 8 && @frame_scores[player - 1][i][0] == 10\t\t# strike in 9th frame ->> take first two of 10th\n tally_comp(i,0,i+1,0,i+1,1)\n\t\t\t\t\n else\n if @frame_scores[player - 1][i][0] == 10\t\t\t\t# strike in current frame\n if @frame_scores[player - 1][i+1][0] == 10\t\t# followed by strike in next frame\n tally_comp(i,0,i+1,0,i+2,0)\n else\t\t\t\t\t\t\t# followed by anything else\n tally_comp(i,0,i+1,0,i+1,1)\n end\n elsif @frame_scores[player - 1][i].reduce(:+) == 10\t# spare in current frame\n tally_comp(i,0,i,1,i+1,0)\n else\t\t\t\t\t\t\t\t# no bonus\n tally_comp(i,0,i,1,nil,nil)\n end\n end\nend",
"def score_complete(i)\t\t\n if i == 9\t\t\t\t\t\t\t\t# last frame\n frame_score = @frame_scores[player - 1][i].reduce(:+)\n # puts frame_score\n # puts @game_scores[player - 1][-1]\n @game_scores[player - 1] << @game_scores[player - 1][-1] + frame_score\n\t\t\n elsif i == 8 && @frame_scores[player - 1][i][0] == 10\t\t# strike in 9th frame ->> take first two of 10th\n tally_comp(i,0,i+1,0,i+1,1)\n\t\t\t\t\n else\n if @frame_scores[player - 1][i][0] == 10\t\t\t\t# strike in current frame\n if @frame_scores[player - 1][i+1][0] == 10\t\t# followed by strike in next frame\n tally_comp(i,0,i+1,0,i+2,0)\n else\t\t\t\t\t\t\t# followed by anything else\n tally_comp(i,0,i+1,0,i+1,1)\n end\n elsif @frame_scores[player - 1][i].reduce(:+) == 10\t# spare in current frame\n tally_comp(i,0,i,1,i+1,0)\n else\t\t\t\t\t\t\t\t# no bonus\n tally_comp(i,0,i,1,nil,nil)\n end\n end\nend",
"def no_of_blocks\n @highlighted_blocks = \"\"\n blocks = Random.rand(5) + 1\n blocks.times {|count|\n row = Random.rand(5)\n column = Random.rand(5)\n @highlighted_blocks << \"#button_#{row}_#{column} \"\n }\n end",
"def total_number_of_rounds\n case player_count\n when 2..4\n 2\n when 5..8\n 3\n when 9..16\n 4\n when 17..32\n 5\n else\n 6\n end\n end",
"def total_resouce_value(minutes = 10)\n changes, area, holds, cycles = {}, @data, [], []\n max_x, max_y = area[0].size, area.size\n\n # print_area(area, 0)\n\n (1..minutes).each do |time|\n (0..max_x - 1).each do |x|\n (0..max_y - 1).each do |y|\n adjacents = [\n [x - 1, y - 1],\n [x - 1, y],\n [x - 1, y + 1],\n [x, y - 1],\n [x, y + 1],\n [x + 1, y - 1],\n [x + 1, y],\n [x + 1, y + 1]\n ].select { |k, v| k >= 0 && v >= 0 && k <= max_x - 1 && v <= max_y - 1 }\n .map { |dx, dy| area[dx][dy] }.compact\n\n case area[x][y]\n when '.'\n changes.merge!([x, y] => '|') if adjacents.count('|') >= 3\n when '|'\n changes.merge!([x, y] => '#') if adjacents.count('#') >= 3\n when '#'\n changes.merge!([x, y] => '.') unless adjacents.include?('|') && adjacents.include?('#')\n end\n end\n end\n\n changes.each { |(cx, cy), value| area[cx][cy] = value }\n\n resource = [area.flatten.count('|'), area.flatten.count('#')].reduce(&:*)\n\n if holds.include?(resource)\n unless cycles.include?(resource)\n cycles << resource\n else\n if holds.join.include? cycles.join\n puts \"Part 2: #{cycles[(minutes - holds.size) % cycles.size - 1]}\"\n return\n else\n cycles = []\n end\n end\n end\n\n holds << resource\n\n # print_area(area, time)\n end\n\n puts \"Part 1: #{area.flatten.count('|') * area.flatten.count('#')}\"\n end",
"def runner\nwelcome\ncurrent_sum=hit?(initial_round)\ndisplay_card_total(current_sum)\n until current_sum>=21 do\n current_sum=hit?(current_sum)\n end\n end_game(current_sum)\n \n\nend",
"def turn_count()\n count = 0\n index = 0\n loop do\n if position_taken?(index)\n count += 1\n end\n index += 1\n if index > 9 \n break\n end\n end\n return count\n end",
"def count_black_tiles_around(in_tiles, tile_x, tile_y)\n black_tile_count = 0\n MOVE.each do |dir, deltas|\n other_tile_x = tile_x + deltas[0]\n other_tile_y = tile_y + deltas[1]\n hash_key = \"#{other_tile_x}_#{other_tile_y}\"\n black_tile_count += 1 if (in_tiles[hash_key] % 2 == 1)\n end\n black_tile_count\nend",
"def max_blocks; end",
"def found_blocks\n shares.where(:upstream_result => \"Y\").count + blocks.count\n end",
"def sum_of_point\n # Calculating point of each block\n calculate_points\n # Sum\n rubbish_count + not_clear_count + somewhat_count + understand_count\n end",
"def progress()\n percent = (($ops / $total_ops) * 100).floor\n if (percent <= 99)\n $progress.progress = percent\n $ops += 1\n else\n $progress.finish\n end\nend",
"def progression counter,opts = {}\n (@steps = nil; return) if opts[:reset]\n @steps ||= (1..10).map{ |n| [(@num_rows.to_f / 10.to_f) * n,n*10] }\n return if @steps.empty?\n c,perc = @steps[0] \n if counter > c\n Logger.<<(__FILE__,\"INFO\",\"Having processed #{perc}% now ...\",inline: true)\n @steps.shift\n end\n end",
"def calculate_progress\n result = self.progress_status\n (100 * result.values.count(true) / result.values.compact.count).to_s\n end",
"def count_correct_positions\n color_index_checker = []\n @code_guess.each_with_index do |color, index|\n if color == @secret_code[index]\n @red_peg += 1\n end\n end\n end",
"def get_score\n empty_squares = [] # lists of empty squares we have already counted\n score = [0, 0] # [score of black, score of white]\n\n #for each stone of the board\n @board.board_of_stone.each_with_index do |row, i|\n row.each_with_index do |stone, j|\n # if the spot is empty and we've not counted it yet\n if stone == 0 && !empty_squares.include?([i, j])\n # get the group of empty spots and its adjacents\n group, adj = get_adj(i, j)\n # if get_adj returned -1, meaning (i, j) is linked to a not_border\n if adj == -1\n # no need to add it to empty_squares since we're not going to\n # check this specific spot again anyway.\n next # jump to next iteration of each_with_index\n end\n # the player who gets the points depend on the color of the adjacents\n cur_adj_color = group_color(adj)\n # if the group of adj is all black or all white\n if(cur_adj_color > 0)\n # count score (cur_adj_color-1 because black's score is stored in score[0])\n score[cur_adj_color-1] += group.size\n # save empty spots that have been counted\n empty_squares += group\n end\n end\n end\n end\n\n #add captured stones\n for i in [0, 1] do\n score[i] += nb_captured[i]\n end\n\n return score\n end",
"def covered_percent; end",
"def covered_percent; end",
"def total_guess_count()\r\n\t\t# TODO: fill in method body\r\n\t\treturn -1\r\n\tend",
"def runner\n welcome\n cards_counter = initial_round\n\n until cards_counter > 21\n compare = hit?(cards_counter)\n compare == cards_counter ? display_card_total(cards_counter):display_card_total(compare)\n cards_counter = compare\n end\nend_game(cards_counter)\nend",
"def covered_percentages; end",
"def average_finish_time \n \ni = 0\n while i != 100\n $round = 0 \n while $step < $max_step\n jet = throw_dice\n make_move(jet)\n $round = $round + 1\n end\n $step = 0\n $resultGame.push($round)\n i +=1\n end\nend",
"def progress_bar_percentage(recipe, user = current_user)\n num_of_ingredients_matched = (recipe.ingredients & get_active_ingredients(user)).length\n percent_of_ingredients_matched = num_of_ingredients_matched.fdiv(recipe.ingredients.length) * 100\n case percent_of_ingredients_matched\n when 0..25\n return \"rgba(255,0,0,0.7)\"\n when 25..50\n return \"rgba(255,165,0,0.7)\"\n when 50..75\n return \"rgba(255,255,0,0.7)\"\n else\n return \"rgba(0,100,0,0.7)\"\n end\n end",
"def gray_boomcity_tile_potential_count\n gray_boomcity_tile_count +\n [gray_double_boomcity_tile_count, @pending_gray_boom_tile_lays[:double_boom].size].min\n end",
"def turn_count\n counter = 0\n @cells.each do |cell|\n if cell != \" \"\n counter += 1\n end\n end\n counter\n end",
"def average_finish_time\n\tcount = 0\n\t#simuler une game\n\tgame_state = 0\n\twhile game_state != 10\n\t\troll = rand(6)\n\t\tif roll > 3 #5-6\n\t\t\tgame_state +=1\n\t\telsif roll == 0\n\t\t\tif game_state != 0 \n\t\t\t\tgame_state -= 1\n\t\t\tend\n\t\tend\n\t\tcount +=1\n\tend\n\n\treturn count\nend",
"def display_board(board,number_of_turns,progress)\n board.each do |row|\n row.each do |cell| \n # Each element of the board contains 2 space characters\n # 'colorize' gem is used to print coloured text\n # and 'cell' contains the colour which to be used\n print \" \".colorize(:background=>cell)\n end\n puts \"\"\n end\n # Show the number of turns and completion\n puts \"Current number of turns: #{number_of_turns}\"\n puts \"Current completion: #{progress}%\"\n \n # Ask the user to input the colour as long as the game is not finished\n if progress < 100\n print \"Choose a colour: \"\n end\n \nend",
"def turn_count(board)\n turn_counter = 0\n (board.length).times do |i|\n if position_taken?(board, i)\n turn_counter += 1\n end\n end\n\n return turn_counter\nend",
"def total_blocked\n self.blockades(false).count + self.blockades_by(false).count\n end",
"def calculate_score\n # Calculate score given the number of lines cleared at once\n case (@deleted_indexes.length / 2)\n when 1\n @score += 40 * (@level + 1)\n when 2\n @score += 100 * (@level + 1)\n when 3\n @score += 300 * (@level + 1)\n when 4\n @score += 1200 * (@level + 1)\n end\n @score\n end",
"def blocks_trail_count\n @highest_block_number - @current_block_number\n end",
"def score\n populate_frames.inject(0) {|a,v| a+ v.frame_total}\n end",
"def calculate_h\n # Get all black and red cells and calculate the distance from the last cell or the first cell\n h = 0\n @state.each_with_index do |cell, index|\n if cell != 'F'\n h += (cell == 'B') ? @state.length - index : index\n end\n end\n return h\n end",
"def block(board)\n opponent_token = find_opponent_token\n block_options = []\n WIN_COMBINATIONS.each do |combo| \n if combo.reject {|i| board.cells[i] == opponent_token}.length == 1\n block_options << combo.detect {|i| board.cells[i] == \" \"}\n end\n end\n block_move = block_options.first\n if block_move != nil\n (block_move+=1).to_s\n end\n block_move\n end",
"def percentComplete\n totalImages = image_labels.count\n pct = (labelledImagesCount()/totalImages)*100.0\n pct.round(1)\n end",
"def turn_count\n counter = 0\n @board.each do |index_taken|\n if index_taken == \"X\" || index_taken == \"O\"\n counter += 1\n end\n end\n counter\n end",
"def get_score\n empty_squares = [] # lists of empty squares we have already counted\n score = [0, 0] # [score of black, score of white]\n\n #for each stone of the board\n @board_of_stone.each_with_index do |row, i|\n row.each_with_index do |stone, j|\n # if the spot is empty and we've not counted it yet\n if stone == 0 && !empty_squares.include?([i, j])\n # get the group of empty spots and its adjacents\n group, adj = get_adj(i, j, 3)\n # the player who gets the points depend on the color of the adjacents\n # We consider not-borders as another players, so nobody gets any point\n cur_adj_color = group_color(adj)\n # if the group of adj is all black or all white\n if(cur_adj_color > 0)\n score[cur_adj_color-1] += group.size # count score\n empty_squares += group # save empty spots that have been counted\n end\n end\n end\n end\n\n #add captured stones\n for i in [0, 1] do\n score[i] += nb_captured[i]\n end\n\n return score\n end",
"def runner\n welcome\n current_total = initial_round\n \n \n until current_total >21\n current_total=hit?(current_total)\n display_card_total(current_total)\nend\n end_game(current_total)\n\n end",
"def progress_percentage\n total_amount = 0\n # proceed_amount = 0\n total_amount = card_sub_tasks.map(&:service_card_count).reduce(:+)\n # card_sub_tasks.each do |card_sub_task|\n # if card_sub_task.proceed == CardSubTask::PROCEED_FINISHED || card_sub_task.proceed == CardSubTask::PROCEED_ERROR\n # proceed_amount += card_sub_task.service_card_count\n # elsif card_sub_task.proceed == CardSubTask::PROCEED_PROCESSING\n # proceed_amount += card_sub_task.service_cards.count\n # end\n # end\n return percentagere = \"#{sprintf(\"%.1f\", proceed_amount.to_i / total_amount.to_f * 100)}%\"\n end",
"def getblockbycount(height)\n @api.request 'getblockbycount', height\n end",
"def turn_count\n counter = 0\n cells.each do |index|\n if index != \" \"\n counter += 1\n end\n end\n counter\n end",
"def turn_count(board)\n\n\toccupied_spaces = 0\n\n\tcounter = 0\n\twhile counter < board.size\n\t if position_taken?(board, counter)\n\t\t occupied_spaces += 1\t\t \nend \ncounter += 1\nend\noccupied_spaces\nend",
"def find_region\n count = 0\n GRID.each_with_index do |y_values, current_x|\n y_values.each do |current_y|\n distance = 0\n ALL_POINTS.each do |point|\n distance += ((point.y - current_y).abs + (point.x - current_x).abs)\n end\n p distance\n count += 1 if distance < 10_000\n end\n end\n p count\nend",
"def total_poss\n @nrow * @ncol * @nbox\n end",
"def calculate_minimal_flips\n @optimal = 0\n\n until game_over?\n change_colour(best_colour)\n @optimal += 1\n end\n\n reset\n end",
"def runner(current_card_total)\n welcome\n initial_round\n until current_card_total>21\n hit?(sum)\n display_card_total(card_total)\n end\n end_game\nend",
"def turn_count(board)\n count = 0\n\n board.each_with_index do |location, index|\n if position_taken?(board, index)\n count = count + 1\n end\n end\n\n count\nend",
"def count_up(x, y)\n if y + 1 >= $height\n return 0\n end\n return $canvas[x][y + 1] == 1 ? 1 : 0\nend",
"def get_progresses\n if @all_count > 0\n @progress_ch = 100 * @memorized_count_ch / @all_count\n @progress_ja = 100 * @memorized_count_ja / @all_count\n else\n @progress_ch = 0\n @progress_ja = 0\n end\n end",
"def percent_remaining\n #num_unlabeled = image_labels.where(:label_id => nil).count\n num_unlabeled = image_labels.count - labelledImagesCount()\n if(images.count > 0)\n percent_remaining = 100.0 * num_unlabeled.to_f / images.count\n else\n percent_remaining = 0.0\n end\n end",
"def runner\n\n welcome\n counter = initial_round\n \n until counter > 21 do\n counter = hit?(counter)\n display_card_total(counter)\nend\nend_game(counter) \nend",
"def color_matches(loc=@counter)\n code = get_code_remainder(loc)\n guess = get_guess_remainder(loc)\n x = 0\n y = 0\n index = 0\n totalmatches = 0\n matches = 0\n guess.each{|g|\n code.each{ |c| \n if c == g && matches == 0\n matches += 1\n guess[x] = 0\n code[y] = 5\n end\n y += 1\n }\n y = 0\n totalmatches += 1 if matches > 0\n matches = 0\n x += 1\n }\n totalmatches\n end",
"def total_per_big_component(&block)\n @scms.sort.each do | name, linehash |\n size = linehash.values.sum\n output name, 0, size, &block if !size.nil? and size > 20000\n end\n end",
"def goldenCompletion?\n\t\t@cards[TOTAL_UNIQUE_CARDS..2*TOTAL_UNIQUE_CARDS-1].reduce(0) {|memo, card| card.complete? ? memo + 1 : memo} / TOTAL_UNIQUE_CARDS.to_f\n\tend",
"def detect_block_size(pm)\n print \"Detecting block size: \"\n block_size = 0\n # Find out when 2 repeating blocks are found\n (4..50).each do |i|\n aaa = i.times.map{|ii| \"A\"}.join\n cipher_aaa = pm.encrypt_profile(aaa).unpack(\"m\")[0]\n\n # Scan cipher text in windows of 2..i/2 to search for repeating blocks\n (2..i/2).each do |win_size|\n # puts \"Checking win_size: #{win_size}\"\n start_i = 0\n (0..cipher_aaa.length - 2*win_size).each do |start_i|\n block_1 = cipher_aaa[start_i..start_i + win_size-1]\n block_2 = cipher_aaa[start_i + win_size..start_i +(2*win_size - 1)]\n if block_1 == block_2\n block_size = win_size\n break\n end\n end\n end\n if block_size > 0\n puts \"*\"\n puts \"Found block size: #{block_size}\"\n return block_size\n end\n print \".\"\n end\n\n raise \"Block size not detected\"\nend",
"def circle_of_blocks pass, xoffset, yoffset, angleoffset, blocksize, distance\n numblocks = 10\n\n for i in 1..numblocks do\n angle = ((360 / numblocks) * i) + angleoffset\n radians = angle * (Math::PI / 180)\n x = (xoffset + (distance * Math.cos(radians))).round\n y = (yoffset + (distance * Math.sin(radians))).round\n pass.solids << [ x, y, blocksize, blocksize, 255, 255, 0 ]\n end\nend",
"def number_correct\n turns.count do |each_turn|\n each_turn.correct?\n end\n end",
"def turn_count\n count = 0\n @cells.each do |element|\n count += 1 if element != \" \"\n end\n count\n end",
"def stat\n each_with_object(Hash.new(0)) { |c, o| o[c] += 1 }\n end",
"def runner\n welcome\n total = initial_round\n until total>21 do\n total = hit?(total)\n display_card_total(total)\nend\nend_game(total)\nend",
"def max_blocks=(_arg0); end",
"def comb_select()\r\n\tmin_runner = 10\r\n\tmax_runner = 100\r\n\tgreater_than = 1000000\r\n\tcounter = 0\r\n\t\r\n\tfor runner in (min_runner..max_runner)\r\n\t\trun_f = factorial(runner)\r\n\t\tmin_select = (runner/4).to_i\r\n\t\tfor selection in (2..runner-1)\r\n\t\t\tdivider = factorial(selection) * factorial(runner - selection)\r\n\t\t\tcounter += 1 if run_f / divider > greater_than\r\n\t\tend\r\n\tend\r\n\treturn counter\r\nend",
"def getblockbycount(height)\n request :getblockbycount, height\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 work\n unmark_circles_part_of_bingo\n check_marked_circles\n @card.update(num_bingos: get_num_bingos)\n @card.num_bingos\n end",
"def turn_count\n count = 0\n cells.each {|pos| count += 1 if pos == \"X\" || pos == \"O\"}\n count\n end",
"def runner\n # code runner here\n \n theSum = 0 \n \n welcome\n theSum = initial_round\n until(theSum > 21)\n theSum = hit?(theSum)\n display_card_total(theSum)\n end\nend_game(theSum)\nend",
"def runner\r\n welcome \r\n total = initial_round #tricky too \r\n until total > 21\r\n total = hit?(total) #tricky part \r\n display_card_total(total)\r\n \r\n end\r\nend_game(total)\r\nend",
"def progress\n total = asset.pieces.count\n downloaded = total - piece_downloads.incomplete.count\n [downloaded, total]\n end",
"def length\n @blocks.inject(0) {| sum , item | sum + item.length}\n end",
"def remaining_percent\n (remaining_pints.to_f)/(124.to_f)\n end",
"def success\n (correct_answers_count*100.0/answers_count).round.to_i if answers_count > 0\n end",
"def runner\n # code runner here\n running_total = 0\n welcome\n running_total += initial_round\n until running_total > 21 do\n running_total = hit?(running_total)\n display_card_total(running_total)\n end\nend_game(running_total)\nend",
"def posboard (position, count)\n\t\t\n\t\tcase position\n\t\t\twhen 0\n\t\t\tputs \"You are at the begining\"\n\t\t\tposition = 0\n\t\t\twhen 1\n\t\t\tputs \"On the board, you are on position 1 #~~~~~~~~\"\n\t\t\twhen 2\n\t\t\tputs \"On the board, you are on position 2 ##~~~~~~~\"\n\t\t\twhen 3\n\t\t\tputs \"On the board, you are on position 3 ###~~~~~~\" \n\t\t\twhen 4\n\t\t\tputs \"On the board, you are on position 4 ####~~~~~\"\n\t\t\twhen 5\n\t\t\tputs \"On the board, you are on position 5 #####~~~~\"\n\t\t\twhen 6\n\t\t\tputs \"On the board, you are on position 6 ######~~~\"\n\t\t\twhen 7\n\t\t\tputs \"On the board, you are on position 7 #######~~\"\n\t\t\twhen 8\n\t\t\tputs \"On the board, you are on position 8 #######~~\"\n\t\t\twhen 9\n\t\t\tputs \"On the board, you are on position 9 ########~\"\n\t\t\twhen 10\n\t\t\tputs \"On the board, you're on position 10 ######### CONGRATULATIONS YOU WON \"\n\t\t\tputs \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n\t\t\tputs \"~ The game took \" + count.to_s + \" repetitions to finish ~\"\n\t\t\tputs \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n\t\t\texit\n\t\telse\n\t\tputs \"Technical issue, restart the game\"\n\t\texit\n\t\tend\n\t\tcount = count + 1\nreturn count\n\nend",
"def progress(run_id)\r\n @result_count = self.get_results(run_id)[:result].length - 1\r\n run = Run.find(run_id)\r\n @result = ((@result_count.to_f / run.units.count.to_f) * 100).round(2)\r\n end",
"def calculate_confirmations(block_height, force_latest_block_reload: false)\n\n if block_height && block_height != -1\n latest_block_height(force_reload: force_latest_block_reload) - block_height + 1\n else\n 0\n end\n\n end",
"def calc_progress\n p = 0.25\n unless self.compile_errors.nil?\n p = 0.5\n end\n\n if self.correct\n p = 1.0\n else\n unless self.results.nil?\n p_tc = 0.0\n self.results.each do |id,result|\n unless result['error']\n p_tc = p_tc + 1\n end\n end\n p = p + ((p_tc/self.results.size) * 0.5)\n end\n end\n\n p\n end"
] | [
"0.71532583",
"0.7041949",
"0.64696425",
"0.6386704",
"0.6215267",
"0.618034",
"0.61584073",
"0.60580087",
"0.60290825",
"0.59197974",
"0.58793455",
"0.5822503",
"0.5808183",
"0.57963943",
"0.5786179",
"0.5769555",
"0.5712118",
"0.5695716",
"0.56662923",
"0.566162",
"0.5655549",
"0.56446266",
"0.564437",
"0.5633029",
"0.5633029",
"0.56057936",
"0.559853",
"0.55963695",
"0.558949",
"0.55836844",
"0.5575283",
"0.55546284",
"0.55394906",
"0.5532091",
"0.55293757",
"0.55276024",
"0.55182564",
"0.5511793",
"0.5497734",
"0.5488996",
"0.5488996",
"0.5481058",
"0.5480424",
"0.54802376",
"0.54736745",
"0.546624",
"0.54654896",
"0.54647285",
"0.5461733",
"0.54324394",
"0.5428325",
"0.5422368",
"0.5410669",
"0.54089504",
"0.54059523",
"0.5400689",
"0.5397903",
"0.53968704",
"0.5388694",
"0.53829855",
"0.5382498",
"0.5381981",
"0.53811383",
"0.53782463",
"0.53772515",
"0.5369159",
"0.5367016",
"0.5355524",
"0.5352582",
"0.5351871",
"0.5345992",
"0.53449",
"0.5341765",
"0.5340361",
"0.53381693",
"0.5335323",
"0.5328615",
"0.53261566",
"0.5325274",
"0.531828",
"0.53148407",
"0.5311713",
"0.53074753",
"0.5297869",
"0.52954394",
"0.52949727",
"0.52913505",
"0.5288942",
"0.52883834",
"0.5285138",
"0.52777857",
"0.52740777",
"0.5273863",
"0.52735305",
"0.5273381",
"0.52728975",
"0.52712667",
"0.5269365",
"0.5266544",
"0.52638954"
] | 0.6809332 | 2 |
Method used to return the colour given by the user | def get_colour
colour = gets.chomp.downcase
if colour =="q" then
colour = "q"
elsif colour == "r"
colour = :red
elsif colour == "b"
colour = :blue
elsif colour == "g"
colour = :green
elsif colour == "y"
colour = :yellow
elsif colour == "c"
colour = :cyan
elsif colour == "m"
colour = :magenta
else
# if the input is none of the above colours or 'q'
# then the input must be invalid
colour = "invalid"
end
# return colour
return colour
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getColor(c)\n if c == \"r\" then return :red\n elsif c == \"b\" then return :blue\n elsif c == \"g\" then return :green\n elsif c == \"y\" then return :yellow\n elsif c == \"c\" then return :cyan\n elsif c == \"m\" then return :magenta\n end\nend",
"def get_color\n @color\n end",
"def color\n return @color\n end",
"def color\n\t\treturn @color\n\t\t\n\tend",
"def color\n @color\n end",
"def color\n @color\n end",
"def color(color); end",
"def color\n return @color\n end",
"def color\n return @color\n end",
"def get_color\n\tputs \"Client's favorite color:\"\n\tcolor = gets.chomp\nend",
"def get_color\n if @thread\n return CYCLING\n end\n\n pins = COLORS.select do |pin|\n get_pin pin\n end\n\n if pins.length == 0\n return nil\n elsif pins.length == 1\n return pins.first\n else\n return INVALID_STATE\n end\n end",
"def request_color(string = nil)\n string = '#999' unless string.to_s.match(/#?[0-9A-F]{3,6}/i)\n color = string\n prefix, string = string.match(/(#?)([0-9A-F]{3,6})/i)[1,2]\n string = $1 * 2 + $2 * 2 + $3 * 2 if string =~ /^(.)(.)(.)$/\n \n _options = default_options_for_cocoa_dialog()\n _options[\"color\"] = string\n \n col = cocoa_dialog(\"colorselect\", _options)\n return nil unless col && col != \"\" # user cancelled\n col.delete! '#'\n\n color = prefix\n if /(.)\\1(.)\\2(.)\\3/.match(col) then\n color << $1 + $2 + $3\n else\n color << col\n end\n return color\n end",
"def color\n @color || $def_fg_color\n end",
"def color\n @color\nend",
"def actual_color\n ColorCode.where(numeric_code: default_code.split(\"-\")[-2])[0]\n end",
"def get_user_text_color(user)\n user_color = get_user_color(user).gsub(\"#\", \"\")\n\n # Get the hex color as red, green, blue\n r = user_color[0..1].hex\n g = user_color[2..3].hex\n b = user_color[4..5].hex\n\n if ((r * 0.299) + (g * 0.587) + (b * 0.114)) > 186\n \"#4a4a4a\"\n else\n \"#ffffff\"\n end\n end",
"def color\n @data[:color]\n end",
"def color; end",
"def color; end",
"def color; end",
"def colorQuest(color)\n color = color.downcase if color\n return \"7DC076EF\" if color == \"blue\"\n return \"089D5EBF\" if color == \"red\"\n return \"26CC4B56\" if color == \"green\"\n return \"6F697395\" if color == \"cyan\"\n return \"5CFA729D\" if color == \"magenta\"\n return \"135D47BF\" if color == \"yellow\"\n return \"56946F5A\" if color == \"gray\"\n return \"7FDE6B39\" if color == \"white\"\n return \"751272B7\" if color == \"purple\"\n return \"0E7F4F3F\" if color == \"orange\"\n return \"2D4A5694\" # Returns the default dark gray color if all other options are exhausted\nend",
"def color\n @red ? \"R\" : \"B\"\n end",
"def color\n @data['color']\n end",
"def color\n @color;\n end",
"def color\n Color.new\n end",
"def user_color(user_id)\n User.find(user_id).color\n end",
"def color\n\t\tif name == \"Broken\"\n\t\t\tcolor = \"red\"\n\t\telsif name == \"Needs Attention\"\n\t\t\tcolor = \"orange\"\n\t\telsif name == \"Working\"\n\t\t\tcolor = \"green\"\n\t\telse\n\t\t\tcolor = \"\"\n\t\tend\n\t\treturn color\n end",
"def getColor(theColor, default = 'gray')\n preset = Proc.new do |color|\n case color\n when 'windowBackground' then return NSColor.windowBackgroundColor # 0.93\n when 'textColor' then return NSColor.textColor # 0.0\n when 'backgroundColor' then return NSColor.textBackgroundColor # 1.0\n when 'clear' then return NSColor.clearColor\n else color\n end\n end\n if preset.call(theColor) == 'box' # box fill color doesn't have a system color\n dark = !NSAppearance.currentAppearance.name.to_s.index('Dark').nil?\n rgb = dark ? [0.12, 0.12, 0.12] : [0.89, 0.89, 0.89]\n else # get the specified color or default - no dark mode swaps are performed\n rgb = COLORS[preset.call(default)] if (rgb = COLORS[theColor]).nil?\n end\n rgb = [0.5, 0.5, 0.5] if rgb.nil? # get gray if nothing else has worked\n NSColor.colorWithSRGBRed( rgb[0],\n green: rgb[1],\n blue: rgb[2],\n alpha: 1.0 )\n end",
"def color\n\t\t \t\t\t\"El color de tu vaca es #{@color}\"\n\t\t \t\tend",
"def get_color\n completed? ? 'info' : 'warning'\n end",
"def colour_for(char)\n return '' if char.colour == @colour\n\n @colour = char.colour\n @colour.to_s\n end",
"def see_color(str)\n return 'red' if str.start_with?('red')\n return 'blue' if str.start_with?('blue')\n\n ''\n end",
"def validate_color(color)\n if (color<0) \n return 0\n elsif (color>255)\n return 255\n else\n return color\n end\n end",
"def purple\n colorize(35)\n end",
"def green\n colorize(32)\n end",
"def getColor(colorname)\n# @color = { \"white\" => assignColor256(\"white\",255,255,255),\n# \"black\" => assignColor256(\"black\",0,0,0),\n# \"orange\" => assignColor256(\"orange\",255,0,0),\n# \"red\" => assignColor256(\"red\",0,255,0),\n# \"blue\" => assignColor256(\"blue\",0,0,255),\n# \"grey\" => assignColor256(\"grey\",120,120,120),\n# } ;\n col = @color[colorname] ;\n if(col.nil?) then\n f = File::new(RGBFILE) ;\n rval = -1 ; gval = -1 ; bval = -1 ;\n while(entry = f.gets)\n\tentry.strip! ;\n\trstr,gstr,bstr,name = entry.split ;\n\tif(name == colorname) then\n\t rval = rstr.to_i * 256 ;\n\t gval = gstr.to_i * 256 ;\n\t bval = bstr.to_i * 256 ;\n\t break ;\n\tend\n end\n if(rval < 0) then\n\tif(colorname =~ /^\\#([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/) then\n\t rstr = $1 ; gstr = $2 ; bstr = $3 ;\n\t rval = rstr.hex * 256 ; \n\t gval = gstr.hex * 256 ; \n\t bval = bstr.hex * 256 ; \n\telse\n\t $stderr << \"unknown color name:\" << colorname << \"\\n\" ;\n\tend\n end\n col = assignColor(colorname,rval,gval,bval) ;\n end\n return col ;\n end",
"def rgb_color; end",
"def red\n colorize(:red)\nend",
"def get_color(string)\n\tif $colors[string].nil?\n\t\t$colors[string] = $Colorfmt % $color\n unless $same_color\n $color += 1 \n end\n\tend\n\t$colors[string]\nend",
"def color( *val )\n if val.empty?\n return @color if @color\n return @form.color if @form\n return $def_fg_color\n else\n @color_pair = nil\n return property_set :color, val\n end\n end",
"def red\n colorize(31)\n end",
"def color\n fetch('creature.bird.colors')\n end",
"def calculate_color\n\n self.color || color_by_title\n end",
"def yellow\n colorize(33)\n end",
"def color\n @color ||= color_scope.first\n end",
"def state_color\n result = nil\n states.each do |state|\n result = state.color if state.color\n end\n return result || EmptyColor\n end",
"def get_color\n @colors.each {\n |key, val| \n (val[:set] = true; return val[:syn]) unless val[:set]\n }\n DEFAULT_COLOR\n end",
"def color (color=nil)\n if not color then\n @color\n else\n color = COLORS[color] if color.is_a? Symbol\n color = color.to_str\n if color[0] == ?# and color.length == 7\n color = color[1..-1].to_i(16)\n @color = color * (2**8) + 255\n else\n raise \"color must be a valid string in the format #RRGGBB\"\n end\n end\n end",
"def get_color default=$datacolor, color=color(), bgcolor=bgcolor()\n return default if color.nil? || bgcolor.nil?\n #raise ArgumentError, \"Color not valid: #{color}: #{ColorMap.colors} \" if !ColorMap.is_color? color\n #raise ArgumentError, \"Bgolor not valid: #{bgcolor} : #{ColorMap.colors} \" if !ColorMap.is_color? bgcolor\n acolor = ColorMap.get_color(color, bgcolor)\n return acolor\n end",
"def colors\n return\n end",
"def color\n @color ||= COLORS[label.length%COLORS.length].to_sym\n end",
"def color?\n @color\n end",
"def text_color(param)\n begin \n colour = case param\n when Integer then super(param) rescue normal_color\n when Symbol then send(param) rescue normal_color\n when Array then Color.new(*param) rescue normal_color\n else\n normal_color\n end\n end\n colour.is_a?(Color) ? colour : normal_color\n end",
"def select_color\n selected ? :red : color\n end",
"def color\n @attributes[:color]\n end",
"def colors; end",
"def isColor(c)\n if c == \"r\" or c == \"b\" or c == \"g\" or c == \"y\" or c == \"c\" or c == \"m\" then\n return true\n else\n return false\n end\nend",
"def color_name\n COLOR[self.color.to_s]\n end",
"def getRandomColor()\n num = Random.rand(1..6)\n if num == 1 then return :red\n elsif num == 2 then return :blue\n elsif num == 3 then return :green\n elsif num == 4 then return :yellow\n elsif num == 5 then return :cyan\n elsif num == 6 then return :magenta\n end\nend",
"def green(text)\n colorize(text, 32)\nend",
"def numColor(number)\n if(number > 0)\n return 'green'\n elsif(number < 0)\n return 'red'\n else\n return ''\n end\n end",
"def processed_color\n if(self.processed == \"1\")\n return \"green\"\n else\n return \"red\"\n end\n\n end",
"def colour\n @colour ||= Colour.new(attributes[:colour])\n end",
"def output_color(text, color=text.to_i)\r\n # Color matches: 1 - Black; 2 - White; 3 - Red; 4 - Yellow; 5 - Green; 6 - Blue; 7 - Gold\r\n colors = { 1 => 30, 2 => 36, 3 => 31, 4 => 33, 5 => 35, 6 => 34, 7 => 220 }\r\n # \\e[47m Is for the grey foreground \\e[{color} is for picking the color and \\e[0m is for resetting the terminal.\r\n \"\\e[1m\\e[47m\\e[#{colors[color]}m#{text}\\e[0m\\e[22m\"\r\n end",
"def get_colors_from_player(prompt)\n\t\twhile true\n\t\t\tcolors = encode_input Mastermind.get_user_input(prompt)\n\t\t\treturn colors unless colors.nil?\n\t\t\tputs Mastermind.color(INVALID_INPUT_MESSAGE, \"error\")\n\t\tend\n\tend",
"def processed_color\n if(self.processed == \"1\")\n return \"green\"\n else\n return \"red\"\n end\n end",
"def processed_color\n if(self.processed == \"1\")\n return \"green\"\n else\n return \"red\"\n end\n end",
"def processed_color\n if(self.processed == \"1\")\n return \"green\"\n else\n return \"red\"\n end\n end",
"def processed_color\n if(self.processed == \"1\")\n return \"green\"\n else\n return \"red\"\n end\n end",
"def processed_color\n if(self.processed == \"1\")\n return \"green\"\n else\n return \"red\"\n end\n end",
"def processed_color\n if(self.processed == \"1\")\n return \"green\"\n else\n return \"red\"\n end\n end",
"def scan_for_colors; end",
"def fg(c)\n return self unless ANSI_COLORS[c]\n return colorize(ANSI_COLORS[c])\n end",
"def get_user_color(user)\n require \"digest/md5\"\n \"##{Digest::MD5.hexdigest(user.name)[0..5]}\"\n end",
"def to_string\r\n \"#{colour}\"\r\n end",
"def getComplement(color)\n\tcase color\n\n\twhen \"red\"\n\t\treturn \"cyan\"\n\twhen \"green\"\n\t\treturn \"magenta\"\n\twhen \"yellow\"\n\t\treturn \"blue\"\n\twhen \"blue\"\n\t\treturn \"yellow\"\n\twhen \"magenta\"\n\t\treturn \"green\"\n\twhen \"cyan\"\n\t\treturn \"red\"\n\telse\n\t\tputs \"ERROR in getComplement\"\n\t\treturn\n\tend\n\nend",
"def colors(warm, cool)\n puts \"#{warm} is a contrast color to #{cool}\"\nend",
"def symbol\n @color \n end",
"def dopp_colour(name)\n dopp = SHA1.hexdigest(name)\n\tr = (128 + (dopp[0..1].hex)/2).to_s(16)\n\tg = (128 + (dopp[2..3].hex)/2).to_s(16)\n\tb = (128 + (dopp[4..5].hex)/2).to_s(16)\n return [r,g,b].join()\nend",
"def getDrawColor()\n return @drawColor\n end",
"def colour(name, text)\n if Pry.color\n str = Pry::Helpers::Text.send(name, text)\n unless str.start_with?(\"\\001\")\n str = \"\\001#{Pry::Helpers::Text.send name, '{text}'}\\002\".sub '{text}', \"\\002#{text}\\001\"\n end\n str\n else\n text\n end\nend",
"def context_get_fgcolor()\n return $gimp_iface.gimp_context_get_foreground()[0]\nend",
"def auxiliary_colour\n @cr[0xe] >> 4\n end",
"def get_color(key)\n if key.is_a? String\n color = key\n elsif Wirb::COLORS.key?(key)\n color = Wirb::COLORS[key]\n end\n\n color ? \"\\033[#{ color }m\" : ''\n end",
"def color\n case (@code.to_i / 100)\n when 2\n color = :green\n when 3\n color = :yellow\n when 4, 5\n color = :red\n else\n color = :blue\n end\n color\n end",
"def status_color(accepted)\n if accepted == 0\n return \"style=\\\"color:red;\\\"\"\n elsif accepted == 1\n return \"style=\\\"color:gray;\\\"\"\n elsif accepted == 2\n return \"style=\\\"color:black;\\\"\"\n else\n return \"style=\\\"color:red;\\\"\"\n end\n end",
"def color_name\n fetch('color.name')\n end",
"def dampen_color(color)\n return \"#CC9933\" if color == \"#EBE129\" # Yellow\n return \"#CD32AA\" if color == \"#CCA6FC\" # Pinkish\n color\n end",
"def r; self.color.r end",
"def about\n @color = params[:color]\n end",
"def get_current_color(points, x, y)\n if points.key?(x.to_s.to_sym) && points[x.to_s.to_sym].key?(y.to_s.to_sym)\n points[x.to_s.to_sym][y.to_s.to_sym]\n else\n BLACK\n end\nend",
"def colour_for(char)\n return ''.freeze if char.colour == @colour\n\n @colour = char.colour\n @colour.to_s\n end",
"def red(input)\n puts \"\\e[31m#{input}\\e[0m\"\nend",
"def red(input)\n puts \"\\e[31m#{input}\\e[0m\"\nend",
"def red(text)\n colorize(text, 31)\nend",
"def background_color(color); end",
"def get_color(color) # :nodoc:\n # Convert a HTML style #RRGGBB color.\n if color and color =~ /^#[0-9a-fA-F]{6}$/\n color = color.sub(/^#/, '')\n return color.upcase\n end\n\n index = Format.get_color(color)\n\n # Set undefined colors to black.\n unless index\n index = 0x08\n raise \"Unknown color '#{color}' used in chart formatting.\"\n end\n\n get_palette_color(index)\n end",
"def get_color(rating)\n colors = {\n 10 => '#00cc00',\n 9 => '#33cc99',\n 8 => '#66ff99',\n 7 => '#99ffff',\n 6 => '#9999ff',\n 5 => '#cc99ff',\n 4 => '#ff66cc',\n 3 => '#ff6699',\n 2 => '#ff3366',\n 1 => '#ff0000',\n }\n return colors[rating]\n end",
"def rgb_style(string)\n pastel = Pastel.new\n styled_rgb = pastel.red(\"#{string[0]}\") + pastel.green(\"#{string[1]}\") + pastel.blue(\"#{string[2]}\")\n return styled_rgb\nend",
"def color_pick\n if mark_ratio < (day_parameter + least_mark_ratio)\n color = \"#C7E6F2\" #light color below average performance\n elsif mark_ratio >= ((2*day_parameter) + least_mark_ratio)\n color = \"#44bbdf\" #dark color excellent perfomance\n else\n color = \"#70c9e5\" #meduim color average performance\n end \n return color \n end"
] | [
"0.7778326",
"0.75625",
"0.7505634",
"0.7385949",
"0.7374629",
"0.7374629",
"0.7343969",
"0.72700876",
"0.72700876",
"0.72321415",
"0.721719",
"0.72035575",
"0.716802",
"0.7166885",
"0.71456116",
"0.7118985",
"0.70945656",
"0.7090077",
"0.7090077",
"0.7090077",
"0.70468515",
"0.7036095",
"0.7031343",
"0.702861",
"0.70127505",
"0.7008643",
"0.70054895",
"0.6942306",
"0.69300914",
"0.692895",
"0.6914641",
"0.6912385",
"0.6905988",
"0.6899184",
"0.6878695",
"0.68783295",
"0.6861307",
"0.68411005",
"0.6831644",
"0.6824364",
"0.680235",
"0.67966634",
"0.6796577",
"0.67902654",
"0.6770479",
"0.67686766",
"0.6764834",
"0.6754288",
"0.67341524",
"0.672595",
"0.67163056",
"0.6712003",
"0.6691426",
"0.66800517",
"0.66656196",
"0.6658745",
"0.66523546",
"0.66442186",
"0.66367316",
"0.6624419",
"0.66225106",
"0.6617365",
"0.661614",
"0.6614415",
"0.66141576",
"0.6594057",
"0.6594057",
"0.6594057",
"0.6594057",
"0.6594057",
"0.6594057",
"0.65825796",
"0.6576875",
"0.6572754",
"0.6568656",
"0.65600026",
"0.655544",
"0.6545317",
"0.65432924",
"0.6542495",
"0.6537887",
"0.65312296",
"0.6530994",
"0.65261567",
"0.65248036",
"0.6524083",
"0.6523421",
"0.6516149",
"0.6515821",
"0.6506566",
"0.65026325",
"0.6499172",
"0.6498907",
"0.6498907",
"0.6498436",
"0.64939976",
"0.6490314",
"0.649",
"0.6488276",
"0.6487473"
] | 0.7542151 | 2 |
Method used to display the board on the screen | def display_board(board,number_of_turns,progress)
board.each do |row|
row.each do |cell|
# Each element of the board contains 2 space characters
# 'colorize' gem is used to print coloured text
# and 'cell' contains the colour which to be used
print " ".colorize(:background=>cell)
end
puts ""
end
# Show the number of turns and completion
puts "Current number of turns: #{number_of_turns}"
puts "Current completion: #{progress}%"
# Ask the user to input the colour as long as the game is not finished
if progress < 100
print "Choose a colour: "
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"---------------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"---------------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \" ----------- \"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \" ----------- \"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n\n end",
"def display_board\n\n puts \" #{@board[0].mark} | #{@board[1].mark} | #{@board[2].mark} \"\n puts \"-----------\"\n puts \" #{@board[3].mark} | #{@board[4].mark} | #{@board[5].mark} \"\n puts \"-----------\"\n puts \" #{@board[6].mark} | #{@board[7].mark} | #{@board[8].mark} \"\n end",
"def display_board\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend",
"def display_board\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend",
"def display_board\n puts \" | | \"\n puts\"-----------\"\n puts \" | | \"\n puts\"-----------\"\n puts \" | | \"\nend",
"def show_board\n @display.each do |row|\n puts row.join(' ')\n end\n end",
"def display_board\n puts \" | | \" \n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend",
"def display_board\n\t board =\" | | \\n-----------\\n | | \\n-----------\\n | | \"\n\t puts board\n\tend",
"def display_board()\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board()\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \" ----------- \"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \" ----------- \"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n\t\t\tsystem(\"cls\")\n\t\t\tprint \"\\n\"\n\t\t\t 7.downto(0).each_with_index{|x|\n\t\t\t\t print \"#{x+1}| \"\n\t\t\t\t\t8.times{|y|\n\t\t\t\t\tif y%2==0 && x%2 == 0 || y%2==1 && x%2 == 1\n\t\t\t\t\t\tif @board[y][x] != nil && @board[y][x].color == \"white\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].white.bold.on_red, \" \".on_red\n\t\t\t\t\t\telsif @board[y][x] != nil && @board[y][x].color == \"black\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].green.bold.on_red, \" \".on_red\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tprint \" \".on_red\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tif @board[y][x] != nil && @board[y][x].color == \"white\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].white.bold, \" \"\n\t\t\t\t\t\telsif @board[y][x] != nil && @board[y][x].color == \"black\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].green.bold, \" \"\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tprint \" \", \" \"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\tprint \"\\n\"\n\t\t\t\t }\n\t\t\t print \"------------------\\n\"\n\t\t\t print \" a b c d e f g h\\n\\n\"\n\tend",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\r\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\r\n end",
"def display_board\r\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\r\n end",
"def display_board\n\t\tsystem \"clear\" or system \"cls\"\n\t\tprint \" 1 2 3 4 5 6 7 8 \\n\\n\"\n\t\t(0..7).each do |row|\n\t\t\tprint \"#{(row+97).chr} \"\n\t\t\t(0..7).each do |collumn|\n\t\t\t\tprint \"#{@board[row][collumn]} \" if @board[row][collumn] == \"X\"\n\t\t\t\tprint @board[row][collumn].to_s + \" \" if @board[row][collumn].is_a?(Piece)\n\t\t\tend\n\t\t\tprint \" #{(row+97).chr} \"\n\t\t\tputs\n\n\t\tend\n\t\tprint \"\\n 1 2 3 4 5 6 7 8 \\n\"\n\tend",
"def show_board\n puts \" \" + board_spaces[1] + \" | \" + board_spaces[2] + \" | \" + board_spaces[3] + \" \"\n puts \"-----------\"\n puts \" \" + board_spaces[4] + \" | \" + board_spaces[5] + \" | \" + board_spaces[6] + \" \"\n puts \"-----------\"\n puts \" \" + board_spaces[7] + \" | \" + board_spaces[8] + \" | \" + board_spaces[9] + \" \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts '---------------'\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts '---------------'\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n row1 = \" #{@board[0]} | #{@board[1]} | #{@board[2]}\\n\"\n row2 = \" #{@board[3]} | #{@board[4]} | #{@board[5]}\\n\"\n row3 = \" #{@board[6]} | #{@board[7]} | #{@board[8]}\\n\"\n spacer = \"-----------\\n\"\n\n row1 + spacer + row2 + spacer + row3\n end",
"def display_board\n\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n\n end",
"def display_board\n puts \"#{human.name}: #{human.marker}, #{computer.name}: #{computer.marker}\"\n puts \"Round #{@round}.\"\n puts \"Score: #{human.score} - #{computer.score}\"\n puts \"\"\n board.draw\n puts \"\"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n\n end",
"def display_board\n puts\n puts \"Here is the current board:\"\n puts \n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"---+---+---\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"---+---+---\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n puts \n end",
"def display\n \"\\n=============COMPUTER BOARD=============\\n\" +\n \"#{@npc.board.render}\\n\" +\n \"==============PLAYER BOARD==============\\n\" +\n \"#{@user_board.render(true)}\\n\"\n end",
"def display_board\n puts \"\\n---------------\\n\".center(5)\n @board.play_area[0..2].each { |square| print square.to_s.center(5) }\n puts \"\\n\\n\"\n @board.play_area[3..5].each { |square| print square.to_s.center(5) }\n puts \"\\n\\n\"\n @board.play_area[6..8].each { |square| print square.to_s.center(5) }\n puts \"\\n---------------\\n\".center(5)\n end",
"def display_board\n puts \"#{@board[0].value} | #{@board[1].value} | #{@board[2].value}\"\n puts \"-\"*10\n puts \"#{@board[3].value} | #{@board[4].value} | #{@board[5].value}\"\n puts \"-\"*10\n puts \"#{@board[6].value} | #{@board[7].value} | #{@board[8].value}\"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n end",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n end",
"def display_board\n puts \" \" \"|\" \" \" \"|\" \" \"\n puts \"-----------\"\n puts \" \" \"|\" \" \" \"|\" \" \"\n puts \"-----------\"\n puts \" \" \"|\" \" \" \"|\" \" \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"---+----+----\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"---+----+----\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n end",
"def board_display\n puts @board\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \" \n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def show()\n\t\tputs (' \t|\t' + ' \t|\t')\n\t\tputs (@@board[7] + '\t|\t' + @@board[8] + '\t|\t' + @@board[9])\n\t\tputs ('------------------------------------')\n\t\tputs (@@board[4] + '\t|\t' + @@board[5] + '\t|\t' + @@board[6])\n\t\tputs (' \t|\t' + ' \t|\t')\n\t\tputs ('------------------------------------')\n\t\tputs (@@board[1] + '\t|\t' + @@board[2] + '\t|\t' + @@board[3])\n\t\tputs (' \t|\t' + ' \t|\t')\n\tend",
"def display\n @board.each { |x| \n puts x.join(\" \")\n }\n end",
"def show_board # show the game board\n print @board[0..2]\n puts \"\\n\"\n print @board[3..5]\n puts \"\\n\"\n print @board[6..8]\n puts \"\\n\"\n end",
"def display\n puts \"\\n GAME BOARD \"\n puts \" Turn #{turn_count}\"\n puts \"*************\"\n puts \"* #{self.cells[0]} | #{self.cells[1]} | #{self.cells[2]} *\"\n puts \"*-----------*\"\n puts \"* #{self.cells[3]} | #{self.cells[4]} | #{self.cells[5]} *\"\n puts \"*-----------*\"\n puts \"* #{self.cells[6]} | #{self.cells[7]} | #{self.cells[8]} *\"\n puts \"*************\\n\\n\"\n end",
"def display\n system('clear')\n puts\n # show board with pieces\n print \"\\t\\tA\\tB\\tC\\tD\\tE\\tF\\tG\\tH\\n\\n\"\n print \"\\t +\", \" ----- +\"*8,\"\\n\\n\"\n 8.downto(1) do |rank|\n print \"\\t#{rank} |\\t\"\n 'A'.upto('H') do |file|\n if board[\"#{file}#{rank}\".to_cell] then piece = board[\"#{file}#{rank}\".to_cell]\n else piece = \" \"\n end\n print \"#{piece} |\\t\"\n end\n print \"#{rank}\\n\\n\\t +\", \" ----- +\"*8,\"\\n\\n\"\n end\n print \"\\t\\tA\\tB\\tC\\tD\\tE\\tF\\tG\\tH\"\n puts \"\\n\\n\"\n # show occupancy\n print \" White occupancy: \"\n puts whitePieces.to_cells.map{ |cell| cell.to_square}.join(\", \")\n print \" Black occupancy: \"\n puts blackPieces.to_cells.map{ |cell| cell.to_square}.join(\", \")\n puts\n # show whose move it is\n case @whitesMove\n when true\n puts \" WHITE to move.\"\n when false\n puts \" BLACK to move.\"\n end\n puts\n end",
"def draw_board()\n @board\n p \"#{@board[0]} || #{@board[1]} || #{@board[2]}\"\n p \"===========\"\n p \"#{@board[3]} || #{@board[4]} || #{@board[5]}\"\n p \"===========\"\n p \"#{@board[6]} || #{@board[7]} || #{@board[8]}\"\n puts \"\\n\"\n puts \"\\n\"\n end",
"def game_board_display(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n\n end",
"def display\n puts \"#{@board.join(\" \")}\"\n end",
"def display_board\n\t\tputs \"\\n\\n\"\n\t\tprint \"|\\u2460 |\\u2461 |\\u2462 |\\u2463 |\\u2464 |\\u2465 |\\u2466 |\"\n\t\t@board.plastic.reverse.each do |row|\n\t\t\tprint \"\\n|\"\n\t\t\trow.each {|x| print \"#{x.to_c} |\"} \t\t\t\n\t\tend\n\t\tputs \"\"\n\tend",
"def display(board)\n @board = board\n render\n end",
"def display_board(board)\n\tputs \" #{board[0]} | #{board[1]} | #{board[2]} \"\n\tputs \"-----------\"\n\tputs \" #{board[3]} | #{board[4]} | #{board[5]} \"\n\tputs \"-----------\"\n\tputs \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board\r\nprint \" #{@board[0]} | #{@board[1]} | #{@board[2]} \\n\"\r\nprint \"-----------\\n\"\r\nprint \" #{@board[3]} | #{@board[4]} | #{@board[5]} \\n\"\r\nprint \"-----------\\n\"\r\nprint \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\r\nend",
"def drawBoard\n @board.each do |element|\n print \"#{element} \"\n puts \"\"\n end\n end",
"def display_board\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(hide_secret = false)\n\t\tdisplay_colors\n\t\tdisplay_decoding_rating_board\n\t\tdisplay_secret_board(hide_secret)\n\tend",
"def display_board\n board = \" | | \n-----------\n | | \n-----------\n | | \"\n puts board\nend",
"def display\n\t\tbreakline = \"---- --- ----\"\n\t\tputs breakline.center(@linewidth)\n\t\tputs \"| #{@board[:one]} | #{@board[:two]} | #{@board[:three]} |\".center(@linewidth)\n\t\tputs breakline.center(@linewidth)\n\t\tputs \"| #{@board[:four]} | #{@board[:five]} | #{@board[:six]} |\".center(@linewidth)\n\t\tputs breakline.center(@linewidth)\n\t\tputs \"| #{@board[:seven]} | #{@board[:eight]} | #{@board[:nine]} |\".center(@linewidth)\n\t\tputs breakline.center(@linewidth)\n\t\tputs \"\".center(@linewidth)\n\tend",
"def display_board\n display = \" a b c d e f g h \\n\"\n @board.each_with_index do |arr, i|\n line = \"#{i + 1} \"\n arr.each do |hash|\n hash[:piece].nil? ? line += \"#{hash[:base]} \" : line += \"#{hash[:piece].name} \"\n end\n line += \"\\n\"\n display += line\n end\n display\n end",
"def draw_board\n\t\tputs \"#{@board[\"a1\"]} | #{@board[\"a2\"]} | #{@board[\"a3\"]}\"\n\t\tputs \"-----------\"\n\t\tputs \"#{@board[\"b1\"]} | #{@board[\"b2\"]} | #{@board[\"b3\"]}\"\n\t\tputs \"-----------\"\n\t\tputs \"#{@board[\"c1\"]} | #{@board[\"c2\"]} | #{@board[\"c3\"]}\"\n\tend",
"def display_board(brd)\n puts green(\"You're #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\")\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\\n\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\\n\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board\n print \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n print \"-----------\"\n print \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n print \"-----------\"\n print \" #{@board[6]} | #{@board[7]} | #{@board[8]} \" \nend",
"def display_board\n if @lists.empty?\n display_menu\n end\n\n system \"clear\"\n \n # Itereate through each list in the board\n for list in @lists.values\n # Store the card description in an array used to print to the user\n card_descriptions = []\n for card in list.cards.values\n card_descriptions.push(card.description)\n end\n\n # Use a TTY Box to represent a list visually\n print TTY::Box.frame(width: 30, height: (list.cards.values.length + 1) * 2, title: {top_left: \"#{list.title}\"}) { card_descriptions.join(\"\\n\") }\n end\n\n display_menu\n end",
"def render\n @board_array.each_with_index do |row, row_index|\n row.each_with_index do |cell, col_index|\n if @position_hash[[row_index, col_index]].hidden\n print '______'\n else\n print cell.to_s\n end\n end\n print \"\\n\"\n end\n end",
"def display_board(board)\n system('cls')\n puts \"Player is #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{board[1]} | #{board[2]} | #{board[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{board[4]} | #{board[5]} | #{board[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{board[7]} | #{board[8]} | #{board[9]}\"\n puts \" | |\"\n puts \"\"\nend",
"def render_board\n i = 0\n while i < board.dimension\n puts \"\"\"\n #{render_row(i)} \"\"\"\n i += 1\n end\n end",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend"
] | [
"0.82833374",
"0.8256956",
"0.8243903",
"0.8239019",
"0.8234275",
"0.8234275",
"0.82334036",
"0.82197326",
"0.8208226",
"0.81796664",
"0.8175248",
"0.8175248",
"0.8108998",
"0.8099377",
"0.80955386",
"0.80955386",
"0.80955386",
"0.80955386",
"0.80955386",
"0.80955386",
"0.80955386",
"0.80955386",
"0.80955386",
"0.80955386",
"0.80955386",
"0.8090934",
"0.8090934",
"0.8072502",
"0.8067202",
"0.8052386",
"0.80344015",
"0.8028066",
"0.8026204",
"0.8009415",
"0.80017155",
"0.7992804",
"0.79834247",
"0.79822946",
"0.7982047",
"0.7975202",
"0.7969375",
"0.79555166",
"0.79555166",
"0.79528207",
"0.79379296",
"0.7933401",
"0.79323995",
"0.79233974",
"0.79190093",
"0.78561574",
"0.7850143",
"0.7838452",
"0.7834305",
"0.78088266",
"0.7808487",
"0.7801893",
"0.7793949",
"0.77758324",
"0.77490723",
"0.7732691",
"0.772556",
"0.7721073",
"0.7715751",
"0.7701496",
"0.7698688",
"0.76932895",
"0.7673718",
"0.7667926",
"0.7660828",
"0.76571137",
"0.7643927",
"0.76310796",
"0.762804",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892",
"0.7626892"
] | 0.0 | -1 |
Method used to change the size of the board | def change_size()
print "Width (Currently #{$board_width})? "
# Validate the input
# If the user input is invalid, the user will be asked to try again
valid = false
until valid == true do
input = gets.chomp
if input.to_i.to_s == input then
$board_width = input.to_i
valid = true
else
puts "Input is not an integer! Try again: "
end
end
print "Height (Currently #{$board_height})? "
# Validate the input
# If the user input is invalid, the user will be asked to try again
valid = false
until valid == true do
input = gets.chomp
if input.to_i.to_s == input then
$board_height = input.to_i
valid = true
else
puts "Input is not an integer! Try again: "
end
end
# The best score is reset when the board size is changed
$best_score = 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def board_size\n\t\t@board.size\n\tend",
"def size \n\n\t\t# Set the basic metrics\n\t\tcase @board_size\n\t\twhen :small \t\t\t\t# A 20x20 grid\n\t\t\t@width = 30\n\t\t\t@height = 20\n\t\t\t@dragon_count = 50 * @board_level\n\t\t\t@cell_size = 30\n\t\t\t@cover_png = 'sprites/cover_30.png'\n\t\t\t@dragon_png = 'sprites/dragon_30.png'\n\t\t\t@gold_png = 'sprites/gold_30.png'\n\t\t\t@cell_png = [ 'sprites/cell0_30.png', 'sprites/cell1_30.png', 'sprites/cell2_30.png', \n\t\t\t\t\t\t 'sprites/cell3_30.png', 'sprites/cell4_30.png', 'sprites/cell5_30.png',\n\t\t\t\t\t\t 'sprites/cell6_30.png', 'sprites/cell7_30.png', 'sprites/cell8_30.png' ]\n\t\tend\n\n\t\t# Clear and resize the board array\n\t\t@spawned = false\n\t\t@victorious = false\n\t\t@burniation = -1\n\t\t@burn_size = 1\n\t\t@dragons = Array.new( @width * @height, 0 )\n\t\t@cell_status = Array.new( @width * @height, :status_covered )\n\n\t\t# Decide how big the stuff on the right hand side should be\n\t\t@label_size = -2.5\n\t\t@size_restart = $gtk.calcstringbox( \"Restart\", @label_size )\n\t\t@size_dragon = $gtk.calcstringbox( \"888 Dragons To Find\", @label_size )\n\t\t@size_time = $gtk.calcstringbox( \"88:88:88\", @label_size )\n\n\t\twhile [ @size_restart.x, @size_dragon.x, @size_time.x ].max < ( $gtk.args.grid.w - ( ( @width + 6 ) * @cell_size ) )\n\n\t\t\t# Try some slightly bigger sizes then\n\t\t\t@size_restart = $gtk.calcstringbox( \"Restart\", @label_size+0.1 )\n\t\t\t@size_dragon = $gtk.calcstringbox( \"888 Dragons To Find\", @label_size+0.1 )\n\t\t\t@size_time = $gtk.calcstringbox( \"88:88:88\", @label_size+0.1 )\n\n\t\t\t# And nudge up the label size\n\t\t\t@label_size += 0.1\n\t\tend \n\n\t\t@label_size -= 0.1\n\t\t@size_restart = $gtk.calcstringbox( \"Restart\", @label_size )\n\t\t@size_dragon = $gtk.calcstringbox( \"888 Dragons To Find\", @label_size )\n\t\t@size_time = $gtk.calcstringbox( \"88:88:88\", @label_size )\n\t\t\n\t\t# Lastly, work out some sensible offsets\n\t\t@board_w = @width * @cell_size\n\t\t@board_h = @height * @cell_size\n\t\t@board_x = 2 * @cell_size \n\t\t@board_y = $gtk.args.grid.center_y - ( @board_h / 2 )\n\n\t\t@label_x = @board_x + @board_w + ( 2 * @cell_size )\n\t\t@label_time_y = $gtk.args.grid.center_y + ( @size_time.y + 20 ) * 1.5\n\t\t@label_dragon_y = @label_time_y - 20 - @size_dragon.y - 20\n\t\t@label_restart_y = @label_dragon_y - 20 - @size_restart.y - 20\n\n\t\t@label_width = [ @size_restart.x, @size_dragon.x, @size_time.x ].max + 20\n\n\tend",
"def size=(dimension); end",
"def fill_board(size)\n board = []\n board_rows = []\n size.times {|i| board_rows << i}\n size.times {board << board_rows}\n @board = board\n end",
"def size=(width, height)\n end",
"def resize_to(width, height); end",
"def resize(width, height); end",
"def incSize\n if ((@y + @size) < 254) & ((@x + @size) < 510)\n call erase\n let @size = @size + 2\n call draw\n end\n end",
"def update_size(x,y)\n @width = x if x > @width\n @height = y if y > @height\n end",
"def size=(size)\n @size = size\n resize\n end",
"def change_size(size)\n return false if size == current_image_size\n\n if size == 'auto'\n new_column, new_row, new_extra_lines = working_article.calculate_fitting_image_size(column, row, extra_height_in_lines)\n if column == new_column && row == new_row && extra_height_in_lines == new_extra_lines\n return false\n end\n\n self.column = new_column\n self.row = new_row\n self.extra_height_in_lines = new_extra_lines\n save\n true\n elsif size.include?('x')\n size_array = size.split('x')\n self.column = size_array[0].to_i\n self.row = size_array[1].to_i\n save\n true\n else\n puts 'wrong size format!!!'\n return false\n end\n end",
"def size(w,h)\n @size = \"#{w}x#{h}\"\n end",
"def size=(size)\n raise ArgumentError, \"Rect#size= takes an Array of form [width, height].\" if size.size != 2\n self[2,2] = size\n size\n end",
"def resize!\n @arr.size *=2\n end",
"def resize new_width, new_height\n win.resize new_width, new_height\n end",
"def resize!\n end",
"def resize width = max_width, height = max_height\n @form.resize width, height\n self.write Mine::Key.RESIZE\n end",
"def resize(width, height)\n end",
"def size=(size)\n self.width = self.height = @size = size\n end",
"def update_size(width, height) \n if @vertical\n @height += height\n @width = width if width > @width\n else\n @width += width\n @height = height if height > @height\n end\n end",
"def setBrushSize(size)\n puts(\"Brush size updated\") \n @brushSize = size\n end",
"def resize width, height\n @widgets[@index].width = width\n @widgets[@index].height = height\n @widgets[@index].repaint\n end",
"def set_playground_size(size)\n @playground.size = size\n end",
"def set_size(w,h)\n @width = w\n @height = h\n end",
"def initialize(size)\n @board_size = size\n @board = []\n @board_size.times { @board << Array.new(@board_size, EMPTY_SYMBOL) }\n end",
"def setSize(width, height)\n setWidth(width)\n setHeight(height)\n end",
"def updateSize(x,y)\n x = (@panel.getWidth() > x) ? @panel.getWidth : x\n y = (@panel.getHeight() > y) ? @panel.getHeight : y\n @panel.setPreferredSize(Dimension.new(x,y))\n end",
"def change_board_size(highest_score, width, height)\n #Asks for the users input for both width and height and then sets them accordingly\n puts \"Width (Currently #{width}), change it to?\"\n width = gets.chomp.to_i\n puts \"Height (Currently #{height}), change it to? \"\n height = gets.chomp.to_i\n #Resets the high score when the user changes board size as you would expect to happen \n highest_score = 0\n display_main_menu(highest_score, width, height)\nend",
"def piece_size=(v)\n return unless v\n @piece_count = nil\n @piece_size = [v, 1024].max\n end",
"def setCanvasSize\n if @intTargetX.to_s.to_i > 20 and @intTargetY.to_s.to_i > 20\n puts('setting new dimetions')\n @canvasRefrance.resizeCanvas(@intTargetY.to_s.to_i,@intTargetX.to_s.to_i)\n else \n puts('setting defult dimentions')\n @canvasRefrance.resizeCanvas(@minDimensions,@minDimensions)\n end\n end",
"def initialize(size)\n @board = Array.new(size) {Array.new(size){ '*' } }\n end",
"def resize(size)\n @size = size\n new_slots = Array.new(@size).map { 0 }\n new_slots.each_with_index do |slot, i|\n new_slots[i] = @slots[i]\n end\n @slots = new_slots\n end",
"def initializeBoard()\n #\n # TO DO: complete this method\n #\n for j in 0...@size\n for i in 0...@size\n @board[j][i]=EMPTY\n end\n end\n center = (@size/2)-1\n @board[center][center] = BLACK\n @board[center+1][center+1] = BLACK\n @board[center+1][center] = WHITE\n @board[center][center+1] = WHITE\n\n\n\n\n end",
"def populate_board\n rows_of_pieces = (size - 2) / 2\n make_pieces([0, 1], 'red', rows_of_pieces, 1)\n make_pieces([size - 1, 0], 'black', rows_of_pieces, -1)\n end",
"def decSize\n if @size > 2\n call erase\n let @size = @size - 2\n call draw\n end\n end",
"def size\n width * height\n end",
"def size=(size)\n end",
"def main_setter(board, score, gameover)\n @board = board\n @size = 4\n @score = score\n @gameover = gameover\n end",
"def build_grid size\n self.tiles.clear\n size.to_i.times do |row|\n size.to_i.times do |column|\n self.tiles.build({\n x: column,\n y: row\n })\n end\n end\n end",
"def size= (x)\n change_options({\"size\" => x})\n end",
"def real_piece_size\n piece_size + connector_size\n end",
"def initializeBoard()\n\n # TO DO: COMPLETE THIS METHOD\n maxMid = @size / 2\n minMid = @size / 2 - 1\n for i in 0..size-1\n for j in 0..size-1\n if i == maxMid && j == maxMid\n @board[i][j] = \"B\"\n elsif i == minMid && j == minMid\n @board[i][j] = \"B\"\n elsif (i == minMid || i == maxMid) && (j == maxMid || j == minMid)\n @board[i][j] = \"W\"\n else\n @board[i][j] = \"-\";\n end\n end\n end\n end",
"def sizeup(size)\n return nil if canvas.size.contains?(size)\n canvas.resize(canvas.size.max(size), max_width: @max_width)\n end",
"def size\n\t\t@w * @h\n\tend",
"def size(width, height)\n self.width = width\n self.height = height\n end",
"def build_square size\n #starting positions\n x,y = size/2,0\n\n # build square\n (1..size**2).inject(Array.new(size){[]}) do |arr,i|\n\n # store current number in square\n arr[y][x] = i\n\n # move up and left\n x = (x+1)%size\n y = (y-1)%size\n\n # undo move and move down if space is taken\n if arr[y][x]\n y = (y+2)%size\n x = (x-1)%size\n end\n arr\n end\n end",
"def update_size\n @max_x = @glade['drawingarea'].allocation.width - 1\n @max_y = @glade['drawingarea'].allocation.height - 1\n @glade['xvalue'].set_range(1,@max_x)\n @glade['yvalue'].set_range(1,@max_y)\n end",
"def update_scale\n heightpx = @board.height*@scale\n widthpx = @board.width*@scale\n # Gameboard\n @board_window.height = heightpx\n @board_window.width = widthpx\n # Clue windows\n @clues_windows[:rows].height = heightpx\n @clues_windows[:rows].width = (@scale*@board.clues[:rows].map { |row| row.length }.max)\n @clues_windows[:columns].height = (@scale*@board.clues[:columns].map { |column| column.length }.max)\n @clues_windows[:columns].width = widthpx\n # Clues\n @clues_list.each { |clue| clue[:text_object].delete() }\n @passing.each { |pass| pass.remove() }\n @passing = draw_passing(@board.clues)\n @clues_list = draw_clues(@board.clues)\n # Blocks\n @blocks.each do |block, cell|\n x = block.coords[:x]*@scale\n y = block.coords[:y]*@scale\n cell.coords = [x, y, x+@scale, y+@scale]\n end\n # Guide lines\n @guide_lines.each { |line| line.remove }\n @guide_lines = draw_guide_lines()\n update_highlight()\n end",
"def slot_size (size)\r\n @slot_size = size\r\n end",
"def resize_type(type, to_size)\n resize(type => to_size)\n end",
"def number_of_cells(size)\n size * size\n end",
"def initialize(size)\n @board = Array.new(size[0])\n @board.each_index do |i|\n @board[i] = Array.new(size[1])\n end\n end",
"def size=(size='300x200')\n @width, @height = size.split(\"x\").map { |dimension| dimension.to_i }\n end",
"def size(x, y=nil)\n settings.size = [x, y || x]\n end",
"def size\n\t\t@rows * @columns\n\tend",
"def set_size!(size) \n @transforms << SIZES[size]\n self \n end",
"def size\n \"#{width}x#{height}\"\n end",
"def size\n \"#{width}x#{height}\"\n end",
"def update_local_window_size(size); end",
"def size=(size)\n instance_set(:size, size)\n end",
"def size=(value)\n @size = value\n end",
"def size=(value)\n @size = value\n end",
"def adapt_design_size \n hits = 0\n while space_factor < Constants::Min_allowed_factor and hits < 3\n if @vertical \n @height /= Constants::Shrink_factor\n @height += @height%20 == 0 ? 0 : 20-@height%20\n elsif not @vertical\n @width /= Constants::Shrink_factor\n @width += @width%20 == 0 ? 0 : 20-@width%20\n end\n composite_main_image_position\n generate_white_spaces\n white_space_area = white_space_w * white_space_h\n hits +=1\n end\n end",
"def set_Size(value)\n set_input(\"Size\", value)\n end",
"def settings\n size 400, 300\nend",
"def initializeBoard()\n\t\tfor i in (0...@board.length)\n\t\t\tfor j in (0...@board.length)\n\t\t\t\t@board[i][j] = EMPTY\n\t\t\tend\n\t\tend\n\n\t\t@board[@size/2][@size/2] = BLACK\n\t\t@board[@size/2 - 1][@size/2 - 1] = BLACK\n\t\t@board[@size/2 - 1][@size/2] = WHITE\n\t\t@board[@size/2][@size/2 - 1] = WHITE\n\n end",
"def size\n rows * columns\n end",
"def create_board(size, num_mines)\n\t\tfinal_board = []\n\t\t# Create outer loop\n\t\t1.upto(size) do |row|\n\t\t\trow_buffer = []\n\t\t\t# Create inner loop\n\t\t\t1.upto(size) do |column|\n\t\t\t\trow_buffer << Square.new([column,((size+1)-row)], size)\n\t\t\tend\n\t\t\t# Once each row is composed add it to \n\t\t\t# the final board.\n\t\t\tfinal_board << row_buffer\n\t\tend\n\t\tset_mines(final_board, num_mines) # Now that we have the board, lets add some mines\n\t\tfinal_board\n\tend",
"def increment_size\n\t\tincremented_size = row_count + 1\n\n\t\t@rows = Array.new(incremented_size){Array.new(incremented_size, 0)}\t# adding a row and a column to the current Matrix\n\t\t@row_count = incremented_size\t# incrementing the counter of rows\n\t\t@column_count = incremented_size\t# incrementing the counter of columns\n\tend",
"def resize(size)\n dup.resize!(size)\n end",
"def setPixelSize(width, height)\n setWidth(width + \"px\") # if width >= 0\n setHeight(height + \"px\") # if height >= 0\n end",
"def place_ship(size)\n span = free_squares.select { |span| span.count >= size }.sample\n raise \"We're getting crowded here\" unless span\n offset = rand(0..span.count - size)\n @ship_squares << span.slice(offset, size)\n @ship_squares.last.each { |cell| cell.ship = size }\n end",
"def resize_width(_width)\n raise \"#{self.class.name} is expected to define #resize_width, to properly set component sprite attributes\"\n end",
"def resize\n @image.resize \"#{@placement[:a]}x#{OUTER}\\!\"\n end",
"def size(size)\n @value[:size] = size\n self\n end",
"def update start_row, start_col, end_row, end_col\n temp = @board[start_row][start_col]\n @board[start_row][start_col] = \"[ ]\"\n @board[end_row][end_col] = temp\n end",
"def board\n end",
"def set_board\n @canvas = GameCanvas.new\n @board = Board.new(self)\n @canvas.place(@board.block_size * @board.num_rows,\n @board.block_size * @board.num_columns, 10, 10)\n @board.draw\n end",
"def shrink_ship\n @length -= 1\n end",
"def update_board \n\t@the_board = Board.new(array[0].position, array[1].position, array[2].position, array[3].position, array[4].position, array[5].position, array[6].position, array[7].position, array[8].position) \n\t@the_board.display \n end",
"def resize(w, h)\r\n @x2 = @x1 + w\r\n @y2 = @y1 + h\r\n end",
"def resize(width)\n @cli_opts[:geometry] = \"#{width}x\"\n self\n end",
"def drawBoard() \n #1. prepare the default board\n @height.times do |y|\n @width.times do |x|\n print EMPTY_MARKER\n end\n puts\n end\t\n @squares = []\n @width.times do |x|\n column = []\n @height.times do |y|\n column << EMPTY_MARKER\n end\n @squares << column\n end\t\n # 2. fill the mine marker\n @mines.each do |mine|\n x,y = mine\n @squares[x][y] = MINE_MARKER\n end\t\t\n #puts @squares;\n\n end",
"def widthcell\n 10\n end",
"def board\n\n end",
"def k_resize!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 48 )\n\n\n\n type = K_RESIZE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 445:3: 'resize'\n match( \"resize\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 48 )\n\n\n end",
"def resize\n trigger(:_clear_)\n\n trigger(:_refresh_)\n\n true\n end",
"def size(new_size = nil)\n new_size.nil? ? @size : @size = new_size\n end",
"def set_table_size\n @table_x = @table_reversed[0].size\n @table_y = @table_reversed.size\n end",
"def setFigureOnBoard(posx, posy, value)\r\n @board[posx][posy] = value\r\n @sumCol[posx] += value\r\n @sumRow[posy] += value\r\n @sumDiag[0] += value if posx == posy\r\n @sumDiag[1] += value if posx + posy == 2\r\n end",
"def board_size()\n p \"What board size would you want? odd numbers besides 1 are valid choices; 3 is a normal 3 by 3 board and 5 would make a 5 by 5 board.\"\n choice = gets.chomp\n if choice.to_i.odd? == true && choice.to_i > 1 && choice.to_i < 10\n choice.to_i\n else\n \tp \"wrong size choice\"\n board_size()\n end\nend",
"def width\n @width ||= (cells.map(&:to_s) << to_s).map(&:size).max\n end",
"def width(val); @width = val; self; end",
"def update_height\n @height = max_column.size if max_column.size > @height\n end",
"def initialize \n @rows = 8\n @columns = 8\n @grid = create_board\n end",
"def visual_size(value)\n @ole.VisualSize = value\n nil\n end",
"def setSize _obj, _args\n \"_obj setSize _args;\" \n end",
"def set_size\n @size = Size.find(params[:id])\n end",
"def set_size\n @size = Size.find(params[:id])\n end",
"def width\n cols\n end"
] | [
"0.7331184",
"0.714792",
"0.6797675",
"0.67375064",
"0.663364",
"0.6601978",
"0.655269",
"0.65476507",
"0.65396357",
"0.6520203",
"0.6486752",
"0.64289594",
"0.6415148",
"0.639494",
"0.6390217",
"0.63797843",
"0.6369863",
"0.63569635",
"0.6338497",
"0.63159657",
"0.62864286",
"0.62673146",
"0.62587374",
"0.6239641",
"0.6202779",
"0.6197949",
"0.6195211",
"0.61844",
"0.61527526",
"0.6150869",
"0.6146728",
"0.61430734",
"0.61362016",
"0.6132889",
"0.6124055",
"0.6110466",
"0.6109748",
"0.61010844",
"0.6099322",
"0.60951823",
"0.60626984",
"0.605785",
"0.6038483",
"0.6030336",
"0.6016268",
"0.6014706",
"0.59965694",
"0.59894234",
"0.5958683",
"0.59561163",
"0.59505033",
"0.5946661",
"0.59424216",
"0.59307",
"0.5929056",
"0.5915552",
"0.5909792",
"0.5909792",
"0.5900416",
"0.5897024",
"0.589664",
"0.589664",
"0.58947295",
"0.5884175",
"0.58829194",
"0.5867643",
"0.5856608",
"0.5846956",
"0.5833581",
"0.58327764",
"0.5812657",
"0.5806263",
"0.58005345",
"0.5788084",
"0.57875466",
"0.57842034",
"0.5769485",
"0.57674104",
"0.57612896",
"0.57572734",
"0.57551235",
"0.57533884",
"0.57487637",
"0.5739422",
"0.5728833",
"0.5727907",
"0.572689",
"0.5723748",
"0.57131034",
"0.5697962",
"0.5697596",
"0.56971294",
"0.5689184",
"0.56828547",
"0.56828463",
"0.5682706",
"0.56814724",
"0.5680728",
"0.5680728",
"0.56781715"
] | 0.6025228 | 44 |
Method used to create the splash screen | def start_splash
# Clear the console
puts "\e[H\e[2J"
# Create a new splash object
splash = ConsoleSplash.new(13, 40) # 13 lines, 40 columns
# Add header to the splash console
splash.write_header("Welcome to Flood-It", "Georgica Bors", "1.0")
# Add text to the splash console
splash.write_center(-3, "<Press enter to continue>")
# Select the pattern of the border of the splash screen
splash.write_horizontal_pattern("*")
splash.write_vertical_pattern("*")
# Draw the splash screen
splash.splash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def splash_page\n end",
"def makeSplash\n clearScreen\n splash = ConsoleSplash.new(15,70)\n splash.write_header(\"Welcome to Sokoban\",\"Ben Cornforth\",\"Alpha Build, November 2015\",{:nameFg=>:green,:authorFg=>:green, :versionFg=>:green, :bg=>:black})\n splash.write_horizontal_pattern(\"/*\",{:fg=>:white, :bg=>:black})\n splash.write_vertical_pattern(\"/\",{:fg=>:orange, :bg=>:black})\n splash.splash\n if pressKey != ''\n menuScreen\n end\nend",
"def splashScreen(width, height)\n splash = ConsoleSplash.new(height, width);\n splash.write_header(\"Welcome to Flood-It\", \"Jake Sturgeon\", \"1.0\")\n splash.write_center(-3, \"<Press enter to continue>\")\n splash.write_horizontal_pattern(\"*\")\n splash.write_vertical_pattern(\"*\")\n splash.splash\n puts \"\"\nend",
"def splash\n @phone, @prefix = classify_phone\n @items = case @prefix\n when 'webkit' then $WK_ITEMS\n when 'touch' then $TO_ITEMS\n when 'basic' then $BA_ITEMS\n end\n @theme = 'brownell'\n render :template => 'home/splash', :layout => @prefix\n end",
"def splash\n puts <<-'SPLASH'\n\n\n _________ __ __ ______ _________ _______ ______\n /________/\\/_/\\/_/\\ /_____/\\ /________/\\ /______/\\ /_____/\\\n \\__.::.__\\/\\:\\ \\:\\ \\\\::::_\\/_\\__.::.__\\/ \\::::__\\/__\\:::_ \\ \\\n /_\\::\\ \\ \\:\\ \\:\\ \\\\:\\/___/\\ \\::\\ \\ \\:\\ /____/\\\\:\\ \\ \\ \\\n \\:.\\::\\ \\ \\:\\ \\:\\ \\\\_::._\\:\\ \\::\\ \\ \\:\\\\_ _\\/ \\:\\ \\ \\ \\\n \\: \\ \\ \\ \\:\\_\\:\\ \\ /____\\:\\ \\::\\ \\ \\:\\_\\ \\ \\ \\:\\_\\ \\ \\\n \\_____\\/ \\_____\\/ \\_____\\/ \\__\\/ \\_____\\/ \\_____\\/\n\n\n JUST GO: The world's greatest social event planning calendar app.\n\n\n SPLASH\n end",
"def splash_screen(application)\r\n\t# select a random splash image to display\r\n\timages = Dir['./splash/*.{PNG,png}']\r\n\ticon = load_icon(images[rand(images.length())], application)\r\n\r\n\t# the splash screen dialog\r\n\tsplash = FXDialogBox.new(application, nil, FRAME_LINE,\r\n\t\t\t\t\t\t\t:padLeft => 0, :padRight => 0, :padTop => 0, :padBottom => 0)\r\n\t\r\n\t# frame to hold the splash screen components\r\n\tframe = FXVerticalFrame.new(splash, LAYOUT_FILL_X)\r\n\t\r\n\t# the main label that holds the splash image and application title\r\n\tlabel = FXLabel.new(frame, 'CS 1300 Ruby Hangman', icon, \r\n\t\t\t\t\t\t:opts => TEXT_BELOW_ICON | JUSTIFY_LEFT)\r\n\tlabel.font = FONT['Courier 24 bold']\r\n\r\n\t# People tell me I like to talk... so let's add a chatty message\r\n\tmessage = [\r\n\t\t'', \r\n\t\t\"Guess the word in #{MAX_GUESSES} tries, or you\\'ll swing!\",\r\n\t]\r\n\t\r\n\tFXLabel.new(frame, message.join(\"\\n\"), :opts => JUSTIFY_LEFT | TEXT_AFTER_ICON) do |theLabel|\r\n\t\ttheLabel.font = FONT['Helvetica 12']\r\n\tend\r\n\r\n\t# set the splash screen to display for 5 seconds\r\n\tapplication.addTimeout(5000, :repeat => false) do\r\n\t\tsplash.close()\r\n\tend\r\n\t\r\n\t# fire it up\r\n\tsplash.execute(PLACEMENT_SCREEN)\r\nend",
"def nadar; 'Splash splash splash...'; end",
"def goto_splash\r\n fadeout_all\r\n SceneManager.goto(Scene_Splash)\r\n end",
"def init()\n # Splash screen\n splash = ConsoleSplash.new(25,88)\n splash.write_header(\"Flood-It\", \"Huzaifa Ahmed\", \"1.0\")\n splash.write_center(-3, \"<Press enter to continue>\")\n splash.write_horizontal_pattern(\"*\")\n splash.write_vertical_pattern(\"*\")\n splash.splash\n\n # Press enter to continue\n gets\n\n # Load the main menu\n display_menu\nend",
"def main_menu_runner\n\n splash\n\n login_menu_display\n\n end",
"def create\n @splashscreen = Splashscreen.new(splashscreen_params)\n\n respond_to do |format|\n if @splashscreen.save\n format.html { redirect_to splashscreens_url, notice: 'Splashscreen was successfully created.' }\n format.json { render :show, status: :created, location: @splashscreen }\n else\n format.html { render :new }\n format.json { render json: @splashscreen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def splashscreen\n\t\n\tprogressbar_score = 0\n\t\n\t#create WebDialog UI\n\tsplashscreen_width =677 #660\n \tsplashscreen_height = 435 #420\n \t\n\t#get sreen size to set the position of UI\n \t$c = Sketchup.active_model.active_view.center\n\t\n \t$dlgSplashScreen = UI::WebDialog.new(\"-=- GESTURE -=-\", false, \"GESTURE\", splashscreen_width, splashscreen_height, $c[0]-splashscreen_width/2, $c[1]-splashscreen_height/2, true);\n \t$dlgSplashScreen.set_file File.dirname(__FILE__) + \"/GESTURE/Control/splashscreen.html\"\n\t\n\t\n\t$dlgSplashScreen.min_height = 435\n \t$dlgSplashScreen.min_width = 677\n\t$dlgSplashScreen.max_height = 435\n \t$dlgSplashScreen.max_width = 677\n\t\n\t$dlgSplashScreen.set_position $c[0]-splashscreen_width/2, $c[1]-splashscreen_height/2\n\t$dlgSplashScreen.set_size splashscreen_width, splashscreen_height\n\t\n\t$dlgSplashScreen.show\n\t#splashscreen stucks on the top\n\t$dlgSplashScreen.show_modal\n\t\n\t#callback to get the video status\n\t$dlgSplashScreen.add_action_callback(\"SPLASHSCREEN_VID\") do |js_wd, message|\n\t\t#1 video ended\n\t\t#useless\n\t\t#splashscreen_video=message.to_i\n\t\t# just +1 to update\n\t\tprogressbar_score = progressbar_score + 70\n\t\tupdate_progress(progressbar_score)\n\tend\n\n\t# Test Kinect Connection\n\t\n\t# Get Sketchup environment data\n\t$SUversion = Sketchup.version\n\t$model = Sketchup.active_model\n\t$titlemodel = $model.title\n\t$materials = $model.materials\n\t$objects = $model.active_entities\n\t$number_obj = $model.active_entities.length\n\t\n\t$view = $model.active_view\n\t$camera = $view.camera\n\t$eye = $camera.eye\n\t$target = $camera.target\n\t$up = $camera.up\n\t$direction = $camera.direction\t\n\t#log(2,\"###SketchUp Object\")\n\tlog(2,'SU Version: '+$SUversion.to_s)\n\t##lo\n\tprogressbar_score = progressbar_score + 10\n\tupdate_progress(progressbar_score)\n\t\n\t#Ruby resources\n\t$rb=RUBY_VERSION\n\tlog(2,'###RUBY RESOURCES')\n\tlog(2,'Ruby Version :'+$rb.to_s)\n\tif File.exist?($LOAD_PATH[3]) && File.exist?($LOAD_PATH[2]) && $rb==\"1.8.6\"\n\t\t$rbres=true\n\t\tlog(2,\"Load Path updated: All OK\")\n\telse\n\t\t$rbres=false\n\t\tlog(2,\"Load Path updated: NOT OK\")\t\t\n\tend\n\tprogressbar_score = progressbar_score + 10\n\tupdate_progress(progressbar_score)\n\t\n\n\t\n\t# Load C++ module\n\tidCpp=UI.start_timer(0,false){\n\t\t$CppLaunch = UI.openURL(\"C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/GESTURE/Interpretation/GESTURE/x64/Release/GESTURE.exe\")\n\t}\n\tif $CppLaunch \n\t\tlog(2,\"Load GESTURE.exe: OK\")\n\telse\n\t\tlog(2,\"Load GESTURE.exe: NOT OK\")\n\tend\n\tprogressbar_score = progressbar_score + 10\n\tupdate_progress(progressbar_score)\n\t\n\t# Create TCPServer\n\t$hostname = 'localhost'\n\t$port = 2000\n\tputs \"Establishing a connection...\"\n#\t$streamSock = TCPSocket.new($hostname, $port)#TCPSocket.new( \"127.0.0.1\", 20000 ) \n\n\tidsocket=UI.start_timer(2.0,false){\n\t\tputs \"new thread start\"\n\t\t\n\t\t\n\t\t#loop{\n\t\t$streamSock = TCPSocket.new($hostname, $port)\n\t\t$strr = $streamSock.read(120)\n\t\t#strr = $streamSock.recv(120)\n\t\t$order=$strr.split('/')\n\t\tputs $order[0]\n\t\tif $order[0].include? \"hello\"\n\t\t\tUI.stop_timer(idsocket)\n\t\t\t$SocketTest=true\n\t\tend\n\t#TCPSocket.new( \"127.0.0.1\", 20000 ) \n\t\tputs \"Connection established\"\n\t#while ($streamSock == nil)\n#\t\t$streamSock = TCPSocket.new($hostname, $port)#TCPSocket.new( \"127.0.0.1\", 20000 ) \n#\tend\n\t\n\t\t#}\n\t}\n\tif $streamSock != nil\n\t\t$SocketTest=true\n\t\t\n\telse\n\t\t$SocketTest=true\n\tend\n\t\n\t\n\t#test all component\n\t\n \t\t\n \t#if user closes splashscreen???\n \tputs $dlgSplashScreen.visible?\n\n \t# test progressbarscore==100%\n#\tdlgSplashScreen.close\n #\t menu\n \t\nend",
"def intro\n system 'clear'\n intro = PicDisplay.new\n intro.logo\n sleep(4)\n welcome\n end",
"def set_splashscreen\n @splashscreen = Splashscreen.find(params[:id])\n end",
"def start\n super\n create_menu_background()\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n create_command_window()\n @status_window = Window_Party_Status.new(0, 0, 480,424, $game_party.members)\n @menu_info_window = Window_Menu_Info.new(0,424,640,56)\n end",
"def start\n super\n create_menu_background()\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @title_window = Window_Outline_Title.new(0, 0, 640, 56)\n @content_window = Window_Outline.new(0, 56, 640, 424)\n \n # Create Window \n @list_window = Window_Outline_List.new(0, 0, 400, 400, Vocab::tutorials_strings)\n width_remain = (640 - @list_window.width)/2\n @list_window.x = width_remain.floor\n height_remain = (480 - @list_window.height)/2\n @list_window.y = height_remain.floor\n end",
"def splash()\n\t\t@request.add('/')\n\t\t@request.add('/var/widgets.json?callback=define')\n\t\t@request.add('/system/me?_charset_=utf-8')\n\t\t@request.add('/tags/directory.tagged.json?_charset_=utf-8&_=1342651726188')\n\t\t@request.add('/var/search/activity/all.json?items=12&_charset_=utf-8&_=1342651726197')\n\t\t@request.add('/var/search/public/random-content.json?page=0&items=10&tag=&type=c&_charset_=utf-8&_=1342651726201')\n\t\t@request.add('/var/templates/worlds.2.json?_charset_=utf-8')\n end",
"def startLoadingScreen _args\n \"startLoadingScreen _args;\" \n end",
"def display_splash_text\n splash = Artii::Base.new :font => 'slant'\n puts splash.asciify('Country Trivia').blue\n splash\n end",
"def home\n @static_page = StaticPage.preload_for(:content).find_by(role: :home)\n # return unless stale?(@static_page)\n\n set_custom_splash\n set_metadata(@static_page)\n end",
"def home\n @static_page = StaticPage.preload_for(:content).find_by(role: :home)\n # return unless stale?(@static_page)\n\n set_custom_splash\n set_metadata(@static_page)\n end",
"def start_game\n #present the start button and title and image\n @stack = @shoes.stack left: 200 do\n @prompt = @shoes.title( \"Blackjack\",\n stroke: $WHITE,\n align: \"center\")\n @author = @shoes.para( \"By: Thomas Tracy\",\n stroke: $WHITE,\n align: \"center\")\n @toBegin = @shoes.title( \"Click the cards to begin!\",\n stroke: $WHITE,\n align: \"center\")\n @splashImage = @shoes.image(\"View_application/blackjack_splash.png\").move( 350, 250)\n\n #once the start button is clicked, remove the splash and start the game\n @splashImage.click do\n #remove splash\n @stack.clear\n @splashImage.clear\n #create the game view\n newGame = GameView.new(@shoes)\n newGame.create_gameView\n end #end click\n end #end stack\n end",
"def make_screen\n flags = [HWSURFACE, DOUBLEBUF] # FULLSCREEN will be added later\n @screen = Screen.open( [600, 900], 0, flags )\n @screen.title = \"Geotower for great good!\"\n end",
"def create\r\n super # Create the windows\r\n show(PLACEMENT_SCREEN) # Make the main window appear\r\n end",
"def index\n @splashscreens = Splashscreen.all\n end",
"def ios_splash_tag(url, options={})\n rel = 'apple-touch-startup-image'\n\n tag :link, { :rel => rel, :href => url }.merge(options)\n end",
"def start\n super\n create_menu_background\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n \n @item_back_window = Window_Base.new(0, 56, 640, 328)\n @dataviews_window = Window_Dataviews.new(0, 56, 640, 56, MENU_CONFIG::ITEM_DATAVIEWS)\n @dataviews_window.active = false\n @dataviews_window.opacity = 0\n \n @item_window = Window_Item.new(0, 96, 640, 272, $game_party.items, @dataviews_window.selected_view)\n @item_window.opacity = 0\n @item_window.help_window = @help_window\n \n @equip_details_window = Window_EquipDetails.new(0,384,640,96,nil)\n @equip_details_window.visible = false\n @item_details_window = Window_ItemDetails.new(0,384,640,96,nil)\n @item_details_window.visible = false\n update_detail_window(@item_window.selected_item)\n \n @target_window = Window_Party_Status.new(0, 0, 480, 424, $game_party.members)\n hide_target_window\n end",
"def start\n super\n create_menu_background\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n \n @item_back_window = Window_Base.new(0, 56, 640, 328)\n @dataviews_window = Window_Dataviews.new(0, 56, 640, 56, MENU_CONFIG::ITEM_DATAVIEWS)\n @dataviews_window.active = false\n @dataviews_window.opacity = 0\n \n @item_window = Window_Item.new(0, 96, 640, 272, $game_party.items, @dataviews_window.selected_view)\n @item_window.opacity = 0\n @item_window.help_window = @help_window\n \n @equip_details_window = Window_EquipDetails.new(0,384,640,96,nil)\n @equip_details_window.visible = false\n @item_details_window = Window_ItemDetails.new(0,384,640,96,nil)\n @item_details_window.visible = false\n update_detail_window(@item_window.selected_item)\n \n @target_window = Window_Party_Status.new(0, 0, 480, 424, $game_party.members)\n hide_target_window\n end",
"def dispose_splashscreen\r\n @sprite.bitmap.dispose\r\n @sprite.dispose\r\n end",
"def test_splash_page\n false\n end",
"def center_splashscreen(sprite)\r\n sprite.x = Graphics.width / 2\r\n sprite.y = Graphics.height / 2\r\n sprite.ox = sprite.bitmap.width / 2\r\n sprite.oy = sprite.bitmap.height / 2\r\n end",
"def on_background_init()\n background_path = LVGL::Hacks.get_asset_path(\"app-background.svg\")\n if File.exist?(background_path)\n @background = LVGL::LVImage.new(@screen).tap do |el|\n el.set_protect(LVGL::PROTECT::POS)\n el.set_height(LVGUI.pixel_scale(1280))\n el.set_width(LVGUI.pixel_scale(720))\n el.set_src(\"#{background_path}?height=#{LVGUI.pixel_scale(1280)}\")\n el.set_x((@screen.get_width() - el.get_width()) / 2) # center\n el.set_y(@screen.get_height() - el.get_height()) # Stick to the bottom\n end\n end\n end",
"def splash_image_url\n self.splash_image ? self.splash_image.convert('-resize 50%').url : '/assets/campaigns/splash_default.jpg'\n end",
"def make_screen\n @screen = Screen.new(Configuration.screen[:size], 32, [HWSURFACE, DOUBLEBUF])\n\n @screen.title = \"Towerdefence!\"\n end",
"def start\n super\n create_menu_background\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n @help_window = Window_Help.new\n @help_window.width = 640\n @saves_list = []\n (0..MAX_SAVE_SLOT-1).each do |i|\n @saves_list << SaveData.new(SLOT_NAME.clone.gsub!(/\\{ID\\}/i) { (i+1).to_s }, \n make_filename(i))\n end\n @window_slotdetail = Window_Slot_Details.new(160, 56, 480, 424, nil)\n @window_slotlist = Window_Slot_List.new(0, 56, 160, 424, @saves_list)\n if OPACITY_DEFAULT == false\n @help_window.opacity = NSS_WINDOW_OPACITY\n @window_slotlist.opacity = NSS_WINDOW_OPACITY\n @window_slotdetail.opacity = NSS_WINDOW_OPACITY\n end\n \n @confirm_window = Window_Confirmation.new(220, 212, SFC_Window_Width, \n Vocab::confirm_save_text,\n Vocab::confirm_yes_text,\n Vocab::confirm_no_text)\n @confirm_window.active = false\n @confirm_window.visible = false\n \n # Create Folder for Save file\n if SAVE_PATH != ''\n Dir.mkdir(SAVE_PATH) if !FileTest.directory?(SAVE_PATH)\n end\n if @saving\n @index = $game_temp.last_file_index\n @help_window.set_text(Vocab::SaveMessage)\n else\n @index = latest_file_index()\n @help_window.set_text(Vocab::LoadMessage)\n end\n @window_slotlist.index = @index\n # Draw Information\n @last_slot_index = @window_slotlist.index\n @window_slotdetail.window_update(@saves_list[@last_slot_index])\n end",
"def add_cover()\n @cover = LVGL::LVObject.new(@screen)\n # Make it so we can use the opacity to fade in/out\n @cover.set_opa_scale_enable(true)\n @cover.set_width(@screen.get_width())\n @cover.set_height(@screen.get_height())\n @cover.set_click(false)\n\n @cover.get_style().dup.tap do |style|\n @cover.set_style(style)\n\n # Background for the splash\n style.body_main_color = BG_COLOR\n style.body_grad_color = BG_COLOR\n # Some themes will add a border to LVObject.\n style.body_border_width = 0\n end\n end",
"def show_splash_screen?\n (browser.platform.android? || browser.platform.ios?) && cookies['splash-screen'] != 'hidden'\n end",
"def splash\n\n#\t\tif (signed_in? && !params.has_key?(:logout)) # signed in user is not logging out\n\t\tif (signed_in?) # signed in user\n\t\t\tredirect_to home_path\n\t\telse\n#\t\t\tif (signed_in? && params.has_key?(:logout) && params[:logout] = true) # signed in user is logging out\n#\t\t\t\tsign_out\n#\t\t\tend\t\n\n\t\t\t@user = User.new # in case new user signs up\n\t\t\t\n\t\t\t# returns a Activerecord relation vs. a model instance - http://stackoverflow.com/questions/6004891/undefined-method-for-activerecordrelation\t\n\t\t\t@videos = Video.get_videos.where(\"live = ?\", false).where(\"status = ?\", \"finished\")\n#\t\t\t@venues = @venues.order(\"RANDOM()\")\n#\t\t\t@venues = @venues.limit(5) \t\t\n\t\t\t\t\n\t\t\t# Use Amazon AWS SDK methods (.new and .url_for) to get a url to the S3 object (the thumbnail)\n\t\t\ts3 = AWS::S3.new(:access_key_id => ENV['AWS_KEY_ID_READ'], :secret_access_key => ENV['AWS_KEY_VALUE_READ'])\n\t\t\t@bucket = s3.buckets[ENV['AWS_BUCKET']]\n\t\t\t# Code concepts below should be used in views/index.html.erb\n\t\t#\tobject = @bucket.objects['uploads/video/attachment/191/uploadify_test.png']\n\t\t#\t@url = oject.url_for(:get, { :expires => 1200.minutes.from_now, :secure => true }).to_s\n\n#\t\t\t@user = User.new\n\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html\n\t\t\t\tformat.js { render :template => 'sessions/destroy.js.erb'}\n#\t\t\t\tformat.js { render js: \"alert('Hello Rails');\"}\n\t\t\tend\n\n\t\tend\t\t\n\tend",
"def start!\n @window = Window.new width, height, fullscreen?\n window.caption = name\n window.scene = Scenes.generate(first_scene)\n window.show\n end",
"def start\n super\n create_menu_background\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, YE::SYSTEM::WINDOW_HELP)\n @system_window = Window_System.new(0, 0, 640, 384)\n \n positions = []\n positions.push(CursorPosition.new(Rect.new(0, @system_window.cWindowSkinsLabel.rect.y-12, \n @system_window.width-32, 48)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.ucBGMVolume.cVolumeLabel.rect.y-12, \n @system_window.width-32, 48)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.ucSFXVolume.cVolumeLabel.rect.y-12, \n @system_window.width-32, 48)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.ucBGSVolume.cVolumeLabel.rect.y-12, \n @system_window.width-32, 48)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.cBattleAnimLabel.rect.y, \n @system_window.width-32, 24)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.cAutoDashLabel.rect.y, \n @system_window.width-32, 24)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.cInstantTextLabel.rect.y, \n @system_window.width-32, 24)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.cDifficultyLabel.rect.y, \n @system_window.width-32, 24)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.cInGameTutoLabel.rect.y, \n @system_window.width-32, 24)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.cReturnTitleLabel.rect.y, \n @system_window.width-32, 24)))\n \n @command_window = Window_Custom_Selectable.new(0, 0, 640, 384, positions, true)\n @command_window.opacity = 0\n @command_window.visible = true\n @command_window.active = true\n @command_window.z = 1000\n if @menu_index != nil\n @command_window.index = @menu_index\n update_help()\n else\n @command_window.index = 0\n end\n\n @last_index = -1\n end",
"def initialize\n\n @prompt = TTY::Prompt.new\n escape_to_welcome\n LoadAssets.load_logo\n\n end",
"def splash_settings\r\n SplashSettingsController.instance\r\n end",
"def start\n super\n create_menu_background()\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @actor = $game_party.members[@actor_index]\n \n @char_image_window = Window_Char_Image.new(-16, 56+16, 640, 424, @actor)\n @char_image_window.opacity = 0\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n \n @skill_back_window = Window_Base.new(200, 56, 440, 328)\n @dataviews_window = Window_Dataviews.new(200, 56, 440, 56, MENU_CONFIG::SKILL_DATAVIEWS)\n @dataviews_window.active = false\n @dataviews_window.opacity = 0\n \n @status_window = Window_Skill_Status.new(0, 0, 200, 128, @actor)\n \n @skill_window = Window_Skill.new(200, 96, 440, 272, @actor, @dataviews_window.selected_view)\n @skill_window.opacity = 0\n @skill_window.help_window = @help_window\n \n @skill_details_window = Window_SkillDetails.new(0,384,640,96,nil)\n @skill_details_window.visible = false\n @skill_window.detail_window = @skill_details_window\n \n @target_window = Window_Party_Status.new(140, 0, 480, 424, $game_party.members)\n hide_target_window\n end",
"def start\n super\n create_menu_background()\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @actor = $game_party.members[@actor_index]\n \n @char_image_window = Window_Char_Image.new(-16, 56+16, 640, 424, @actor)\n @char_image_window.opacity = 0\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n \n @skill_back_window = Window_Base.new(200, 56, 440, 328)\n @dataviews_window = Window_Dataviews.new(200, 56, 440, 56, MENU_CONFIG::SKILL_DATAVIEWS)\n @dataviews_window.active = false\n @dataviews_window.opacity = 0\n \n @status_window = Window_Skill_Status.new(0, 0, 200, 128, @actor)\n \n @skill_window = Window_Skill.new(200, 96, 440, 272, @actor, @dataviews_window.selected_view)\n @skill_window.opacity = 0\n @skill_window.help_window = @help_window\n \n @skill_details_window = Window_SkillDetails.new(0,384,640,96,nil)\n @skill_details_window.visible = false\n @skill_window.detail_window = @skill_details_window\n \n @target_window = Window_Party_Status.new(140, 0, 480, 424, $game_party.members)\n hide_target_window\n end",
"def after_sign_in_path_for(resource)\n splash_page\n end",
"def setup_screen_fadein\n $game_troop.screen.start_fadein(@acts[1] || 30)\n end",
"def run_normal\n welcome_header\n main_menu \n end",
"def splashScreenFriendfunction(splahsScreenObject)\n @splashScreenFriendObject = splahsScreenObject\n end",
"def cfs_kit_create_about_screen(scr_title, scr_text)\n\n t = Time.new \n time_stamp = \"_#{t.year}_#{t.month}_#{t.day}_#{t.hour}#{t.min}#{t.sec}\"\n\n scr_header = \"\n ###############################################################################\n # cfs_kit About Screen\n #\n # Notes:\n # 1. Do not edit this file because it is automatically generated and your\n # changes will not be saved.\n # 2. File created by create_app_screen.rb on #{time_stamp}\n #\n # License:\n # Written by David McComas, licensed under the copyleft GNU General Public\n # License (GPL).\n #\n ###############################################################################\n\n SCREEN AUTO AUTO 0.5\n GLOBAL_SETTING BUTTON BACKCOLOR 221 221 221\n \n TITLE \\\"#{scr_title}\\\"\n SETTING BACKCOLOR 162 181 205\n SETTING TEXTCOLOR black\n \n VERTICALBOX \\\"\\\" 10\n \"\n\n scr_trailer = \"\n END # Vertical Box\n \"\n \n scr_file = File.join(Osk::SCR_DIR,Osk::ABOUT_SCR_FILE)\n\n begin\n \n # Always overwrite the temp file \n File.open(scr_file,\"w\") do |f| \n \n f.write (scr_header)\n\n #f.write (\"\\n LABEL \\\" \\\"\\n\")\n \n info_line = 1\n info_line_str = \"\"\n scr_text.each do |line|\n info_line_str << \" NAMED_WIDGET line_#{info_line} LABEL \\\"#{line}\\\"\\n\" \n info_line_str << \" SETTING TEXTCOLOR 0 0 153\\n\"\n info_line += 1\n end\n \n f.write (info_line_str)\n f.write (\"\\n LABEL \\\" \\\"\\n\")\n f.write (scr_trailer)\n\n end # File\n \n rescue Exception => e\n puts e.message\n puts e.backtrace.inspect \n end\n\nend",
"def initialize window, x, y\n images = Gosu::Image::load_tiles(window, \"media/SlugSlime.png\", WIDTH, HEIGHT, true)\n\n super(window, x, y, WIDTH, HEIGHT, images)\n\n @creation_milliseconds = Gosu.milliseconds\n end",
"def init_window\n self.z = 10_000\n lock\n @name_window.visible = false\n @name_window.lock\n @name_text.text = ''\n update_windowskin\n init_pause_coordinates\n self.pauseskin = RPG::Cache.windowskin(PauseSkin)\n self.back_opacity = ($game_system.message_frame == 0 ? 255 : 0)\n unlock\n @name_window.unlock\n end",
"def create_wait_for_play_screen\r\n @log.error \"create_wait_for_play_screen: not implemented\\n\"\r\n end",
"def welcome\n system 'rake db:seed'\n system 'clear'\n Logo.start\n puts \"Hello, and welcome to Crockpot Recipe Finder!\"\n puts \" \"\n sleep(2)\n login_page\n end",
"def Main\n #Begin preinitialization\n preInit()\n\n #Render Game Window and begin drawing onto the screen.\n\n DEBUG.cout(\"Initializing Game Window...\", 0, false)\n window = GameWindow.new\n window.show\n\n #End game and return to desktop\n return nil\nend",
"def initialize\n\n #Graphics.freeze\n\n @closing = false\n @savequit = false\n\n $mouse.change_cursor('Default')\n sys('open')\n\n # Vp\n @vp = Viewport.new(0,0,$game.width,$game.height)\n @vp.z = 3500\n\n @snap = Sprite.new(@vp)\n @snap.z = -101\n @snap.bitmap = $game.snapshot\n\n # Background\n @bg = Sprite.new(@vp)\n @bg.z = -100\n #@bg.bitmap = Bitmap.new(640,480)\n #@bg.bitmap.fill(Color.new(0,0,0,180))\n @bg.bitmap = $cache.menu_background(\"sample\")\n #@bg.bitmap = $cache.menu_background(\"witch\")\n @bg.opacity = 0\n \n #@bg.y = 30\n #@bg.do(seq(go(\"y\",-50,150,:qio),go(\"y\",20,150,:qio)))\n\n #self.do(delay(300))\n\n @next_menu = $menu.menu_page\n $menu.menu_page = nil\n\n @menu = nil\n\n #Graphics.transition(20,'Graphics/Transitions/trans') \n\n end",
"def main_begin\n create_graphics\n sort_sprites\n fade_in(@mbf_type || DEFAULT_TRANSITION, @mbf_param || DEFAULT_TRANSITION_PARAMETER)\n end",
"def start_scene; end",
"def initialize(battler)\n x,y = Scan_Window_Settings[0], Scan_Window_Settings[1]\n w,h = Scan_Window_Settings[2], Scan_Window_Settings[3]\n super(x,y,w,h)\n self.contents = Bitmap.new(width - 32, height - 32)\n self.z = 4950\n if Scan_Window_Bg != nil\n @background_image = Sprite.new\n @background_image.bitmap = RPG::Cache.windowskin(Scan_Window_Bg)\n @background_image.x = self.x + Scan_Window_Bg_Postion[0]\n @background_image.y = self.y + Scan_Window_Bg_Postion[1]\n @background_image.z = self.z - 1\n @background_image.visible = self.visible\n end\n self.back_opacity = Scan_Window_Settings[4]\n self.opacity = Scan_Window_Settings[4] if Scan_Window_Settings[5]\n @battler = battler\n refresh\n end",
"def initialize \n super(ScreenWidth, ScreenHeight, false)\n self.caption = \"Mad Pokemon\"\n $window = self\n\n @@images = Hash.new\n @@fonts = Hash.new \n load_images\n load_fonts\n\n @@fading_off = false\n @@fading_on = false\n @@end_fade = 0\n @@start_fade = 0\n\n @@change_game_state = nil\n\n @@game_state = MenuState.new\n end",
"def quit\n ::HawkLoginController.load_into @stage, :width => 517,\n :height => 374\n\n @stage.min_width = 500\n @stage.min_height = 300\n\n @stage.size_to_scene\n end",
"def initialize\n super(WIDTH, HEIGHT)\n self.caption = 'Sector Five'\n @background_image = Gosu::Image.new('images/start_screen.png')\n @scene = :start\n\n @game = GameService.new(self)\n end",
"def start\n super\n if VICTORY_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(VICTORY_CONFIG::IMAGE_BG)\n @bg.opacity = VICTORY_CONFIG::IMAGE_BG_OPACITY\n end\n \n @help_window = Window_Info_Help.new(0, 0, 640, 56, Vocab::victory_help_text)\n @help_window.cText.align = 1\n @help_window.cText.font.bold = true\n # Refresh for the text alignment\n @help_window.refresh()\n\n if VICTORY_CONFIG::DIVIDE_EXP\n exp_by_actor = (@exp / $game_party.members.size).to_i\n else\n exp_by_actor = @exp\n end\n \n @actor_remaining_exp = []\n @victory_char_info_windows = []\n @victory_new_skill_windows = []\n @victory_level_up_windows = []\n for i in 0 .. $game_party.members.size-1 \n actor_exp = ActorExp.new(exp_by_actor, determine_tick($game_party.members[i].next_exp, exp_by_actor))\n @actor_remaining_exp.push(actor_exp)\n \n if i%2 == 0 \n x = -320\n else\n x = 640\n end\n victory_char_info_window = Window_Victory_Char_Info.new(x, (i/2).to_i*128+168, 320, 128, $game_party.members[i])\n victory_char_info_window.active = false\n @victory_char_info_windows.push(victory_char_info_window)\n\n victory_new_skill_window = Window_Victory_New_Skill.new((i%2)*320, (i/2).to_i*128+168+128-56, 320, 56, nil)\n victory_new_skill_window.active = false\n victory_new_skill_window.visible = false\n @victory_new_skill_windows.push(victory_new_skill_window)\n\n victory_level_up_window = Window_Victory_Level_Up.new((i%2)*320+200, (i/2).to_i*128+168, 120, 56)\n victory_level_up_window.active = false\n victory_level_up_window.visible = false\n victory_level_up_window.opacity = 0\n @victory_level_up_windows.push(victory_level_up_window)\n end\n\n @victory_item_window = Window_Victory_Item.new(160, 488, 320, 256, @drop_items)\n @victory_item_window.active = false\n @victory_item_window.visible = false\n\n @exp_window = Window_Victory_Exp.new(20, 83, 300, 56, @exp)\n @gold_window = Window_Victory_Gold.new(320, 83, 300, 56, @gold)\n\n [@help_window, @victory_item_window, @exp_window, @gold_window]+\n @victory_char_info_windows+@victory_new_skill_windows.each{\n |w| w.opacity = VICTORY_CONFIG::WINDOW_OPACITY;\n w.back_opacity = VICTORY_CONFIG::WINDOW_BACK_OPACITY\n }\n \n end",
"def start\n super\n create_menu_background()\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @actor = $game_party.members[@actor_index]\n @char_image_window = Window_Char_Image.new(-16, 56+16, 640, 424, @actor)\n @char_image_window.opacity = 0\n @char_info_window = Window_Char_Info.new(0, 0, 200, 128, @actor)\n \n @status_window = Window_Status.new(200, 40, 440, 440, @actor)\n \n @status_equip_window = Window_Status_Equip.new(415, 40, 225, 272, @actor)\n @status_equip_window.active = false\n \n @equip_details_window = Window_EquipDetails.new(0,384,640,96,nil)\n @equip_details_window.visible = false\n @item_details_window = Window_ItemDetails.new(0,384,640,96,nil)\n @item_details_window.visible = false\n \n positions = []\n positions.push(CursorPosition.new(Rect.new(@status_equip_window.x,\n @status_equip_window.y, \n @status_equip_window.width-32, \n @status_equip_window.height-32)))\n \n @command_window = Window_Custom_Selectable.new(0, 0, 640, 480, positions)\n @command_window.opacity = 0\n @command_window.visible = true\n @command_window.active = true\n @command_window.index = 0\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n @help_window.visible = false\n \n @status_equip_window.help_window = @help_window\n end",
"def create\r\n @icons_app.each do |k,v|\r\n v.create\r\n end\r\n # local variables\r\n \r\n refresh_settings\r\n \r\n #splitter position\r\n gfxgui_settings = @app_settings['guigfx']\r\n \r\n # window size\r\n ww = gfxgui_settings[:ww_mainwin]\r\n hh = gfxgui_settings[:hh_mainwin]\r\n \r\n # continue to insert item into giochi menu\r\n FXMenuSeparator.new(@giochimenu)\r\n FXMenuCommand.new(@giochimenu, \"Opzioni\").connect(SEL_COMMAND, method(:mnu_cuperativa_options))\r\n FXMenuSeparator.new(@giochimenu)\r\n FXMenuCommand.new(@giochimenu, \"&Esci\").connect(SEL_COMMAND, method(:onCmdQuit))\r\n \r\n # Reposition window to specified x, y, w and h\r\n position(0, 0, ww, hh)\r\n \r\n # Create the main window and canvas\r\n super \r\n # Show the main window\r\n show(PLACEMENT_SCREEN)\r\n \r\n # default game or last selected\r\n game_type = @app_settings[\"curr_game\"]\r\n #p @supported_game_map\r\n # initialize only an enabled game. An enabled game is a supported game.\r\n # Game disabled are not in the @supported_game_map. This to avoid to build poperties and\r\n # custom widgets\r\n if @supported_game_map[game_type]\r\n if @supported_game_map[game_type][:enabled]\r\n initialize_current_gfx(game_type)\r\n end\r\n else\r\n # default game is not supported, initialize the first enable game\r\n @log.debug(\"Default game not enabled, look for the first enabled one\")\r\n @supported_game_map.each do |k, game_info_h|\r\n game_type = k\r\n if game_info_h[:enabled]\r\n initialize_current_gfx(game_type)\r\n break\r\n end\r\n end\r\n end\r\n log_sometext(\"Benvenuta/o nella Cuperativa versione #{VER_PRG_STR}\\n\")\r\n @log.info(\"TheApp Create OK\") \r\n end",
"def main_window\r\n super\r\n # Make main command window\r\n main_command_window\r\n # Make play time window\r\n @playtime_window = Window_PlayTime.new\r\n @playtime_window.x = 0\r\n @playtime_window.y = 224\r\n # Make steps window\r\n @steps_window = Window_Steps.new\r\n @steps_window.x = 0\r\n @steps_window.y = 320\r\n # Make gold window\r\n @gold_window = Window_Gold.new\r\n @gold_window.x = 0\r\n @gold_window.y = 416\r\n # Make status window\r\n @status_window = Window_MenuStatus.new\r\n @status_window.x = 160\r\n @status_window.y = 0\r\n end",
"def loadView\n self.view = MainView.alloc.initWithFrame(UIScreen.mainScreen.bounds)\n end",
"def create_background\n @background = Window.new(@viewport, @x, @y, @width, @height, skin: @skin)\n end",
"def setup_screen_fadeout\n $game_troop.screen.start_fadeout(@acts[1] || 30)\n end",
"def create_menu_background\n @menuback_sprite = Sprite.new\n @menuback_sprite.bitmap = $game_temp.background_bitmap\n @menuback_sprite.color.set(16, 16, 16, 128)\n update_menu_background\n end",
"def main_end\r\n super\r\n # If switching to title screen\r\n if $scene.is_a?(Scene_Title)\r\n # Fade out screen\r\n Graphics.transition\r\n Graphics.freeze\r\n end\r\n end",
"def create_loading_bar\n @loading_bar = Loading_Bar.new(@x, @y, 60, @viewport)\n end",
"def create_background\n add_disposable @background = UI::BlurScreenshot.new(@__last_scene)\n @background.opacity -= 255 / ENTERING_ANIMATION_DURATION * ENTERING_ANIMATION_DURATION\n end",
"def set_login_background!\n `defaults write /Library/Preferences/com.apple.loginwindow DesktopPicture \"#{File.expand_path(@desktop_image)}\"`\n end",
"def main_window ; end",
"def start\n super\n create_menu_background\n if PARTY_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(PARTY_CONFIG::IMAGE_BG)\n @bg.opacity = PARTY_CONFIG::IMAGE_BG_OPACITY\n end\n \n @actor_positions_backup = {}\n for i in 0 .. $game_party.members.size-1\n @actor_positions_backup[$game_party.members[i].id] = $game_party.actor_positions[i]\n end\n @party_order_window = Window_Party_Order.new(160, 0, 480, 156, $game_party.members)\n @party_order_window.active = false\n @party_order_window.index = -1\n\n @command_window = Window_Command.new(160, \n [Vocab::formation_change_command, \n Vocab::formation_order_command, \n Vocab::formation_revert_command])\n @command_window.x = 0\n @command_window.y = 0\n @command_window.height = @party_order_window.height\n @command_window.active = true\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n @battle_formation_details_window = Window_BattleFormationDetails.new(0,384,640,96,nil)\n @battle_formation_details_window.visible = false\n\n @battle_formation_index_backup = $game_party.battle_formation_index\n @battle_formations_window = Window_Battle_Formations.new(0, 156, 640, 228, PARTY_CONFIG::BATTLE_FORMATIONS)\n @battle_formations_window.active = false\n @battle_formations_window.index = $game_party.battle_formation_index\n @battle_formations_window.help_window = @help_window\n @battle_formations_window.detail_window = @battle_formation_details_window\n \n [@help_window, @battle_formation_details_window, @party_order_window,\n @command_window, @battle_formations_window].each{\n |w| w.opacity = PARTY_CONFIG::WINDOW_OPACITY;\n w.back_opacity = PARTY_CONFIG::WINDOW_BACK_OPACITY\n }\n end",
"def main_sprite\r\n super\r\n # Make title graphic\r\n @sprite = Sprite.new\r\n @sprite.bitmap = RPG::Cache.title($data_system.title_name)\r\n end",
"def home()\n@ss.close\n @titleLabel.setVisible(true)\n @actionNew.setVisible(true)\nsetWindowTitle('Internet Cafe Customer Management System (I.C.C.M.S.) by SAFEW')\nend",
"def create_screenshot_graphic\n @screenshot_loaded = false\n @screenshot = Sprite.new(@viewport)\n @screenshot.opacity = 0\n end",
"def victory_screen\n system 'clear'\n 'GAME OVER'\n Catpix::print_image \"victory_screen.jpg\",\n :limit_x => 1.0,\n :limit_y => 0,\n :center_x => true,\n :center_y => true,\n :bg => \"white\",\n :bg_fill => true\n abort(\"See you next time.\".red)\nend",
"def start\n super\n create_menu_background()\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @actor = $game_party.members[@actor_index]\n \n @char_image_window = Window_Char_Image.new(-16, 56+16, 640, 424, @actor)\n @char_image_window.opacity = 0\n @char_info_window = Window_Char_Info.new(0, 0, 200, 128, @actor)\n @char_info_window.ucExp.visible = false\n @char_info_window.ucExpGauge.visible = false\n @char_info_window.ucTotalExp.visible = false\n @char_info_window.refresh()\n\n @item_window = Window_Equip_Item.new(425, 40, 215, 272 + 72, @actor, @equip_index)\n @item_window.active = false\n @item_window.index = -1\n @item_window.window_update($game_party.items)\n \n @equip_window = Window_Status_Equip.new(200, 40, 225, 272, @actor)\n @equip_window.active = false\n @equip_window.height = @equip_window.height + 72\n @equip_window.index = @equip_index\n\n @status_window = Window_Equip_Compare_Status.new(200, 40, 225, 344, @actor)\n @status_window.active = false \n @status_window.visible = false\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n @equip_window.help_window = @help_window\n @item_window.help_window = @help_window\n \n @equip_details_window = Window_EquipDetails.new(0,384,640,96,nil)\n @equip_details_window.visible = false\n @equip_window.detail_window = @equip_details_window\n @item_window.detail_window = @equip_details_window\n \n @command_window = Window_Command.new(200, \n [Vocab::equip_command, \n Vocab::equip_optimize_command, \n Vocab::equip_remove_command,\n Vocab::equip_remove_all_command], 2)\n @command_window.opacity = 0\n @command_window.x = 0\n @command_window.y = 48\n @command_window.active = true\n \n @optimize_modes_window = Window_Optimize_Modes.new(0, 0, 400, 64, MENU_CONFIG::OPTIMIZE_MODES)\n @optimize_modes_window.visible = false\n @optimize_modes_window.active = false\n @optimize_modes_window.help_window = @help_window\n \n @optimize_modes_window_headers = Window_Selectable_Headers.new(@optimize_modes_window)\n width_remain = (640 - @optimize_modes_window_headers.width)/2\n @optimize_modes_window_headers.x = width_remain.floor\n height_remain = (480 - @optimize_modes_window_headers.height)/2\n @optimize_modes_window_headers.y = height_remain.floor\n @optimize_modes_window_headers.visible = false\n @optimize_modes_window_headers.addHeader(Vocab::optimize_mode_text, \n 0, @optimize_modes_window.contents.width, \n 1, Font.optimize_mode_header_font)\n @optimize_modes_window_headers.refresh()\n end",
"def start_load_screenshot\n show_loading_bar\n Thread.new{extract_graphic}\n end",
"def create_mission_window\n @mission_window = Window_Mission.new(0, 0)\n @mission_window.y = Graphics.height - @mission_window.height\n end",
"def main\n create_graphics\n curr_scene = $scene\n check_up\n while @running && curr_scene == $scene\n Graphics.update\n update\n end\n dispose\n # Unload title related pictures\n RPG::Cache.load_title(true)\n RPG::Cache.load_interface(true)\n ::Scheduler.start(:on_scene_switch, ::Scene_Title) if !@running && $scene.is_a?(Scene_Map)\n end",
"def welcome\n clear\n ascii_heading(\"The Bakers Box\")\n box_margin = ((TTY::Screen.width)-(\"Welcome to The Bakers Box\".length)-6)/2\n box = TTY::Box.frame padding: 3, align: :center, left: box_margin, top: 6 do\n \"Welcome to The Bakers Box\\n\\nThe percentage based\\nRecipe management app\"\n end\n print box\n space\nend",
"def welcome\n system \"clear\"\n aa = Artii::Base.new :font => 'univers'\n bb = Artii::Base.new :font => 'doh'\n cc = Artii::Base.new :font => 'larry3d'\n dd = Artii::Base.new :font => 'banner3'\n puts bb.asciify('Welcome to')\n sleep(2)\n system \"clear\"\n puts aa.asciify(\"Who Wants To Be A\")\n sleep(1)\n puts bb.asciify(\" Millionbear\")\n puts cc.asciify(\" $$$$$$$$$$$$$$$$$$$$$$$\")\n sleep(2)\n system \"clear\"\n puts aa.asciify \" With your host\"\n sleep(1)\n system \"clear\"\n puts bb.asciify \" Alex\"\n puts bb.asciify \" Trebear\"\n sleep(2)\n system \"clear\"\n # bear_host\n\n if !$IS_LITE_MODE\n Catpix::print_image \"lib/cli/img/bear5.png\",\n :center_x => true,\n :resolution => \"low\",\n :bg_fill => false\n puts\n end\nend",
"def show\n @showing = true\n if @fullscreen\n #Use full java path for Window, since there is a Gosu::Window\n @activity.request_window_feature(JavaImports::Window::FEATURE_NO_TITLE)\n @activity.get_window.set_flags(JavaImports::WindowManager::LayoutParams::FLAG_FULLSCREEN,\n JavaImports::WindowManager::LayoutParams::FLAG_FULLSCREEN)\n #@activity.content_view = @surface_view\n @window = @activity.getWindow\n #Replace position and size with gosu metrics\n else\n @window = @activity.getWindow\n #Only the thread that created the view can change it, so setLayout\n #and setTitle cannot be executed here\n p = Proc.new do\n @window.setLayout(@width, @height)\n @activity.setTitle @caption\n end\n @activity.runOnUiThread(p)\n end\n @screen_width = @surface_view.get_width\n @screen_height = @surface_view.get_height\n end",
"def createTitlebar\n height = NSHeight(self.window.frame) - NSHeight(self.window.contentView.frame)\n @spinner = NSProgressIndicator.alloc\n .initWithFrame([[0, 2], [height - 4, height - 4]])\n .tap do |obj|\n obj.usesThreadedAnimation = true\n obj.indeterminate = true\n obj.style = NSProgressIndicatorSpinningStyle\n obj.displayedWhenStopped = false\n end\n titlebarView = NSView.alloc.initWithFrame([[0, 0], [40, height]])\n titlebarView.addSubview(@spinner)\n NSTitlebarAccessoryViewController.alloc.init.tap do |obj|\n obj.view = titlebarView\n obj.layoutAttribute = NSLayoutAttributeRight\n end\n end",
"def logo; end",
"def logo; end",
"def intro\r\n clear # execute method clear to clear screen and place logo\r\n puts ' \"I cant stand the rain!!\" '\r\n puts ' Welcome to GK Rainfall collection application'\r\n puts ' Version 0.205'\r\n puts ' Hit enter to continue'\r\n gets\r\n end",
"def create\n # configs\n @splash_host = '68.42.117.7:8050'\n\n @link = Link.new(link_params)\n\n # print params\n puts link_params\n \n # hit Splash and get HTML\n url_string = \"http://#{@splash_host}/render.html?url=#{link_params['URL']}&wait=1\"\n rendered_html = open(url_string).read\n @link.html = rendered_html\n\n # load into Nokogiri and extract title\n parsed_html = Nokogiri::HTML(rendered_html)\n title = parsed_html.css('title').text\n if title == \"\"\n @link.title = \"Unknown Title\"\n else\n @link.title = title\n end\n \n # hit Splash and get thumbnail\n url_string = \"http://#{@splash_host}/render.png?url=#{link_params['URL']}&wait=1&width=320&height=240\"\n @link.picture_from_url(url_string)\n\n\n respond_to do |format|\n if @link.save\n format.html { redirect_to @link, notice: 'Link was successfully created.' }\n format.json { render :show, status: :created, location: @link }\n else\n format.html { render :new }\n format.json { render json: @link.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tick_initialize\n initialize_tiles\n loading_label = {\n x: 640,\n y: 400,\n text: \"Reticulating Splines...\",\n size_enum: 0,\n alignment_enum: 1,\n r: 255,\n g: 255,\n b: 255,\n a: 255\n }\n @args.outputs.background_color = [0, 0, 0]\n @args.outputs.labels << loading_label\n @args.outputs.solids << { x: 320, y: 300, w: 640 * initialization_percent, h: 50, r: 0, g: 255, b: 0, a: 255 }\n @args.outputs.borders << { x: 320, y: 300, w: 640, h: 50, r: 255, g: 255, b: 255, a: 255 }\n end",
"def main_end\r\n # If switching to title screen\r\n if $scene.is_a?(Scene_Title)\r\n # Fade out screen\r\n Graphics.transition\r\n Graphics.freeze\r\n end\r\n end",
"def logo=(_arg0); end",
"def initialize(parent_wnd)\r\n super(parent_wnd)\r\n \r\n @core_game = nil\r\n @splash_name = File.join(@resource_path, \"icons/mariazza_title_trasp.png\")\r\n @algorithm_name = \"AlgCpuMariazza\" \r\n #core game name (created on base class)\r\n @core_name_class = 'CoreGameMariazza'\r\n \r\n # game commands\r\n @game_cmd_bt_list = []\r\n\r\n ## NOTE: don't forget to initialize variables also in ntfy_base_gui_start_new_game\r\n end",
"def progressLoadingScreen _args\n \"progressLoadingScreen _args;\" \n end",
"def display_intro\n # Display Company Logo\n display_logo\n # Display Emergency Information\n display_emergency_info\n end",
"def create_backgrounds\n create_over\n create_hud_bg\n create_under\n create_flow\n end",
"def create_graphics\n create_viewport\n create_background\n create_buttons\n init_entering\n end",
"def welcome_screen\n puts \"Bienvenue dans la secret place !\"\nend"
] | [
"0.7778994",
"0.7694187",
"0.7559071",
"0.7246392",
"0.7219365",
"0.70114976",
"0.6934593",
"0.67861134",
"0.65907055",
"0.6573216",
"0.6390458",
"0.6226434",
"0.6164103",
"0.6083253",
"0.60094047",
"0.6004784",
"0.5908802",
"0.59075403",
"0.5855139",
"0.58454245",
"0.58454245",
"0.57485396",
"0.5747787",
"0.5747583",
"0.57473445",
"0.5710116",
"0.5706396",
"0.5706396",
"0.57040226",
"0.5703037",
"0.5700297",
"0.5684657",
"0.5671695",
"0.5639281",
"0.5627977",
"0.56278986",
"0.56121343",
"0.5604391",
"0.5593117",
"0.55801",
"0.5534033",
"0.55131924",
"0.5509855",
"0.5509855",
"0.54531646",
"0.5435162",
"0.54304576",
"0.5398075",
"0.53900874",
"0.53527623",
"0.53096765",
"0.5305986",
"0.52986115",
"0.528966",
"0.52825797",
"0.52622926",
"0.5246219",
"0.5212043",
"0.51951504",
"0.51881266",
"0.5179919",
"0.51774675",
"0.51584095",
"0.51445246",
"0.5119892",
"0.50883555",
"0.506832",
"0.50622666",
"0.5058124",
"0.50564104",
"0.5038868",
"0.5027361",
"0.5020757",
"0.5019716",
"0.5013618",
"0.5005141",
"0.50047296",
"0.5003898",
"0.49921903",
"0.49898088",
"0.4989642",
"0.49785012",
"0.4962797",
"0.49595344",
"0.49594545",
"0.49556476",
"0.49495128",
"0.49468854",
"0.49468854",
"0.49407643",
"0.49261948",
"0.49147785",
"0.49091378",
"0.49067113",
"0.49046475",
"0.49022123",
"0.49011353",
"0.48968282",
"0.48958114",
"0.48948538"
] | 0.7462053 | 3 |
Write a method(s) that takes a real name and outputs a fake name. First and last name is swapped first, change each vowel (aeiou) to the next vowel, and then all of the constanants to the next constanant in the alphabet. 'a' would be come 'e' 'u' would become 'a' 'd' would become 'f' example: mickey mouse ==> mouse mickey ==> muasi mockiy ==> nuati nodliz BUSINESS LOGIC | def change_char(char)
vowels = ["a", "e", "i", "o", "u"]
constanants = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z"]
alphabet = 'abcdefghijklmnopqrstuvwxyz'
index_of_char = alphabet.index(char) # check for any non-alphabet characters
is_vowel = vowels.index(char) # check any vowels
is_constanant = constanants.index(char) # check for any constanants
if index_of_char == nil
char
# letter is not in alphabet, returns same character
elsif is_vowel
vowels.rotate(1)[vowels.index(char)]
# if letter is a vowel, returns next vowel
elsif is_constanant
constanants.rotate(1)[constanants.index(char)]
# if letter is a constanant, returns next constanant
else
char
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_fake_name (name)\n\t# Swap first & last name\n\tswap_name = name.split(' ').reverse.join(' ')\n\n\t# Swap characters - change all vowels to next vowel,\n\t# and all consonants to next consonant\n\n\t# Initialize fake_name & index (counter) variables \n\tfake_name = ''\n\tindex = 0\n\twhile index < swap_name.length\n\t\tchar = swap_name[index]\n\n\t\t# For each character\n\t\tif char == ' '\n\t\t\t# If space, add space\n\t\t\tfake_name += ' '\n\t\telse\n\t\t\t# Handle lower & uppercase properly\n\t\t\tif char == char.downcase\n\t\t\t\tfake_name += get_swapped_char(char)\n\t\t\telse\n\t\t\t\tfake_name += get_swapped_char(char.downcase).upcase\n\t\t\tend\n\t\tend\n\n\t\t# Increment counter\n\t\tindex += 1\n\tend\n\n\tfake_name\nend",
"def fake_name(name)\n fake_name = name.chars.map! do |letter|\n if letter == \" \"\n letter = \" \"\n elsif \"aeiou\".include?(letter)\n letter = next_vowel(letter)\n elsif \"zdhnt\".include?(letter)\n letter = pre_vowel_scramble(letter)\n else\n letter.next\n end\n end\n fake_name = fake_name.join\n swap_name_order(fake_name)\nend",
"def make_fake_name(name)\n # downcase to avoid issues due to capitalization\n # convert name to an array of characters\n # for each letter,\n name = name.downcase.chars.map! do |letter|\n # if it is a vowel, change it to the next vowel\n if 'aeiou'.include?(letter)\n next_vowel(letter)\n # elsif it is a letter, change it to the next consonant\n elsif ('a'..'z').include?(letter)\n next_consonant(letter)\n # otherwise, nil it\n end\n end\n # convert name back to a string and re-capitalize it\n name = name.join.capitalize\nend",
"def fake_name (full_name)\n words_array = full_name.split (\" \")\n swap_name_array = words_array.reverse\n swap_name = swap_name_array.join(\" \")\n letters = swap_name.chars\n fake_letters = []\n letters.each do |letter|\n vowel = %w[a A e E i I o O u U]\n if vowel.include?(letter)\n fake_letters << next_vowel(letter)\n elsif letter == \" \"\n fake_letters << \" \"\n else\n fake_letters << next_unvowel(letter)\n end\nend\n return fake_letters.join (\"\")\nend",
"def fake_name(name)\n name = name.split.rotate\n name.map! do |n|\n n.downcase!\n vowels = 'aeiou'\n vowels_shifted = vowels.split('').rotate.join\n consonants = 'bcdfghjklmnpqrstvwxyz'\n consonants_shifted = consonants.split('').rotate.join\n\n n.tr!(vowels, vowels_shifted)\n n.tr!(consonants, consonants_shifted)\n\n n = n.split('')\n n[0] = n[0].upcase\n n = n.join\n end\n name = name.join(' ')\nend",
"def fake_name(real_name)\n\treal_full_name = real_name.split(\" \")\n\treal_first_name = real_full_name[0].downcase \n\treal_last_name = real_full_name[1].downcase\n\talphabet = [\"a\",\"b\", \"c\", \"d\", \"e\",\"f\", \"g\", \"h\",\"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n\ti = 0\n\tfake_first_name = \"\"\n\tfake_last_name = \"\"\n\tlength_first = real_first_name.length\n\tlength_last = real_last_name.length \n\n\twhile i < length_first\n\t\tif real_first_name[i] == \"z\"\n\t\t\tfake_first_name += \"a\"\n\t\telsif real_first_name[i] == \"a\" || real_first_name[i] ==\"e\" || \n\t\t\t real_first_name[i] == \"i\" || real_first_name[i] == \"o\" || \n\t\t\t real_first_name[i] == \"u\"\n\t\t\tfake_first_name += real_first_name[i] \n\t\telsif \n\t\t\tind = alphabet.index(real_first_name[i])\n\t\t\tfake_first_name += alphabet[ind+1]\n\t\tend \n\t\ti+=1\n\t\t#fake_first_name[0] = fake_first_name[0].upcase\n\tend \n\tfake_first_name\nend",
"def name_swapper(full_name)\n full_name = full_name.downcase\n vowel_array = ['a','e','i','o','u']\n consenant_array = \"bcdfghjklmnpqrstvwxyz\".split('')\n name_array = full_name.split(\" \")\n reversed_name= \"#{name_array[1]} #{name_array[0]}\"\n secret_name = reversed_name.split('').map! do |letter|\n if vowel_array.include?(letter)\n vowel_array[vowel_array.index(letter)+1]\n elsif consenant_array.include?(letter)\n consenant_array[consenant_array.index(letter)+1]\n elsif letter == \" \"\n \" \"\n end\n\n end\n puts \"Your name USED to be #{full_name.upcase}...but now your name is #{secret_name.join.upcase}!\"\n secret_name.join.upcase\nend",
"def fake_name_c2(real_name)\n\treal_full_name = real_name.split(\" \")\n\treal_first_name = real_full_name[0] \n\treal_last_name = real_full_name[1]\n\ti = 0\n\tfake_first_name = \"\"\n\tfake_last_name = \"\"\n\tvowel_index = \"\"\n\tlength_first = real_first_name.length\n\tlength_last = real_last_name.length \n\t\twhile i < length_last\n\t\tif real_last_name[i] == \"z\"\n\t\t\tfake_last_name += \"a\"\n\t\telsif real_last_name[i] == \"a\" || real_last_name[i] ==\"e\" || \n\t\t\t real_last_name[i] == \"i\" || real_last_name[i] == \"o\" || \n\t\t\t real_last_name[i] == \"u\"\n\t\t\tfake_last_name += real_last_name[i] \n\t\telse \n\t\t\tfake_last_name += real_last_name[i].next \n\t\tend \n\t\ti+=1\n\tend\n\tfake_last_name\nend",
"def make_fake_name (name)\n\t# Swap first & last name\n\tswap_name = name.split(' ').reverse.join(' ')\n\n\tfake_name = ''\n\tindex = 0\n\twhile index < swap_name.length\n\t\tchar = swap_name[index]\n\t\tif char == ' '\n\t\t\tfake_name += ' '\n\t\telse\n\t\t\tif char == char.downcase\n\t\t\t\tfake_name += get_swapped_char(char)\n\t\t\telse\n\t\t\t\tfake_name += get_swapped_char(char.downcase).upcase\n\t\t\tend\n\t\tend\n\n\t\t# Increment counter\n\t\tindex += 1\n\tend\n\n\tfake_name\nend",
"def fakeName(name)\r\n\tnameLen = name.length\r\n\tnameIndex = 0\r\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\r\n\tcons = [\"b\", \"c\",\"d\", \"f\",\"g\", \"h\",\"j\", \"k\",\"l\", \"m\",\"n\", \"p\",\"q\", \"r\",\"s\", \"t\",\"v\", \"x\", \"z\",\"w\", \"y\"]\r\n\tnewName = \"\"\r\n\twhile nameIndex < nameLen\r\n\t\tvowelArrayIndex = 0\r\n\t\tvowels.each do |vow|\r\n\t\t\tif name[nameIndex] == vow\r\n\t\t\t\tnextchar = next_vowel(vowelArrayIndex)\r\n\t\t\t\tnewName = newName + nextchar\r\n\t\t\tend\r\n\t\t\tvowelArrayIndex += 1\r\n\t\tend\r\n\t\tvowelArrayIndex = 0\r\n\t\tconsArrayIndex = 0\r\n\t\tcons.each do |cons|\r\n\t\t\tif name[nameIndex] == cons\r\n\t\t\t\tnextchar = next_cons(consArrayIndex)\r\n\t\t\t\tnewName = newName + nextchar\r\n\t\t\tend\r\n\t\t\tconsArrayIndex += 1\r\n\t\tend\r\n\t\tnameIndex += 1\r\n\tend\r\n\treturn newName\r\nend",
"def fake_name(name)\n\n name_array = name.split('')\n\n name_array.map! do |letter|\n vowels = ['a','e','i','o','u', 'a']\n i = 0\n until i>vowels.length\n if i == 5\n letter = letter.next\n if vowels.include?(letter.downcase)\n letter = letter.next\n end\n break\n elsif letter.downcase == vowels[i]\n letter = vowels[i+1]\n break\n elsif letter.downcase == \" \"\n break\n else\n i += 1 \n end \n end\n letter\n end\n\n p name_array \n\n final_name = name_array.join.split(' ')\n\n final_name.map! do |letter|\n letter.capitalize\n end\n\n final_name2 = final_name.rotate.join(' ')\n\n return final_name2\n\nend",
"def spy_name(realname)\n\tvowels = ['a','e','i','o','u']\n\tconsonants = ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z']\n\treverseName = realname.downcase.split(\" \").reverse!\n\tfullName = reverseName[0] + \" \" + reverseName[1]\n\tletteredName = fullName.split('')\n \tletteredName.map! do |letter|\n \t if vowels.include?(letter)\n \t vowels.rotate(1)[vowels.index(letter)]\n \t elsif consonants.include?(letter)\n \t consonants.rotate(1)[consonants.index(letter)]\n \t end\n \tend\nfullName = letteredName.join('').insert(reverseName[0].length,' ')\nfullName.capitalize!\ntwoNames = fullName.split(\" \")\ntwoNames[1].capitalize!\nfullName = twoNames[0] + \" \" + twoNames[1]\np fullName\nend",
"def fake_name(real_name)\n #call swap name to swap first and last names\n swapped_name = swap_name( real_name)\n last_name = swapped_name[0]\n first_name = swapped_name[1]\n\n #call encrypting method\n fake_last_name = encrypt_word(last_name)\n fake_first_name = encrypt_word(first_name)\n\n #concatenate name\n fake_last_name + \" \" + fake_first_name\nend",
"def spy_name(real_name) ####Still in progress...######\nnew_name = real_name.downcase\nadjust = new_name.split(' ')\nfirst_n = adjust[0].split('')\nlast_n = adjust[1].split('')\n\n\tindex = 0\n\tuntil index == first_n.last\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n\t\t\tif first_n[index] == [\"a\", \"e\", \"i\", \"o\"]\n\t\t\t\tfirst_n[index] = vowels.next\n\t\t\telsif first_n[index] == \"u\"\n\t\t\t\tfirst_n[index] = \"a\"\n\t\t\telsif first_n[index] == \"z\"\n\t\t\t\tfirst_n[index] = \"b\"\n\t\t\telse first_n[index].next\n\t\t\t\tfirst_n[index] = first_n[index].next\n\t\tend\n\t\tindex += 1\n\tend\n#don't forget to return the method\n\tindex = 0\n\tuntil index == last_n.last\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n\t\t\tif last_n[index] == [\"a\", \"e\", \"i\", \"o\"]\n\t\t\t\tlast_n[index] = vowels.next\n\t\t\telsif last_n[index] == \"u\"\n\t\t\t\tlast_n[index] = \"a\"\n\t\t\telsif last_n[index] == \"z\"\n\t\t\t\tlast_n[index] = \"b\"\n\t\t\telse last_n[index].next\n\t\t\t\tlast_n[index] = last_n[index].next\n\t\tend\n\t\tindex += 1\n\tend\n\n\nend",
"def name_change(real_name)\r\n\tnew_name = real_name.downcase.split(' ')\r\n\tnew_name.map! { |real_name|\r\n\t\treal_name.split('').map! { |char|\r\n\t\t\tif \"aeiou\".index(char) != nil\r\n\t\t\t\tchange_char(char, \"aeiou\")\r\n\t\t\telse \r\n\t\t\t\tchange_char(char, \"bcdfghjklmnpqrstvwxyz\")\r\n\t\t\tend\r\n\t\t}\r\n\t}\r\n\tnew_first_name = new_name[1].join('')\r\n\tnew_last_name = new_name[0].join('')\r\n\treturn new_first_name.capitalize + \" \" + new_last_name.capitalize\r\nend",
"def name_change(normal_name)\nvowels = \"aeiouAEIOU\".split(\"\")\nconsonants = \"bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ\".split(\"\")\n\nchanged_name = normal_name.split(\" \")\nchanged_name[0], changed_name[1] = changed_name[1], changed_name[0]\n split_name = changed_name.join(\" \")\nname = split_name.split(\"\")\n\nnew_name = \"\"\nname.each_with_index do |letter, letter_index|\n if vowels.include?(letter)\n vowels.each_with_index do |vowel, vowel_index|\n if letter === vowel\n if letter === \"u\"\n new_name << \"a\"\n elsif letter === \"U\"\n new_name << \"A\"\n else\n new_name << vowels[vowel_index+1]\n end\n end\n end\nend\n if consonants.include?(letter)\n consonants.each_with_index do |consonant, consonant_index|\n if letter === consonant\n if letter === \"z\"\n new_name << \"b\"\n elsif letter === \"Z\"\n new_name << \"B\"\n else\n new_name << consonants[consonant_index+1]\n end\n end\n end\nend\n if letter === \" \"\n new_name << \" \"\n end\n end\n new_name\nend",
"def change_name(name)\r\n\t#store new name in new variable, downcase, split in an array and reverse order\r\n\tnew_name = name.downcase.split(' ').reverse.join(' ')\r\n\t#return the array of all the letters\r\n\t#p new_name\r\n\t#puts new_name.length\r\n\t#p new_name\r\n\talias_and_real_name = []\r\n\tindex = 0\r\n\tvowel_list = \"aeiou\"\r\n\tconsonant_list = \"bcdfghjklmnpqrstvwxyz\"\r\n\twhile index < new_name.length\r\n\t\t#[index] takes and integer and retunrs char, .index takes a char\r\n\t\t#and returns integer**\r\n\t\t#Does the letter at the # index of new_name match the vowel_list string\r\n\t\tif vowel_list.include?(new_name[index])\r\n\t\t\t#next_vowel_index is a #\r\n\t\t\t#it equals the vowel string at the letter index \r\n\t\t\t#from new_name's # index\r\n\t\t\t#Then get the next number\r\n\t\t\tnext_vowel_index = vowel_list.index(new_name[index]).next\r\n\t\t\t#new_name at that index # now equal this new # \r\n\t\t\t#Equals the vowel list at index of the next #\r\n\t\t\tnew_name[index] = vowel_list[next_vowel_index]\r\n\t\t\t\t#Solve for edge cases\r\n\t\t\t\t#If the letter is the name is going to be the last letter \r\n\t\t\t\t#in the vowel string, change it automatically to \r\n\t\t\t\t#the first on\r\n\t\t\r\n\t\t\t\r\n\t\telsif consonant_list.include?(new_name[index])\r\n\t\t\tnext_consonant_index = consonant_list.index(new_name[index]).next\r\n\t\t\tnew_name[index] = consonant_list[next_consonant_index]\r\n\r\n\t\tend #End if statement\r\n\t\t#Incriment outside of if statment but inside while loop\r\n\t\tindex += 1\r\n\t\r\n\tend #End While loop\r\n\r\n\t#return the new alias name\r\n\tnew_name\r\n\t\r\n\t#Take the alias name and stoe it in an array, new name first and real \r\n\t#name second\r\n\talias_and_real_name << new_name << name\r\n\t\r\n#End method\t\t\r\nend",
"def fake_identities(real_name)\n\n # input is downcase, split, and has reverse positions\n new_alias = real_name.downcase.split(' ').reverse\n # use map! to mutate name\n new_alias.map! {|name_info| name_info.split('')}\n\n new_alias.map! do |name_info|\n name_info.map! do |vowel|\n\n if vowel == \"z\"\n vowel = \"a\"\n elsif next_vowels(vowel) == vowel\n vowel.next!\n if next_vowels(vowel) != vowel\n vowel.next!\n end\n vowel\n else\n next_vowels(vowel)\n end\n end\n # returns a string and capitalizes first letter\n name_info.join('').capitalize\n end\n new_alias.join(' ') # keeps blank space here, otherwise it doesnt work\nend",
"def change_name(name)\n\t\t# create alphabet range\n\t\tvowels = 'aeiou'\n\t\tvowel_change = vowels.split('').reverse\n\t\tconsonants = 'abcdefghijklmnopqrstuvwxyz'\n\t\tconsonant_change = consonants.delete('aeiou').split('').reverse\n\n\t\toriginal_name = name\n\t\tname_reverse = original_name.downcase.split.reverse.join('').split('')\n\n\n\t\tnew_name = name_reverse.map do |letter|\n\t\t\tif vowels.include?(letter)\n\t\t\t\tvowel_change[vowel_change.index(letter)-1]\n\t\t\telsif consonants.include?(letter)\n\t\t\t\tconsonant_change[consonant_change.index(letter)-1]\n\t\t\telse\n\t\t\t\tletter\n\t\t\tend\nend\n\nfinal_name = new_name.join.split.map { |name| name.capitalize}.join('')\nend",
"def alias_creator(name)\n name.downcase!\n name_array = name.split(' ')\n name_array.reverse!\n # insert method for changing vowels here\n post_vowels = next_vowel(name_array)\n # insert method for changing consonants here#\n new_name = next_consonant(post_vowels)\n # re-capitalize the first letter of each name\n new_name.map! {|word| word.capitalize}\n # take our array and turn it into a string\n puts \"Your automatically generated alias is:\"\n p new_name * \" \"\nend",
"def name_converter(first_name, last_name)\n #1. swap the order names\n swapped_names = fake_name(first_name, last_name)\n #2 break swappedNames into array\n character_array = swapped_names.split('')\n #3. iterate through array\n vowel = [\"a\",\"e\",\"i\",\"o\",\"u\"]\n consonant = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\",\"y\",\"z\"]\n\n result = ''\n character_array.each do |character|\n if vowel.include?(character)\n #move forward next vowel in vowel array\n if character == 'u'\n result += 'a'\n next\n end \n \n current_index = vowel.index (character)\n new_index = current_index + 1\n #3. go to vowel array with new_index and retrieve that letter\n # next_letter = 'i'\n # add next_letter to result\n result += vowel[new_index]\n\n #follow same steps for moving forward next vowel for consonant \n\n elsif consonant.include?(character)\n if character == \"z\"\n result += 'b'\n next\n end\n\n current_index = consonant.index (character)\n new_index = current_index + 1\n\n result += consonant [new_index]\n\n result += character \n # add new letter to result\n end\n end\n #4. if the character is a vowel do a vowel swap\n #5. elsif the character is a consonant do a consonant swap\n \n result\nend",
"def change_name(name)\n # swapes names\n name = name.split(' ').reverse.join(' ')\n\n #change all consonant's\n name = name.downcase.split('').map do |l|\n if l.match(/[a,e,i,o,u,\\s]/)\n l = l\n #account for edge case\n elsif l == \"z\"\n l = \"b\"\n else\n l = l.next\n #fixes consonant's that changed into vowels\n if l.match(/[a,e,i,o,u]/)\n l.next\n else\n l = l\n end\n end\n end\n#Loop through vowles\n for i in 0..name.length()-1\n case name[i]\n when \"a\"\n name[i] = \"e\"\n when \"e\"\n name[i] = \"i\"\n when \"i\"\n name[i] = \"o\"\n when \"o\"\n name[i] = \"u\"\n when \"u\"\n name[i] = \"a\"\n end\n end\nname = name.join()\nname = name.split.map(&:capitalize).join(' ')\nputs name\nname\nend",
"def create_alias(real_name)\n\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n consonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\",\n \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\",\n \"v\", \"w\", \"x\", \"y\", \"z\"]\n\n # takes the real name, splits into words, reverses the order, joins into string again, and lowercases\n reversed_lowcase_str = real_name.split(\" \").reverse.join(\" \").downcase\n name_char_array = reversed_lowcase_str.chars\n fake_name_char_arr = name_char_array.map! do |letter|\n if letter == \" \"\n letter\n elsif letter == \"u\"\n letter = \"a\"\n elsif letter == \"z\"\n letter = \"b\"\n elsif vowels.include?(letter)\n letter = vowels[vowels.index(letter) + 1] # assigns the letter to be the next vowel\n elsif consonants.include?(letter)\n letter = consonants[consonants.index(letter) + 1]\n end\n end\n\n# rejoins the character array into one string, splits it into word array,\n# capitalizes each word, rejoins into string\n fake_name = fake_name_char_arr.join(\"\").split(\" \").map!{|name| name.capitalize}.join(\" \")\nend",
"def letter_change\n consonant = \"bcdfghjklmnpqrstvwxyz\"\n vowel = \"aeiou\"\n new_name = \"\"\n letter_new = \"\"\n\n split_flip_name.each do |letter|\n if consonant.index(letter) != nil\n letter_new = consonant[consonant.index(letter) + 1]\n elsif vowel.index(letter) != nil\n #addresses last vowel edge case\n if letter == \"u\"\n letter_new = \"a\"\n elsif\n letter_new = vowel[vowel.index(letter) + 1]\n end\n elsif letter == \" \"\n letter_new = letter\n end\n #.to_s addresses a nil edge case\n new_name += letter_new.to_s\n end\n p new_name\n\nend",
"def alias_maker(name)\n \n consonants = \"bcdfghjklmnpqrstvwxz\"\n next_cons = \"cdfghjklmnpqrstvwxzb\"\n \n name.downcase.tr(consonants,next_cons)\n .tr('aeiouy', 'eiouya')\n .split.reverse.each {|word| word.capitalize!}\n .join(' ')\n\n # Separated methods on lines 24-27 for readability\n # First .tr changes all consonants to next\n # Second .tr changes all vowels to next vowel\n # Split names to reverse and capitalize them\n # Rejoin to a single string\n\nend",
"def fake_name(letters)\r\n\tvowel_arr = ['a', 'e', 'i', 'o', 'u']\r\n\tletters.map! do |letter|\r\n\t\tif vowel_arr.include?(letter.downcase)\r\n\t\t\tif letter.upcase! == nil\r\n\t\t\t\t\tif letter.downcase == vowel_arr[4]\r\n\t\t\t\t\t\tletter = vowel_arr[0].upcase\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tnumber = vowel_arr.index(letter.downcase)\r\n\t\t\t\t\t\tnumber = number + 1\r\n\t\t\t\t\t\tletter = vowel_arr[number].upcase\r\n\t\t\t\t\tend\r\n\t\t\telse\r\n\t\t\t\tnumber = vowel_arr.index(letter.downcase)\r\n\t\t\t\t\tif number == 4\r\n\t\t\t\t\t\tletter = vowel_arr[0]\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tnumber = number + 1\r\n\t\t\t\t\t\tletter = vowel_arr[number]\r\n\t\t\t\t\tend\r\n\t\t\tend\r\n\t\telsif \"abcdefghijklmnopqrstuvwxyz\".include?(letter.downcase) == false\r\n\t\t\tletter = letter\r\n\t\telse \r\n\t\t\t\tif letter.downcase == 'z'\r\n\t\t\t\t\tletter = (letter.chr.ord - 24). chr\r\n\t\t\t\telsif vowel_arr.include?(letter.next.downcase) == false\r\n\t\t\t\t\tletter = letter.next\r\n\t\t\t\telse\r\n\t\t\t\t\tletter = letter.next.next\r\n\t\t\t\tend\r\n\t\tend\r\n\tend\r\nletters.join(\"\")\r\nend",
"def name_swap(name)\n reverse_name = name.downcase.split.reverse.join(' ')\n vowel_swap = reverse_name.tr!('aeiou', 'eioua')\n consonant_swap = vowel_swap.tr!('bcdfghjklmnpqrstvwxyz', 'cdfghjklmnpqrstvwxyz').split\n final_alias = consonant_swap.map(&:capitalize).join(' ')\nend",
"def make_vowel_change(first)\n\tnew_first = first.split(\"\") \n\ti = 0\n\tfake_firstname = \"\"\n\tlengthfirst = first.length\n\twhile i < lengthfirst\n\tif new_first[i] == \"a\"\n\t\tfake_firstname += \"e\"\n\telsif new_first[i] == \"e\"\n\t\tfake_firstname += \"i\"\n\telsif new_first[i] == \"i\"\n\t\tfake_firstname += \"o\"\n\telsif new_first[i] == \"o\"\n\t\tfake_firstname += \"u\"\n\telsif new_first[i] == \"u\"\n\t\tfake_firstname == \"a\"\n\telsif (new_first[i] != \"a\" || new_first[i] !=\"e\" || new_first[i] != \"i\" || new_first[i] != \"o\" || new_first[i] != \"u\")\n\t\tfake_firstname += new_first[i]\n\tend\n\ti+=1 \n\tend \n\tfake_firstname\nend",
"def nameSwitch(name)\n vowels = 'aeiou'\n new_name = ''\n newname = name.split(' ').reverse.join(' ')\nend",
"def alias\n puts \"Hello Agent, what is your name?\"\n original_name = gets.chomp.downcase\n\n# split first and last name into two arrays\n#swap first name and last name \n\n split_name = original_name.split\n reverse_name = split_name.reverse!\n \n #join back together in a string with a space\n new_name = reverse_name.join(\" \")\n \n\n# each character into it's own array\n\n letters = new_name.each_char.to_a\n#vowel logic\n#if a charcters = vowel then change to next vowel\n\n\n\n vowels = %w(a e i o u a)\n consonant = %w(b c d f g h j k l m n p q r s t v w x y z b)\n new_alias = letters.map do |letter|\n letter.next \n end\nputs new_alias.join('')\nend",
"def make_up_name(name)\nchanged_name = [] #empty array to push letters from name into when it goes through iteration\nvowels = \"aeiou\"\n\nconsonant = \"bcdfghjklmnpqrstvwxyz\"\n\n\n#if the index of the name provided is a consonant then change it to the next letter.\n\nindex = 0 #start at 0\n \n while index < name.length\n \t\tletter = name[index] #takes every index of every letter in name and stores it in a variable\n \t\tif vowels.include?(letter) #deals with edge case\n \t\t\tif letter == \"u\"\n \t\t\t\tchanged_name.push(\"a\")\n \t\t\telse #need to make it so every other vowel changes to next vowel letter.next\n \t\t\tend\n \t\telsif consonant.inlcude?(letter)\n \t\t\tif letter == \"z\" #deals with edge case\n \t\t\t\tchanged_name.push(\"b\")\n \t\t\telse #everything else will need to be next letter using letter.next \t\t \t\t\n \t\t\tend\n \t\telsif letter == \" \"\n \t\t\t\tchanged_name.push(\" \")\n \t\t\tend\n \t\t \t index += 1\n \tend\nnew_name_array = changed_name.join('') #takes all the letters in the array above and puts it in a new array\nnew_name_array.each {|name| p name.capitalize}\nend",
"def name_rotate(name)\r\n consonants = %w[b c d f g h j k l m n p q r s t v w x y z]\r\n vowels = ['a', 'e', 'i', 'o', 'u']\r\n \r\n name = name.downcase.split('')\r\n \r\n name_rotate = name.map { |char|\r\n if vowels.include?(char)\r\n vowels.rotate(1)[vowels.index(char)]\r\n elsif consonants.include?(char)\r\n consonants.rotate(1)[consonants.index(char)]\r\n else\r\n char\r\n end\r\n }\r\n \r\n name_rotate.join.split(' ').reverse.map { |x| x.capitalize }.join(' ')\r\nend",
"def aliass(full_name)\n alphabet = \"bcdfghjklmnpqrstvwxyz\"\n vowels = \"aeiou\"\n new_string = \"\"\n \n #break input word into array and iterate through each letter\n #if the letter is a vowel, take it and change it to next_vowel\n #if the letter is a consonant, take it and change it to consonant\n #else just add with no modification\n full_name.split('').each do |letter|\n if vowels.include?(letter)\n new_string += vowel(letter)\n elsif alphabet.include?(letter)\n new_string += consonant(letter)\n else\n new_string += letter\n end\n end\n #transform this new string into an array\n new_word = new_string.split(' ')\n #swap first and second word in array\n new_word.reverse!\n #turn new word into string\n new_word.map {|names| names.capitalize!}\n new_string = new_word.join(\" \")\n end",
"def name_swap(name)\n new_name = name.downcase.split(' ')\n spy_name = new_name[1] + ' ' + new_name[0]\n vowels = 'aeioua'\n consonants = 'bcdfghjklmnpqrstvwxyzb'\n new_letter = \"\"\n spy_name.chars.each do |letter|\n if vowels.include?(letter)\n new_letter += change_vowels(letter)\n #p new_letter\n elsif consonants.include?(letter)\n new_letter += change_consonant(letter)\n #p new_letter\n else\n new_letter += letter\n end\n end\n change_name = new_letter.split(' ')\n final_name = change_name.map{|name| name.capitalize}.join(' ')\n# Add a hash to store names and alias names\n alias_names = { name: name, encrypted_name: final_name}\n alias_names.store(:name, name)\n alias_names.store(:encrypted_name, final_name)\n return alias_names\n end",
"def alias_generator(name)\n\nname = name.downcase\n\nvowels_lowcase = %w(a e i o u)\nvowels = vowels_lowcase\nconsonants_lowcase = (\"a\"..\"z\").to_a - vowels\nconsonants = consonants_lowcase\n\n# original = (vowels + consonants)\n# new_letters = (vowels.rotate + consonants.rotate)\n\nname_array = name.split\nname_reverse = name_array.reverse\n\nname_reverse.map! do |word|\n word_split = word.split(\"\")\n # name_reverse[1].split(\"\")\n\n word_split.map! do |letter|\n if vowels.include? letter\n index = vowels.index(letter)\n if letter == vowels.last\n letter = vowels.first\n else\n letter = vowels[index + 1]\n end\n else\n index = consonants.index(letter)\n if letter == consonants.last\n letter = consonants.first\n else\n letter = consonants[index + 1]\n end\n end\n end\n\n word_split[0] = word_split[0].upcase\n word_split.join('')\nend\n\nname_reverse.join(' ')\n# # p name_reverse.tr(original,new_letters)\n\n\n\nend",
"def alias_method (name)\r\n\tnew_first = []\r\n\tnew_last = []\r\n\tvowels_string = \"aeiou\"\r\n\tvowels = vowels_string.split('')\r\n\tconsonants_string = \"bcdfghjklmnpqrstvwxyz\"\r\n\tconsonants = consonants_string.split('')\r\n\ttwo_names = name.split(' ')\r\n\tfirst_name = two_names[0].split('')\r\n\tlast_name = two_names[1].split('')\r\n\tlast_name.each do |character|\r\n\t\tcharacter = character.downcase\r\n\t\tif vowels.include?(character)\r\n\t\t\tindex = vowels.index(character)\r\n\t\t\tnew_last.push(vowels[index + 1])\r\n\t\tend\r\n\t\tif consonants.include?(character)\r\n\t\t\tindex = consonants.index(character)\r\n\t\t\tnew_last.push(consonants[index + 1])\r\n\t\tend\r\n\t\tif character.downcase == 'z'\r\n\t\t\tnew_last.push('b')\r\n\t\tend\r\n\t\tif character.downcase == 'u'\r\n\t\t\tnew_last.push('a')\r\n\t\tend\r\n\tend\r\n\tfirst_name.each do |character|\r\n\t\tcharacter = character.downcase\r\n\t\tif vowels.include?(character)\r\n\t\t\tindex = vowels.index(character)\r\n\t\t\tnew_first.push(vowels[index + 1])\r\n\t\tend\r\n\t\tif consonants.include?(character)\r\n\t\t\tindex = consonants.index(character)\r\n\t\t\tnew_first.push(consonants[index + 1])\r\n\t\tend\r\n\t\tif character.downcase == 'z'\r\n\t\t\tnew_first.push('b')\r\n\t\tend\r\n\t\tif character.downcase == 'u'\r\n\t\t\tnew_first.push('a')\r\n\t\tend\r\n\tend\r\n\tnew_last.push(' ')\r\n\tnew_last = new_last.join('').capitalize\r\n\tnew_first = new_first.join('').capitalize\r\n\treturn_val = new_last + new_first\r\n\treturn_val\r\nend",
"def aliasMaker(name)\r\n\tnewName = []\r\n\tnewName2 = []\r\n\tvowels = [\"a\",\"e\",\"i\",\"o\",\"u\"]\r\n\tconsonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\r\n\tstep1 = name.split(\" \")\r\n\ti = 0\r\n\tj = 0\r\n\r\n\twhile i <= step1.length\r\n\t\tnewName.push(step1[i])\r\n\t\ti += 1\r\n\tend\r\n\tnewName = newName.reverse\r\n\tnewName = newName.join(\" \")\r\n\tstep2 = newName\r\n\twhile j <= step2.length\r\n\t\tif isConsonant(step2[j]) == true\r\n\t\t\tnewName2.push(nextConsonant(step2[j]))\r\n\t\telsif isVowel(step2[j]) == true\r\n\t\t\tnewName2.push(nextVowel(step2[j]))\r\n\t\telse newName2.push(step2[j])\r\n\t\tend\r\n\t\tj += 1\r\n\tend\r\n\tanswer = newName2.join(\"\")\r\n\r\nend",
"def alias_creator(full_name)\n full_name = full_name.downcase\n name = full_name.split(' ').to_a\n first_name = name[0]\n last_name = name[1]\n first_name_letters = first_name.split('')\n last_name_letters = last_name.split('')\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\", \"a\"]\n consonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\", \"b\"]\n \n first_name_letters.map! do |letter|\n if vowels.include?(letter)\n letter_index = vowels.index(letter)\n new_letter_index = letter_index + 1\n letter = vowels[new_letter_index]\n elsif consonants.include?(letter)\n letter_index = consonants.index(letter)\n new_letter_index = letter_index + 1\n letter = consonants[new_letter_index]\n end\n end\n new_first_name = first_name_letters.join('').capitalize\n \n last_name_letters.map! do |letter|\n if vowels.include?(letter)\n letter_index = vowels.index(letter)\n new_letter_index = letter_index + 1\n letter = vowels[new_letter_index]\n elsif consonants.include?(letter)\n letter_index = consonants.index(letter)\n new_letter_index = letter_index + 1\n letter = consonants[new_letter_index]\n end\n end\n new_last_name = last_name_letters.join('').capitalize\n\n new_name = new_last_name + \" \" + new_first_name\n return new_name\n \nend",
"def swap_name(real_name)\n swapped_name = real_name.split(/ /).reverse #split and swap first name and last name\n last_name = swapped_name[0].chars\n first_name = swapped_name[1].chars\n swapped_name = [last_name, first_name] #split characters of the first and last names\nend",
"def swap_name_order(name)\n # Split input into first name and last name\n first_name = name.split(' ')[0].capitalize\n last_name = name.split(' ')[1].capitalize\n fake_name_1 = last_name + \" \" + first_name\nend",
"def aliass(full_name)\n\talphabet = \"bcdfghjklmnpqrstvwxyz\"\n\tvowels = \"aeiou\"\n\tnew_string = \"\"\n\n\t#break input word into array and iterate through each letter\n\t#if the letter is a vowel, take it and change it to next_vowel\n\t#if the letter is a consonant, take it and change it to consonant\n\t#else just add with no modification\n\tfull_name.split('').each do |letter|\n\t\tif vowels.include?(letter)\n\t\t\tnew_string += vowel(letter)\n\t\telsif alphabet.include?(letter)\n\t\t\tnew_string += consonant(letter)\n\t\telse\n\t\t\tnew_string += letter\n\t\tend\n\tend\n\t#transform this new string into an array\n\tnew_word = new_string.split(' ')\n\t#swap first and second word in array\n\tnew_word.reverse!\n\t#turn new word into string\n\tnew_word.map {|names| names.capitalize!}\n\tnew_string = new_word.join(\" \")\nend",
"def letter_swap(agent_name)\n vowels = \"aeiou\"\n consonants = \"bcdfghjklmnpqrstvwxyz\"\n letter_swap = agent_name.split(\"\")\n secret_name = []\n letter_swap.map! do |ltr|\n if vowels.include?(ltr)\n secret_name << vowels[vowels.index(ltr)+1]\n elsif consonants.include?(ltr)\n secret_name << consonants [consonants.index(ltr)+1]\n else\n puts \" \"\n end\n end\n\n secret_name.join(\"\").split.map {|ltr| ltr.capitalize}.join(' ').capitalize\n\nend",
"def alias_name\n first_name = \"lia\".chars\nlast_name = \"hogan\".chars\np first_name.class\nfirst_name[3] = last_name[0]\nfirst_name[4] = last_name[1]\nfirst_name[5] = last_name[2]\nfirst_name[6] = last_name[3]\nfirst_name[7] = last_name[4]\np first_name\n\nlast_name[5] = first_name[0]\nlast_name[6] = first_name[1]\nlast_name[7] = first_name[2]\np last_name\nfirst_name.delete_at(0)\nfirst_name.delete_at(0)\nfirst_name.delete_at(0)\np first_name\nlast_name.delete_at(0)\nlast_name.delete_at(0)\nlast_name.delete_at(0)\nlast_name.delete_at(0)\nlast_name.delete_at(0)\np last_name\n \n full_name = first_name + last_name\n index = 0 \n str_back = \"\"\n while index < full_name.length\n str_back[index]\n if full_name[index] == \"a\"\n str_back[index] = \"e\"\n elsif full_name[index] == \"b\" \n str_back[index] = \"c\"\n elsif full_name[index] == \"c\" \n str_back[index] = \"d\" \n elsif full_name[index] == \"d\" \n str_back[index] = \"f\"\n elsif full_name[index] == \"e\" \n str_back[index] = \"i\"\n elsif full_name[index] == \"f\" \n str_back[index] = \"g\"\n elsif full_name[index] == \"g\" \n str_back[index] = \"h\"\n elsif full_name[index] == \"h\" \n str_back[index] = \"j\"\n elsif full_name[index] == \"i\" \n str_back[index] = \"o\"\n elsif full_name[index] == \"j\" \n str_back[index] = \"k\"\n elsif full_name[index] == \"k\" \n str_back[index] = \"l\"\n elsif full_name[index] == \"l\" \n str_back[index] = \"m\"\n elsif full_name[index] == \"m\" \n str_back[index] = \"n\"\n elsif full_name[index] == \"n\" \n str_back[index] = \"p\"\n elsif full_name[index] == \"o\" \n str_back[index] = \"u\"\n elsif full_name[index] == \"p\" \n str_back[index] = \"q\"\n elsif full_name[index] == \"q\" \n str_back[index] = \"r\"\n elsif full_name[index] == \"r\" \n str_back[index] = \"s\"\n elsif full_name[index] == \"s\" \n str_back[index] = \"t\"\n elsif full_name[index] == \"t\" \n str_back[index] = \"v\"\n elsif full_name[index] == \"u\" \n str_back[index] = \"y\"\n elsif full_name[index] == \"v\" \n str_back[index] = \"w\"\n elsif full_name[index] == \"w\" \n str_back[index] = \"x\"\n elsif full_name[index] == \"x\" \n str_back[index] = \"z\"\n elsif full_name[index] == \"y\" \n str_back[index] = \"a\"\n elsif full_name[index] == \"z\" \n str_back[index] = \"b\"\n else \n str_back[index] = \" \"\n end\n index += 1 \n end\n str_back\nend",
"def spy_alias1 full_name\n alias_name = full_name.downcase.split(' ').reverse!.join(' ').split(//)\n vowels=['a','e','i','o','u']\n alias_name.map! do |letter|\n next_vowel=letter\n vowels.each_index do |index|\n if vowels[index]=='u'&&letter==vowels[index]\n next_vowel='a'\n elsif letter==vowels[index]\n next_vowel=vowels[index+1]\n end\n end\n next_vowel\n end\n \n consonants=['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z']\n alias_name.map! do |letter|\n next_consonant=letter\n consonants.each_index do |index|\n if consonants[index]=='z'&&letter==consonants[index]\n next_consonant='b'\n elsif letter==consonants[index]\n next_consonant=consonants[index+1]\n end\n end\n next_consonant\n end\n \n alias_name=alias_name.join('').split(' ').map! {|name| name.capitalize}.join(' ')\nend",
"def spy_name(str)\n #CREATE VARIABLES FOR VOWELS AND CONSONANTS\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n consonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n #CHANGE STRING FIRST INTO ARRAY THAT MAKES EACH WORD A VALUE THEN REVERSE THEM. \n #THEN TURN ARRAY BACK INTO STRING AND DOWNCASE ANY LETTER.\n #THEN TURN STRING BACK INTO ARRAY THAT TAKES EACH INDIVIDUAL CHARACATER AS A VALUE.\n str = str.split(' ').reverse.join.downcase\n str = str.split('')\n #CREATE TEMPORARY VARIABLE STR_NEW TO EQUEL STR THEN CHANGE BUMP EACH \n #VOWEL AND CONSONANT TO THE NEXT ONE IN LINE. \n str_new = str.map do |char|\n if vowels.include?(char)\n vowels.rotate(1)[vowels.index(char)]\n elsif consonants.include?(char)\n consonants.rotate(1)[consonants.index(char)]\n else\n char\n end\n end\n #TURN ARRAY BACK INTO STRING.\n str_new.join\nend",
"def make_vowel_change_2(last)\n\tnew_last = last.split(\"\") \n\ti = 0\n\tfake_lastname = \"\"\n\tlengthlast = last.length\n\twhile i < lengthlast\n\tif new_last[i] == \"a\"\n\t\tfake_lastname += \"e\"\n\telsif new_last[i] == \"e\"\n\t\tfake_lastname += \"i\"\n\telsif new_last[i] == \"i\"\n\t\tfake_lastname += \"o\"\n\telsif new_last[i] == \"o\"\n\t\tfake_lastname += \"u\"\n\telsif new_last[i] == \"u\"\n\t\tfake_lastname == \"a\"\n\telsif (new_last[i] != \"a\" || new_last[i] !=\"e\" || new_last[i] != \"i\" || new_last[i] != \"o\" || new_last[i] != \"u\")\n\t\tfake_lastname += new_last[i]\n\tend\n\ti+=1 \n\tend \n\tfake_lastname\nend",
"def aliass(full_name)\n\talphabet = \"bcdfghjklmnpqrstvwxyz\"\n\tvowels = \"aeiou\"\n\tnew_string = \"\"\n\n full_name.split('').each do |letter|\n \t\tif vowels.include?(letter)\n \t\t\tnew_string += vowel(letter)\n \t\telsif alphabet.include?(letter)\n \t\t\tnew_string += consonant(letter)\n \t\telse\n \t\t\tnew_string += letter\n \t\tend\nend\n#Transform this new string into an array\n#Swap first and second word in array\n#Turn new word into string\n#Create empty array outside of loop\nnew_word = new_string.split(' ')\n new_word.reverse!\n\nnew_word.map {|names| names.capitalize!}\nnew_string = new_word.join(\" \")\nend",
"def spy_alias2 full_name\n alphabet = {\n vowels: ['a','e','i','o','u'],\n consonants: ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z']\n }\n alias_name = full_name.downcase.split(' ').reverse!.join(' ').split(//)\n alias_name.map! do |letter|\n next_letter=letter\n if alphabet[:vowels].include?(letter)\n index=alphabet[:vowels].index(letter)\n if letter==alphabet[:vowels][-1]\n next_letter=alphabet[:vowels][0]\n else\n next_letter=alphabet[:vowels][index+1]\n end\n elsif alphabet[:consonants].include?(letter)\n index = alphabet[:consonants].index(letter)\n if letter==alphabet[:consonants][-1]\n next_letter=alphabet[:consonants][0]\n else\n next_letter=alphabet[:consonants][index+1]\n end\n end\n next_letter\n end\n alias_name=alias_name.join('').split(' ').map! {|name| name.capitalize}.join(' ')\nend",
"def alias_manager(name)\n name = name.downcase\n name = name.split(\" \").reverse.join(\" \")\n name = name.split(\"\")\n index = 0\n consonant = \"bcdfghjklmnpqrstvwqyz\"\n vowel = \"aeiou\"\n while index < name.length\n if\n !consonant.index(name[index]) && !vowel.index(name[index])\n elsif\n index_of_letter = vowel.index(name[index])\n new_letter = vowel[index_of_letter + 1]\n name[index] = new_letter\n else\n index_of_letter = consonant.index(name[index])\n new_letter = consonant[index_of_letter + 1]\n name[index]= new_letter\n end\n index += 1\n end\n name.join(\"\")\nend",
"def namecoder\n valid_input = false\n until valid_input\n secret_name_database = []\n \n puts \"Whats your first name?\"\n fname = gets.chomp.downcase.split('')\n puts \"What's your last name?\"\n lname = gets.chomp.downcase.split('')\n original_name = [fname,\" \", lname].join\n fullname = [fname,\" \", lname].reverse.flatten\n # p fullname\n \n fullalphabet = \"abcdefghijklmnopqrstuvwxyz\"\n consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z']\n alpha = ['a', 'b', 'c', 'd', 'e', 'u', 'z']\n vowels = ['a', 'e', 'i', 'o', 'u']\n \n # vowel_code(original_name)\n vowels = ['a', 'e', 'i', 'o', 'u']\n fn_vowel = fullname.map do |vowel|\n if vowels.include?(vowel)\n vowels.rotate(1)[vowels.index(vowel)]\n else\n vowel\n end\n end\n # p fn_vowel \n # name_vowels_changed.join\n \n # def cons_code(name_vowels_changed)\n # name_vowels_changed = name_vowels_changed.split('')\n name_both_changed = fn_vowel.map do |cons|\n if consonants.include?(cons)\n consonants.rotate(1)[consonants.index(cons)]\n else\n cons\n end\n end\n # p name_both_changed\n secret_name = name_both_changed.join\n orig_fullname = fullname.join.capitalize\n secret_name_database << [original_name, secret_name]\n p original_name\n p secret_name\n \n puts \"Press enter if you'd like to do another name. Otherwise, type 'quit'.\"\n continue = gets.chomp\n if continue == \"quit\"\n puts \"Thank you for using the program. Here is your list of names:\"\n secret_name_database.each do |orig, secret|\n puts \"#{orig}'s secret name is #{secret}.\"\n end \n valid_input = true\n else\n puts \"Time to add another name...\"\n end \n end\nend",
"def next_vowel(name)\n\tvowels = %w( a e i o u )\n\tname = name.downcase!.split('')\n\tnew_name = name.map do |vowels_method|\n\t\tif vowels.include?(vowels_method)\n\t\t\tvowels.rotate(1)[vowels.index(vowels_method)]\n\t\telsif vowels == 'u'\n\t\t\tvowels.replace('a')\t\n\t\telse\n\t\t\tvowels_method\n\t\tend\n\tend\n\tnew_name.join.capitalize\nend",
"def alias_genrator\n done = false\n real_names = []\n spy_names = []\n\n puts \"Welcome to the super secret alias name generator. What is your full name?\"\n real_name = gets.chomp.downcase\n\n until done\n done = false\n\n real_name_array = real_name.split(' ') # Turn name into array\n\n real_first_name = real_name_array[0].capitalize # Gets and capitalizes first string in real_first_name\n real_last_name = real_name_array.last.capitalize # Gets and capitalizes last string in real_first_name\n\n real_names << real_first_name + \" \" + real_last_name # Stores real name to an array\n\n name_letters = real_name.split('') # Turns user input into array of letters\n\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n consonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\" ]\n\n index = 0\n name_letters.each do |letter| # Checks each letter in name_letters to see if the letter is in the vowels array\n if letter == \"u\"\n name_letters[index] = \"a\"\n elsif\n if vowels.include?(letter) # If it is, store the index of the vowel plus one\n vowel_index = vowels.index(letter)+1\n name_letters[index] = vowels[vowel_index] # Store the new letter in the corresponding index of name_letters\n end\n end\n index+=1\n end\n\n index = 0\n name_letters.each do |letter| # Checks each letter in name_letters to see if the letter is in the consonants array\n if letter == \"z\"\n name_letters[index] = \"b\"\n elsif\n if consonants.include?(letter) # If it is, store the index of the consonants plus one\n consonant_index = consonants.index(letter)+1\n name_letters[index] = consonants[consonant_index] # Store the new letter in the corresponding index of name_letters\n end\n end\n index+=1\n end\n\n new_full_name = name_letters.join('').split(' ') # Joins the new letters of name_letters and splits it into two strings\n\n # In case spy's real name includes a middle name\n first_name = new_full_name[0].capitalize # Gets and capitalizes first string in new_full_name\n last_name = new_full_name.last.capitalize # Gets and capitalizes last string in new_full_name\n\n alias_name = last_name + \" \" + first_name\n\n spy_names << alias_name # Stores alias into an array\n\n p \"Great, your cool new alias is #{alias_name}! Enter another name or type 'done' to exit.\"\n answer = gets.chomp.downcase\n\n if answer == \"done\" # Checks if user is done\n done = true\n else\n real_name = answer\n end\n end\n\n num_of_spies = real_names.length # Gets the number of spies\n counter = 0\n\n while counter < num_of_spies\n p \"#{spy_names[counter]} is really #{real_names[counter]}\" # Prints spies real names and aliases\n counter+=1\n end\nend",
"def alias_creator(nickname)\nvowels=\"aeiou\"\nconsonants=\"bcdfghjklmnpqrstvwxyz\"\n#consonants exclude all vowels\n\nnickname_split=nickname.split(\"\")\nnew_nickname=[]\n#The translated nickname will be saved in the new_nickname arrawy\n\nnickname_split.map! do |x|\n\tif vowels.include?(x)\n\t\tnew_nickname << vowels[vowels.index(x)+1]\n\telsif consonants.include?(x)\n\t\tnew_nickname << consonants[consonants.index(x)+1]\n\telsif x == \" \"\n\t\tnew_nickname << \" \"\n\tend\nend\nnew_nickname.join(\"\").split.map {|x| x.capitalize}.join(\" \")\n#We are doing this so that we capitalize the first letter of both words\nend",
"def scrambler (name)\n\tswapped = name.split.rotate.join(\" \") # Take name and flip it.\n\tswapped.downcase! # Make string lowercase.\n\tname1 = swapped.tr(\"aeiou\", \"eioua\") # Shift all vowels by 1 place.\n\tname2 = name1.tr(\"bcdfghjklmnpqrstvwxyz\", \"cdfghjklmnpqrstvwxyzb\") # Shift all conconants by 1 place.\n\tname3 = name2.split.map(&:capitalize).join(\" \") # Make string into substrings capitalize and join back.\nend",
"def name_handler(name)\n name = name.downcase.chars #takes the input and makes it downcase and breaks it into an array to increment through\n name_new = name.map do |letter| #create a new array called name_new and start block to increment through each array\n letter_change(letter)\n end\n #Code addressing capitalization and swapping first / last\n namearr = name_new.join('').split #join the new_name array back into a string\n p namearr\n first_name = namearr[0] #assign first name to a new variable based on index\n last_name = namearr[1] #assign first name to a new variable based on index\n name_new = last_name.capitalize! + \" \" + first_name.capitalize! #capitalize and swap first for last\nend",
"def alias_maker(fullname)\r\n\tfullname= fullname.downcase\r\n\treverse_name = fullname.split(' ').reverse!.join(' ')\r\n\tletter_array = reverse_name.split('') \r\n\tletter_array.map! do |char|\r\n\t\tif char == \"a\"\r\n\t\t\tchar = \"e\"\r\n\t\telsif char == \"e\"\r\n\t\t\tchar = \"i\"\r\n\t\telsif char == \"i\"\r\n\t\t\tchar = \"o\"\r\n\t\telsif char == \"o\"\r\n\t\t\tchar = \"u\"\r\n\t\telsif char == \"u\"\r\n\t\t\tchar =\"a\"\r\n\t\telsif char == \" \"\r\n\t\t\tchar = \" \"\r\n\t\telse\r\n\t\t\tif char.next == \"a\"\r\n\t\t\tchar = char.next!.next!\r\n\t\t\telsif char.next == \"e\"\r\n\t\t\tchar = char.next!.next!\r\n\t\t\telsif char.next == \"i\"\r\n\t\t\tchar = char.next!.next!\r\n\t\t\telsif char.next == \"o\"\r\n\t\t\tchar = char.next!.next!\r\n\t\t\telsif char.next == \"u\"\r\n\t\t\tchar = char.next!.next!\r\n\t\t\telse\t\r\n\t\t\t\tchar = char.next!\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\tnew_name = letter_array.join\r\n\tfull_alias = new_name.split.map(&:capitalize).join(\" \")\r\nend",
"def encrypt_name(name)\n\n\t\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n\t\tconsonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n\t\talias_name = \"\"\n\t\t\t\n\t\t\tname.each_char do |letter|\n\t\t\t# if the letter is inside the array called vowels\n\t\t\t\tif vowels.include?(letter)\n\t\t\t\t\t# replace the letter with the next vowel in the array\n\t\t\t\t\t# put it into alias_name\n\t\t\t\t\talias_name << vowels[vowels.index(letter)+1]\n\t\t\t\t# replace the letter with the next consonant in the array\n\t\t\t\t# put it into alias_name\n\t\t\t\telsif consonants.include?(letter)\n\t\t\t\t\talias_name << consonants[consonants.index(letter)+1]\n\t\t\t\t# put letter into alias_name\n\t\t\t\t# this is for the spaces\t\n\t\t\t\telse\n\t\t\t\t\talias_name << letter\t\n\t\t\t\tend\n\t\t\tend\n\t\t\n\t\talias_name.split.reverse.map(&:capitalize)*' '\n\nend",
"def make_fake_full_name (full_name)\n # put names into an array and swap first and last (if you wanted a string instead: name.partition(' ').reverse.join)\n full_name = full_name.split(' ').reverse\n # for each name, replace it with a fake name\n full_name.map! {|name| make_fake_name(name)}\n # convert the full name back to a string with a space between the partial names\n full_name = full_name.join(' ')\nend",
"def vowel_converter(swapped_name)\r\n\t# Forces all letters to be lower case in order for code to work properly\r\n\tcode_name = swapped_name.downcase.chars\r\n\tvowels = %w{a e i o u}\r\n\tcode_name.map! do |letter|\r\n\t\t# Edge case fix to make code work as intended\r\n\t\tif letter == \"u\"\r\n\t\t\tletter = \"a\"\r\n\t\telsif vowels.include?(letter)\r\n\t\t\tvowels[vowels.index(letter) + 1]\r\n\t\telse\r\n\t\t\tletter\r\n\t\tend\r\n\tend\r\n\t# This re-capitalizes the first letter of each part of the name\r\n\tcode_name.join('').split.map(&:capitalize).join(' ')\r\nend",
"def next_letter(name)\r\n\t# Create master replacement list\r\n\t# We'll replace each letter with the next one in the list\r\n\t# Edge cases, upper case, etc. are handled within a single list\r\n\tswap_list = \"aeiouabcdfghjklmnpqrstvwxyzb\"\r\n\t# add upper case letters\r\n\tswap_list = swap_list + swap_list.upcase\r\n\t# divide name into array of characters\r\n\tletters = name.chars\r\n\t# swap each letter in array\r\n\tnew_letters = letters.map do |letter|\r\n\t\ti = swap_list.index(letter)\r\n\t\tif i\r\n\t\t\t# switch letter with next letter in list\r\n\t\t\tswap_list[i+1]\r\n\t\telse\r\n\t\t\t# keep as is\r\n\t\t\tletter\r\n\t\tend\r\n\tend\r\n\t# convert new array into string\r\n\tnew_name = new_letters.join\r\n\treturn new_name\r\nend",
"def name_switch(first_name, last_name)\r\n\tswap = last_name + \" \" + first_name\r\n\r\nend",
"def name_switch(first_name, last_name)\r\n\tswap = last_name + \" \" + first_name\r\n\r\nend",
"def alias_creator (str)\n# downcase all characters incase the name had initial caps.\nstr = str.downcase\t\n\n# create vowel string for cross checking each character (I ADDED 3 REPEATING VOWEL SEGMENTS TO PREVENT EDGE CASE FROM BREAKING WHEN ENCODING A VOEWEL AT THE END OF THE STRING LIKE U in \"AEIOU\") \nvowels = \"aeiouaeiouaeiou\"\n# create consonant string for cross checking each character\nconsonants = \"bcdfghjklmnpqrstvwxz\"\n# create empty strings that encoded first and last names will be stored in.\nname_alias = \"\"\n# create empty string to create an encoded full name \nspy_alias = \"\"\n=begin encoding names \n 1.taking the first name string and iterate through each character \n 2. check if vowels string includes current character in first name string\n 3. if it does access the letter in vowels string by its index, increment that index by one\n add that new letter to the alias string. \n 4. if the current character is a consonant it will go through the same process but using the consonants string\n 5. if the current character is a space a space will be added to the encoded string. \n=end\n \n str.each_char do |char| \n \tif char == \" \"\n name_alias+= \" \"\n\n \telsif vowels.include?(char)\n \t\tname_alias += vowels[vowels.index(char).next]\n \n elsif consonants.include?(char)\n \tname_alias += consonants[consonants.index(char).next]\n\n \n\n end \n \t\n end\n # check if the string that was encoded was a full name or just a first or last name\n # if it is a full name. sperate the first and last name and reverse the order (Lastname Firstname)\n \n if name_alias.include?(\" \")\n swap_name = name_alias.split(\" \")\n spy_alias = swap_name[1] + \" \" +swap_name[0]\n else spy_alias = name_alias\n end \n \n \n return spy_alias\n\n\nend",
"def vowel_swap (secret_name)\n\t#first separate string into an array of characters\n\t#the loop through looking for vowels\n\t#use each do loop to then go through each character\n\t#check to see if it is a vowel using gsub and replace with the next vowel\n\t#have to replace with an uppercase vowel, so when a becomes 'e' and then I check for 'e's, those 'a's don't become 'i's and etc\n\tsecret_name = secret_name.split('')\n\tsecret_name.each do |letters|\n\t\tletters.gsub!(/[a]/, \"E\")\n\t\tletters.gsub!(/[e]/, \"I\")\n\t\tletters.gsub!(/[i]/, \"O\")\n\t\tletters.gsub!(/[o]/, \"U\")\n\t\tletters.gsub!(/[u]/, \"A\")\n\tend\n\t#then downcase eveything\n\tsecret_name.map!{|letter| letter.downcase}\n\t\nend",
"def translate_name(name)\nreversed_name = name.split(' ').reverse\nnew_first = reversed_name[0].chars.map {|x|\n x.next\n }\nnew_last = reversed_name[1].chars.map {|x|\n x.next\n }\nnew_name = \"#{new_first.join} #{new_last.join}\"\nend",
"def alias_modifier(full_name)\n low_vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n up_vowels = [\"A\", \"E\", \"I\", \"O\", \"U\"]\n low_consonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n up_consonants = [\"B\", \"C\", \"D\", \"F\", \"G\", \"H\", \"J\", \"K\", \"L\", \"M\", \"N\", \"P\", \"Q\", \"R\", \"S\", \"T\", \"V\", \"W\", \"X\", \"Y\", \"Z\"]\n full_name = full_name.split('')\n updated_name = full_name.map do |char|\n if low_vowels.include?(char)\n low_vowels.rotate[low_vowels.index(char)]\n elsif up_vowels.include?(char)\n up_vowels.rotate[up_vowels.index(char)]\n elsif low_consonants.include?(char)\n low_consonants.rotate[low_consonants.index(char)]\n elsif up_consonants.include?(char)\n up_consonants.rotate[up_consonants.index(char)]\n else\n char\n end\n end\n updated_name.join\nend",
"def next_vowel(name)\n name = name.split('')\n name.each do |indivLetter| \n if indivLetter == \"a\"\n indivLetter.replace(\"e\")\n elsif indivLetter == \"e\"\n indivLetter.replace(\"i\")\n elsif indivLetter == \"i\"\n indivLetter.replace(\"o\")\n elsif indivLetter == \"o\"\n indivLetter.replace(\"u\")\n elsif indivLetter == \"u\"\n indivLetter.replace(\"a\")\n end\n end\nend",
"def mixture (fname, lname)\n mix_firstname = vowel_adv(fname)\n mix_firstname = const_adv(mix_firstname)\n \n mix_lastname = vowel_adv(lname)\n mix_lastname = const_adv(mix_lastname)\n \n mix_firstname = mix_firstname.capitalize\n mix_lastname = mix_lastname.capitalize\n \n tmp = mix_firstname\n mix_firstname = mix_lastname\n mix_lastname = tmp\n return \"#{mix_firstname} #{mix_lastname}\"\n \nend",
"def fake_name (first_name, last_name)\n \"#{last_name} #{first_name}\"\nend",
"def spy_name(real_name)\n capitalize(next_letter(swap(real_name)))\nend",
"def spyname(real_name)\n spy_array = []\n split_name = real_name.reverse.split('')\n split_name.join.chars\n split_name.map! do|name|\n name.tr!(\"aeiouAEIUO\",\"eiouaEIOUA\")\n name.tr!(\"bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ\",\"cdfghjklmnpqrstvwxyzbCDFGHJKLMNPQRSTVWXYZB\")\n spy_array << name.to_str\nend\n p spy_array.join\nend",
"def next_vowel(str)\n\t# Need to identify the vowels in the English alphabet in a new variable\n\tvowels = [\"a\",\"e\",\"i\",\"o\",\"u\"]\n\t# Need to also identify the consonants in the English alphabet in a new variable\n\tconsonants = [\"b\",\"c\",\"d\",\"f\",\"g\",\"h\",\"j\",\"k\",\"l\",\"m\",\"n\",\"p\",\"q\",\"r\",\n\t\t\"s\",\"t\",\"v\",\"w\",\"x\",\"y\",\"z\"]\n\twords = str.split # Splitting the name into words based on space (' ')\n\t\n\t## Loop into each name\n\ti = 0 # Setting an index to zero\n\tnew_word = [] # Setting up an empty array for our new scrambled word\n\tmod_word = [] # Setting up an empty array to hold the capitalized scrambled word\n\n\twhile i < words.length # Looping into each word\n\t\tchars = words[i].split('') # Split each word into characters\n\t\tnew_chars = chars.map{|char| # Mapping into each character\n\t\t\tif vowels.include?(char) # If the character is included in the vowels variable\n\t\t\t\tvowels.rotate(1)[vowels.index(char)] # Reassign it to the next vowel\n\t\t\telsif consonants.include?(char) # If the character is included in the consonants variable\n\t\t\t\tconsonants.rotate(1)[consonants.index(char)] # Reassign it to the next consonet\n\t\t\telse\n\t\t\t\tchar # Otherwise don't do anything (In case there are odd characters)\n\t\t\tend\n\t\t}\n\t\tnew_word.push(new_chars.join) # rejoin the word\n\t\t# This bit of code capitalizes the first character of the name\n\t\tmod_word.push(new_word[i].slice(0,1).capitalize + new_word[i].slice(1..-1))\n\t\ti += 1 # increment counter\n\tend\n\treturn mod_word.join(' ') # return the rejoined words\nend",
"def secret_name (name)\r\n\tname = name.downcase\r\n\r\n#create temporary name container \r\ntemp_name = \"\"\r\n#make to strings containing vowels and consonants \r\n#handle edge case by copying the first character to the end\r\nvowels = \"aeioua\"\r\nconsonants = \"bcdfghjklmnpqrstvwxyzb\"\r\n#iterate through each character in the name string and find vowels, consonants and spaces\r\n#add the corresponding letter/character to the temporary name variable and return that variable\r\nname.each_char do |letter| \r\n\tif letter == \" \"\r\n\t\ttemp_name += \" \"\r\n\t\t\r\n\telsif vowels.include?(letter)\r\n \t\ttemp_name += vowels[vowels.index(letter).next]\r\n \t\r\n elsif consonants.include?(letter)\r\n \ttemp_name += consonants[consonants.index(letter).next]\r\n \r\nend\r\n end\r\n return temp_name\r\n end",
"def alias_generator(agent)\n\n# changes vowels into array and uses .reverse method to account \n# for edge cases\n\tvowels = \"aeiou\"\n\tnew_vowels = \"aeiou\".split('').reverse\n\n# changes consonants into array and uses .reverse method to account\n# for edge cases\n\tconsonants = \"bcdfghjklmnpqrstvwxyz\"\n\tnew_consonants = \"bcdfghjklmnpqrstvwxyz\".split('').reverse\n\n# defines variables for user input and parameter\n\treal_name = agent\n\n# swaps first and last names and turns them into arrays \n\treversed_real_name = real_name.downcase.split(' ').reverse\n \talias_name_array = reversed_real_name.join(' ').split('')\n\n # maps the new array through the indices of the vowel and consonant arrays\n \taltered_name = alias_name_array.map do |char| \n if vowels.include?(char)\n # if there is a vowel, it will map to the next vowel\n new_vowels[new_vowels.index(char)-1]\n elsif consonants.include?(char)\n # if there is a consonant, it will map to the next consonant\n new_consonants[new_consonants.index(char)-1]\n else\n # accounts for space or another character\n char\n end\n end \n\n# takes the newly mapped array, joins it back together and capitalizes it\n\tnew_alias = altered_name.join.split.map!{ |name| name.capitalize }.join(\" \")\nend",
"def next_vowcon(oldlet) #actually takes in the whole name (not just 1 letter), since it is only split to an array of [first_name, last_name]\r\n vowel = ['a','e','i','o','u']\r\n rot_vow = vowel.rotate #reverses vowel array\r\n consonant = 'bcdfghjklmnpqrstvwxzy'.split('')\r\n rot_cons= consonant.rotate #reverses consonant array\r\n i=0\r\n while i < oldlet.length\r\n if vow_index = vowel.index(oldlet[i])\r\n oldlet[i] = rot_vow[vow_index]\r\n else\r\n cons_index = consonant.index(oldlet[i])\r\n oldlet[i] = rot_cons[cons_index]\r\n end\r\n i +=1\r\n end\r\n return oldlet\r\nend",
"def scramble\n\tconsonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z', 'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z']\n\tvowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']\n\n\tputs \"What name would you like to use?\"\n# Get name and return a string\n\t\tspy_name = gets.chomp.to_str\n# Turn into an array to swap name places\n\t\trotate_name = spy_name.split(' ').rotate!\n\t\tp rotate_name\n# Change all of the vowels\n\t\tscramble_name = rotate_name.join(' ')\n\t\tnew_spy_name = scramble_name.split(' ')\n\t\tvowels.each do |vowel|\n\t\t\tnew_spy_name << vowel.next\n\t\tend\nend",
"def name_scramble(str)\n\tarr = str.downcase.split(\"\")\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n\tconsonant = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n\tstr_new = arr.map do |char|\n\t\tif vowels.include?(char) \n\t\t\tvowels.rotate[vowels.index(char)];\n\t\telsif consonant.include?(char)\n\t\t\tconsonant.rotate[consonant.index(char)]\n\t\tend\n\tend\n\tstr_new.join.capitalize\nend",
"def vowel_changer(name)\n vowel_string = \"aeiou\"\n name_array = name.downcase.chars\n new_name = []\n name_array.each do |character|\n if character == \"u\"\n character = \"a\"\n new_name << character\n elsif vowel_string.include? character\n character = vowel_string[vowel_string.index(character) +1]\n new_name << character\n else\n new_name << character\n end\n end\n new_name.join(\"\").split(\" \").each {|word| word.capitalize!}.join(\" \")\nend",
"def new_alias(full_name)\r\n\tnames = full_name.split(\" \")\r\n\tnames.reverse!\r\n\tnames.map! {|each_name| each_name.split(\"\")}\r\n\tnames.map! do |namearray|\r\n\t namearray.map! do |letter|\r\n\t if letter == \"z\"\r\n\t letter = \"a\"\r\n\t else letter.next!\r\n\t end\r\n\tend\r\n\tnames = namearray.join(\"\")\r\n\tend\r\nend",
"def consonant_swap (secret_name)\n\t\n\tsecret_name.map do |letters|\n\t\t\n\t\tif letters == \" \"\n\t\t\tletters\n\t\telsif letters == \"z\"\n\t\t\tletters.gsub!(/[z]/, \"a\")\n\t\telsif letters =~ /[aeiou]/\n\t\t\tletters\n\t\telse \n\t\t\tletters.next!\n\t\t\tif letters =~ /[aeiou]/\n\t\t\t\tletters.next!\n\t\t\tend\n\t\tend\n\n\tend\n\tsecret_name\nend",
"def consenant_swap(name)\r\n name = name.downcase\r\n consenants = \"bcdfghjklmnpqrstvwxyz\"\r\n name_index = 0\r\n cons_index = 0\r\n while name_index < name.length\r\n if name[name_index] == \"a\" || name[name_index] == \"e\" ||name[name_index] == \"i\"|| name[name_index] == \"o\" || name[name_index] == \"u\" || name[name_index] == \" \"\r\n name_index += 1\r\n elsif name[name_index] == \"z\"\r\n name[name_index] = \"b\"\r\n name_index += 1\r\n else\r\n until name[name_index] == consenants[cons_index]\r\n cons_index += 1\r\n end\r\n name[name_index] = consenants[cons_index + 1]\r\n name_index += 1\r\n end\r\n cons_index = 0\r\n end\r\n name\r\nend",
"def codeName (str)\n\tstr = str.to_s.downcase.split(' ')\n\tk = str[0]\n\tstr[0] = str[1]\n\tstr[1] = k\n\tvowels = \"aeiou\"\n\tconsonants = \"bcdfghjklmnpqrstvwxyz\"\n\t\n\tlastName = str[0].chars\n\tfirstName = str[1].chars\n\t\n\tfor i in 0..(lastName.length-1)\n\t\tif lastName[i] == \"a\" || lastName[i] == \"e\" || lastName[i] == \"i\" || lastName[i] == \"o\" || lastName[i] == \"u\"\n\t\t\tlastName[i] = vowels[vowels.index(lastName[i])+1]\n\t\telse\n\t\t\tlastName[i] = consonants[consonants.index(lastName[i])+1]\n\t\tend\n\tend\n\t\n\tfor i in 0..(firstName.length-1)\n\t\tif firstName[i] == \"a\" || firstName[i] == \"e\" || firstName[i] == \"i\" || firstName[i] == \"o\" || firstName[i] == \"u\"\n\t\t\tfirstName[i] = vowels[vowels.index(firstName[i])+1]\n\t\telse\n\t\t\tfirstName[i] = consonants[consonants.index(firstName[i])+1]\n\t\tend\n\tend\n\tstr[0] = lastName.join('').capitalize\n\tstr[1] = firstName.join('').capitalize\n\tstr.join(' ')\n\t\nend",
"def swap_name(name)\n new_name = name.downcase.split.reverse\n new_name = new_name.join(\" \")\n new_name = new_name.chars\n new_name.map! do |letter|\n if letter == \" \"\n \" \"\n else\n letter_changer(letter)\n end\n end\n new_name = new_name.join('')\nend",
"def next_letter(reversed_name)\n vowels = 'aeioua'\n consonants = 'bcdfghjklmnpqrstvwxy'\n #reversed name to array\n reversed_name_array = reversed_name.split('')\n #check if letter is vowel if so make it next vowel\n #check if letter is consonant if so make it next consonant\n reversed_name_array.map! { |letter|\n if vowels.index(letter) != nil\n new_vowel = vowels.index(letter) + 1\n letter = vowels[new_vowel]\n elsif consonants.index(letter) != nil\n new_consonant = consonants.index(letter) + 1\n letter = consonants[new_consonant]\n else\n letter = letter\n end\n }\n reversed_name_array_joined = reversed_name_array.join\nend",
"def alias_generator(name)\n name_ord_reversed = name.split(' ').reverse\n name_ord_reversed = name_ord_reversed.join(\" \")\n name_ord_reversed = name_ord_reversed.split('')\n p name_ord_reversed\n vowels = \"aeiou\"\n vowels_array = vowels.split('')\n p vowels_array\n consonants = \"bcdfghjklmnpqrstvwxyz\"\n consonants_array = consonants.split('')\n p consonants_array\n index = 0 \n until index >= name.length do\n new_alias = []\n letter = name_ord_reversed[index]\n if letter == \" \"\n new_alias << letter\n elsif vowels.include? letter\n new_letter = vowels[index+1]\n new_alias << new_letter\n elsif consonants.include? letter\n new_letter = consonants[index+1]\n new_alias << new_letter\n end \n index += 1 \n end \n \n \n \n\n \nend",
"def vowels_consonant_movement2(name)\n name = name.downcase.split(\" \")\nfirst_name = name[0]\nsecond_name = name[1]\n consonants = \"bcdfghjklmnpqrstvwxyz\"\n vowels = \"aeiou\"\n translated_name = []\n translated_name2 = []\n\n#adjust first name \n x = 0 \n while x < first_name.length\n if first_name[x] == \"z\"\n first_name[x] = \"b\"\n translated_name << first_name[x]\n elsif\n first_name[x] == \"u\"\n first_name[x] = \"a\"\n translated_name << first_name[x]\n \n elsif consonants.include?first_name[x]\n \n new_position = consonants.index(first_name[x]) + 1 \n \n first_name[x] = consonants[new_position]\n translated_name << first_name[x]\n \n elsif vowels.include?first_name[x]\n newer_position = vowels.index(first_name[x]) + 1\n first_name[x] = vowels[newer_position]\n translated_name << first_name[x]\n \n end\n \n x += 1\n end\n \n#adjust second name \n x = 0 \n while x < second_name.length\n if second_name[x] == \"z\"\n second_name[x] = \"b\"\n translated_name2 << second_name[x]\n elsif\n second_name[x] == \"u\"\n second_name[x] = \"a\"\n translated_name2 << second_name[x]\n \n elsif consonants.include?second_name[x]\n \n new_position = consonants.index(second_name[x]) + 1 \n \n second_name[x] = consonants[new_position]\n translated_name2 << second_name[x]\n \n elsif vowels.include?second_name[x]\n newer_position = vowels.index(second_name[x]) + 1\n second_name[x] = vowels[newer_position]\n translated_name2 << second_name[x]\n \n end\n \n x += 1\n end\n \n first_letter = translated_name[0].upcase\n translated_name.delete_at(0)\n translated_name.insert(0, first_letter)\n \n first_letter2 = translated_name2[0].upcase\n translated_name2.delete_at(0)\n translated_name2.insert(0, first_letter2)\n \n return translated_name2.join(\"\") + \" \" + translated_name.join(\"\")\n \n \nend",
"def next_letter(name)\n vowels = \"aeiou\".split(\"\")\n consonants = \"bcdfghjklmnpqrstvwxyz\".split(\"\")\n spy_name = []\n \n name.split(\"\").map do |letter|\n if vowels.include?(letter)\n vowels.index(letter)\n index = vowels.index(letter)\n new_letter = vowels[index + 1]\n new_letter\n elsif consonants.include?(letter)\n consonants.index(letter)\n index = consonants.index(letter)\n new_letter = consonants[index + 1]\n new_letter\n elsif letter == \" \"\n new_letter = \" \"\n new_letter\n end\n spy_name.push(new_letter)\n end\n \n spy_name.join(\"\")\nend",
"def spy_alias(real_name)\r\n\treal_name.gsub!(/[aeiou]/, \"a\" => \"e\", \"e\" => \"i\", \"i\" => \"o\", \"o\" => \"u\", \"u\" => \"a\") \r\n\treal_name.gsub!(/[bcdfghjklm]/, \"b\" => \"c\", \"c\" => \"d\", \"d\" => \"f\", \"f\" => \"g\", \"g\" => \"h\", \"h\" => \"j\", \"j\" => \"l\", \"l\" => \"m\", \"m\" => \"n\") \r\n\treal_name.gsub!(/[npqrstvwxyz]/, \"n\" => \"p\", \"p\" => \"r\", \"r\" => \"s\", \"s\" => \"t\", \"t\" => \"v\", \"v\" => \"w\", \"w\" => \"x\", \"x\" => \"y\", \"y\" => \"z\", \"z\" => \"b\")\r\nend",
"def code_letter(name)\nname = name.downcase.tr(\"aeiou\", \"eioua\")\nname = name.downcase.tr(\"bcdfghjklmnpqrstvwxyz\", \"cdfghjklmnpqrstvwxyzb\")\nend",
"def name_scrambler\r\n\t\r\n\r\n\tscrambled_names = {}\r\n\tputs \"What is your first and last name?\"\r\n\tuser_name = gets.chomp \r\n\twhile user_name != \"quit\" && user_name != \"\" \r\n\t\tnew_name = user_name.downcase.split(' ').reverse!.join(' ')\r\n\t\tname_to_array = new_name.chars\r\n\t\t# This takes the string version of the name and makes it into an \tarray, with each letter separated. \r\n\t\tconsonants = %w{b c d f g h j k l m n p q r s t v w x y z}\r\n\t\tvowels = %w{a e i o u}\r\n\t\t# Setting the new strings we want our conditions to match\r\n\t\tname_to_array.map! do |letter| \r\n\t\t\tif letter == \"u\"\r\n\t\t\t\tletter = \"a\"\r\n \t\t\telsif vowels.include?(letter)\r\n \t\t\t\t# if the letter returns a true value(is a vowel), re\t-assign a new index to that letter (advanced by 1)\r\n \t\t\t\tnew_vowel_index = vowels.index(letter) + 1\r\n \t\t\t\tnew_vowel = vowels[new_vowel_index]\r\n\t\t\telsif letter == \"z\"\r\n\t\t\t\tletter = \"b\"\r\n\t\t\telsif consonants.include?(letter)\r\n\t\t\t\tnew_consonant_index = consonants.index(letter) + 1\r\n\t\t\t\tnew_consonant = consonants[new_consonant_index]\r\n\t\t\telse \r\n\t\t\t\tletter # Accounts for spaces\r\n\t\t\tend\t\t\r\n\t\tend\r\n\t\t#re capitalize by joining the indiv. letters, splitting into first \tand last, capitalizing, and rejoining\r\n\t\tscrambled_name = name_to_array.join('').split(\" \").each{|i| i\t.capitalize!}.join(\" \")\r\n\t\tscrambled_names[user_name] = scrambled_name\r\n\t\tuser_name = gets.chomp #assigns new input to user_name to see if it should loop back to begining or quit\r\n\t\tend \r\nscrambled_names.each do |user_name, scrambled_name|\r\n\tputs \"#{scrambled_name} is more commonly known as #{user_name}\"\r\nend \r\nend",
"def nextLetter(full_name)\n vowels = 'aeiou'\n split_letters = full_name.split('')\n split_letters.map! { |letter|\n if letter != \" \"\n if vowels.index(letter.downcase) != nil\n letter = nextVowel(letter)\n else\n letter = nextConsonant(letter)\n end\n else\n # Don't know exactly why this has to be here but I lose my spaces if I\n # don't do it.\n letter = letter\n end\n }\n split_letters.join('')\nend",
"def swap_name(full_name)\n first_name, last_name = full_name.split(' ')\n\n altered_name = \"#{last_name}, #{first_name}\"\nend",
"def swap_first_last(name)\n name = name.downcase\n swap_name = name.split(' ')\n swap_name[1] << ' '\n swap_name_reverse = swap_name.reverse\n swap_name_reverse_joined = swap_name_reverse.join\nend",
"def alias_creator(name)\n puts \"Your name backwards is #{name.split(' ').rotate!.join(' ')}.\"\nend",
"def get_spy_name(names)\n # no space in between names or too manynames\n if names.count(\" \") == 0\n print \"Enter 2 names\"\n return nil\n elsif names.count(\" \") > 1\n print \"Enter just 2 names\"\n return nil\n end\n\n names_arr = swap_names(names)\n\n names_arr.map!{ |name|\n chars_array = name.chars\n\n chars_array.map!{ |char|\n char = next_letter(char)\n }\n }\n\n # capitalize first letter of both names\n names_arr[0][0].capitalize!\n names_arr[1][0].capitalize!\n\n #insert space after new first name\n names_arr.insert(1, ' ')\n\n return names_arr.join()\nend",
"def format_name(first, last)\n return nil if first.empty? || last.empty?\n first.gsub! (/[^a-z]/i, \"\")\n last.gsub! (/[^a-z]/i, \"\")\n ((first.split(\" \").join[0]<<last).split(\" \").join.downcase)\n\nend",
"def vowel_changer(name)\n vowel_guide = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n name.each do |names|\n name = names.split('')\n name\n name.map! do |char|\n index = 0\n while index < vowel_guide.length\n if char == vowel_guide[index]\n char = vowel_guide[index += 1]\n index += 1\n elsif char == \"u\"\n char = \"a\"\n index += 1\n else\n char\n index += 1\n end\n\n end\n char\n end\n name\n end\n name\nend",
"def next_letter (name)\n vowels = \"aeiou\".split('')\nalphabet = ('a'..'z').to_a\nconsonants = alphabet - vowels\nname_array = name.split('')\nname_array.map! { |letter|\n if letter == \"u\"\n \"a\"\n elsif letter == \"z\"\n \"b\"\n elsif consonants.include? letter\n consonants[consonants.index(letter) + 1]\n elsif vowels.include? letter\n vowels[vowels.index(letter) + 1]\n else\n letter\n end\n}\nname_array.join('')\nend",
"def change_name(original)\n original.gsub!(' ','_')\n INVALID_CHARS.split('').each do |char|\n original.gsub!(char,'')\n end\n original.downcase\n end",
"def name_encryption(full_name)\n\nfull_name = full_name.split(' ').rotate.join(' ')\n# .split(' ') splits full_name into array [\"first\", \"last\"]\n# .rotate rotates the first and last name within the array. (Ex. [\"last\", \"first\"])\n# .join(' ') combines array into a string. (Ex. \"last first\")\n\ncode_name = full_name.split('').map{ |x| x = next_letter(x)}\n# .split('') splits the string \"last first\" into individual characters.\n# .map{ |x| x = next_letter(x)} uses the next_letter method on each character and saves the changes.\n\ncode_name = code_name.join('')\n# .join('') combines individual characters into a\n\nend",
"def swap_names(name)\n real_names = name.downcase.split(\" \")\n real_names[0], real_names[-1] = real_names[-1], real_names[0]\n real_names.join(\" \")\nend"
] | [
"0.85889745",
"0.8385649",
"0.8339667",
"0.8332656",
"0.82483995",
"0.8244456",
"0.82370883",
"0.8107916",
"0.7957297",
"0.7950305",
"0.7928797",
"0.7904246",
"0.7896411",
"0.78897744",
"0.7872509",
"0.7835217",
"0.7814281",
"0.78140986",
"0.77419764",
"0.77310944",
"0.7715916",
"0.76819485",
"0.7672186",
"0.76565135",
"0.7655049",
"0.7640915",
"0.75935864",
"0.7560993",
"0.7542265",
"0.75288284",
"0.75141233",
"0.7422293",
"0.7402667",
"0.7391216",
"0.73378575",
"0.73313904",
"0.72910804",
"0.72805005",
"0.72690445",
"0.7262885",
"0.72611475",
"0.7258177",
"0.72354",
"0.72198486",
"0.71801835",
"0.7168386",
"0.71565616",
"0.7142177",
"0.7131454",
"0.71191585",
"0.7119001",
"0.70924383",
"0.7087804",
"0.7079541",
"0.7070904",
"0.7065182",
"0.7053629",
"0.7050567",
"0.7028231",
"0.70177317",
"0.70118487",
"0.70118487",
"0.69847625",
"0.6970201",
"0.6959712",
"0.6959022",
"0.6951557",
"0.69427216",
"0.69424164",
"0.69372547",
"0.69368637",
"0.6924175",
"0.6919269",
"0.68876135",
"0.68851995",
"0.6853891",
"0.68498915",
"0.68281984",
"0.68264043",
"0.6816256",
"0.68053097",
"0.68028665",
"0.68001765",
"0.6799174",
"0.6782318",
"0.6776891",
"0.6765395",
"0.67497194",
"0.6744562",
"0.6743084",
"0.67371655",
"0.6731754",
"0.6716497",
"0.6702016",
"0.6701846",
"0.66991836",
"0.6696879",
"0.6695602",
"0.6683401",
"0.66610515",
"0.6646233"
] | 0.0 | -1 |
does it return 'true' | def test_true
assert_equal(true, winning_numbers(4,[1,2,3,4]))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def success?() end",
"def result?\n true\n end",
"def check ; true ; end",
"def test?\n false\n end",
"def success?\n return true\n end",
"def result?\n false\n end",
"def test?\n true\n end",
"def success?(*) end",
"def success?\n got.equal?(true)\n end",
"def ok?\n return @ok\n end",
"def to_bool() true end",
"def ok?\n @ok\n end",
"def success?\n got.equal?(true)\n end",
"def evaluate?\n false\n end",
"def evaluate?\n false\n end",
"def success?()\n result != false\n end",
"def success?\n end",
"def tested?\n @tested\n end",
"def aye?\n true\n end",
"def expected?\n false\n end",
"def true \n \"true\" \n end",
"def ok? \n @funct == nil ? (return false) : (return true)\n end",
"def ok?\n @result.retval == 0\n end",
"def truth\n\t\t\t\"You can't handle the truth\" ; true\n\t\tend",
"def value?(value) true end",
"def success?\n true\n end",
"def valid?\r\n return true\r\n end",
"def truth?\n truth\n end",
"def ==(*)\n true\n end",
"def ok?\n @ok\n end",
"def passed?\n\t\t\t@passed\n\t\tend",
"def qwerty\n\t\tfalse\n\tend",
"def success?\n @success == true\n end",
"def check!\n true\n end",
"def entire?\n entire\n end",
"def stand\r\n return true\r\n end",
"def true?\n self == true\n end",
"def test; true; end",
"def match\n true\n end",
"def success?\n false\n end",
"def success?\n false\n end",
"def equal?(p0) end",
"def test_truth\n end",
"def result_to_get?\n if not @result.nil?\n if @result.downcase == 'true'\n return true\n else\n return false\n end\n else\n return false\n end\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def basic?\n false\n end",
"def alto?\n @cr[0xb][7] == 1\n end",
"def ordinary?\n raise \"Not implemented yet\"\n end",
"def do_pigs_fly?\n return true,false\nend",
"def trueish?\n %w(1 t).include? self\n end",
"def real?\n true\n end",
"def always_true\n true\n end",
"def match?\n false\n end",
"def simple?\n true\n end",
"def made?\n result >= 0\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def value?(p0) end",
"def passed?\n @passed == true\n end",
"def to_bool() false end",
"def success?\n !error\n end",
"def delicious?\n\t\treturn true\n\tend",
"def nd?\n true\n end",
"def a\n return true\nend",
"def single_value?\n return false\n end",
"def ai?\n\ttrue\n end",
"def passed?\n return @test_passed\n end",
"def working?\n true\n end",
"def working?\n true\n end",
"def success?\n type == :ok\n end"
] | [
"0.74962187",
"0.7423751",
"0.7372601",
"0.73342854",
"0.7276631",
"0.7243044",
"0.72150457",
"0.70859176",
"0.70450646",
"0.69838965",
"0.69821954",
"0.6960472",
"0.695637",
"0.6946914",
"0.6946914",
"0.6932129",
"0.6924612",
"0.6914291",
"0.69130504",
"0.69049275",
"0.689034",
"0.6879902",
"0.68774784",
"0.6861349",
"0.6845365",
"0.6844579",
"0.68193007",
"0.68184805",
"0.68162864",
"0.67913276",
"0.6789086",
"0.6787761",
"0.6775025",
"0.6772011",
"0.6766454",
"0.6762465",
"0.67611885",
"0.67530394",
"0.6738817",
"0.67381334",
"0.67381334",
"0.67329055",
"0.67300224",
"0.6726915",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.67245233",
"0.6713054",
"0.6700775",
"0.6691174",
"0.66892505",
"0.6685869",
"0.6677398",
"0.6677244",
"0.66770923",
"0.6673694",
"0.667051",
"0.66660917",
"0.66660917",
"0.66660917",
"0.66660917",
"0.66660917",
"0.66485274",
"0.6639703",
"0.6637221",
"0.66340554",
"0.66320187",
"0.66132855",
"0.6610218",
"0.66039926",
"0.6600888",
"0.65982044",
"0.65912265",
"0.65912265",
"0.65856016"
] | 0.0 | -1 |
def select_category_from_projects "SELECT category FROM projects;" end Make sure each ruby method returns a string containing a valid SQL statement. | def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name
"SELECT projects.title, sum(pledges.amount) FROM projects INNER JOIN pledges on pledges.project_id=projects.id group by pledges.project_id ORDER BY projects.title ASC"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_category_from_projects\n\"SELECT category FROM projects;\"\nend",
"def selects_the_category_names_and_pledge_amounts_of_all_pledges_in_the_music_category\n\"SELECT projects.category, pledges.amount\nFROM pledges\nINNER JOIN projects\nON projects.id = pledges.project_id\nWHERE projects.category = 'music';\n\"\nend",
"def current_categories(db)\r\n\tretrieve_categories = '\r\n\tSELECT name FROM categories'\r\n\tcategories = db.execute(retrieve_categories)\r\nend",
"def selects_the_category_name_and_the_sum_total_of_the_all_its_pledges_for_the_books_category\n\"SELECT projects.category, SUM(pledges.amount)\nFROM pledges\nINNER JOIN projects\nON pledges.project_id = projects.id \nWHERE projects.category = 'books';\"\nend",
"def selects_the_category_name_and_the_sum_total_of_the_all_its_pledges_for_the_books_category\n\"SELECT Projects.category, SUM(Pledges.amount) FROM Projects JOIN Pledges ON Pledges.project_id = Projects.id WHERE Projects.category = 'books';\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"Write your SQL query Here\"\nend",
"def categories()\n db = connect()\n db.execute('SELECT * FROM categories')\n end",
"def category()\n sql = \"SELECT * FROM categories WHERE id = $1 ORDER BY name;\"\n values = [@category_id]\n sql_result = SqlRunner.run(sql, values)\n return Category.new(sql_result[0])\n end",
"def get_category_name(category_id)\n db = SQLite3::Database.new \"#{$script_dir}/cfps.db\"\n category = db.get_first_value(\"select name from category where id = ?\", [category_id])\n\n return categor\nend",
"def projects\n where(:_type => ProjectCategory.name)\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n \"Write your SQL query Here\"\n \"SELECT projects.title, SUM(pledges.amount)\n FROM projects\n INNER JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY projects.title ORDER BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"Write your SQL query Here\"\n \"SELECT projects.title, SUM(amount) FROM projects\n INNER JOIN pledges ON project_id = projects.id\n GROUP BY title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT title, SUM(amount)\nFROM projects\nINNER JOIN pledges\nON projects.id = pledges.project_id\nGROUP BY title\nORDER BY title\"\n\n# FROM owners\n# INNER JOIN cats_owners\n# ON owners.id = cats_owners.owner_id\n# JOIN cats ON cats_owners.cat_id = cats.id\n# WHERE cats_owners.owner_id = 2;\n\nend",
"def current_categorized_expenses(db, user_name)\r\n\tretrieve_categorized_expenses = '\r\n\tSELECT categories.name, amount FROM expenses\r\n\tJOIN users ON expenses.user_id = users.id\r\n\tJOIN categories ON expenses.category_id = categories.id\r\n\tWHERE users.name = ?'\r\n\tcategorized_expenses = db.execute(retrieve_categorized_expenses, [user_name])\r\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"Write your SQL query Here\"\n\"SELECT projects.title, SUM(pledges.amount) FROM projects INNER JOIN pledges ON projects.id = pledges.project_id GROUP BY(projects.title) ;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n sql = <<-SQL\n SELECT projects.title, SUM(pledges.amount) FROM projects JOIN pledges ON pledges.project_id = projects.id GROUP BY projects.title;\n SQL\n\nend",
"def getCategories(_, _, _)\n @db.categories\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n <<-SQL\n SELECT projects.title , sum(pledges.amount)\n FROM projects\n INNER JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY pledges.project_id\n ORDER BY projects.title\n SQL\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"Write your SQL query Here\"\n \n\"SELECT projects.title, SUM(amount) \nFROM pledges \nINNER JOIN projects \nON pledges.project_id = projects.id GROUP BY projects.title;\"\nend",
"def category(id)\n db = connect()\n return db.execute('SELECT Id,Title FROM discussions WHERE CatId=?', id), db.execute('SELECT * FROM categories WHERE Id=?', id)\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"Write your SQL query Here\"\n \"SELECT projects.title, SUM(pledges.amount) FROM projects INNER JOIN pledges ON pledges.project_id = projects.id GROUP BY projects.title ORDER BY title\"\nend",
"def list_projects # :nologin:\n query = create_query(:Project, :all, :by => :title)\n show_selected_projects(query)\n end",
"def get_category_id(category)\n db = SQLite3::Database.new \"#{$script_dir}/cfps.db\"\n category_id = db.get_first_value(\"select id from category where name = ?\", [category])\n\n return category_id\nend",
"def select(db); end",
"def select(db); end",
"def get_records_for_category categ\n if categ.nil? or categ == \"\"\n #return @records\n get_data \"select * from todo\"\n else\n #return @records.select { |row| row[0] == categ }\n get_data \"select * from todo where categ = '#{categ}' \"\n end\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n <<-SQL \n SELECT projects.title, SUM(pledges.amount)\n FROM projects \n INNER JOIN pledges on projects.id = pledges.project_id \n GROUP BY projects.title\n ORDER BY projects.title\n SQL\nend",
"def project_statement\n project_clauses = []\n active_subprojects_ids = []\n\n active_subprojects_ids = project.descendants.active.map(&:id) if project\n if active_subprojects_ids.any?\n if has_filter?(\"subproject_id\")\n case operator_for(\"subproject_id\")\n when '='\n # include the selected subprojects\n ################\n # Smile specific : [project.id] + removed\n ids = values_for(\"subproject_id\").map(&:to_i)\n project_clauses << \"#{Project.table_name}.id IN (%s)\" % ids.join(',')\n when '!'\n # exclude the selected subprojects\n\n ################\n # Smile specific : [project.id] + removed\n ids = active_subprojects_ids - values_for(\"subproject_id\").map(&:to_i)\n project_clauses << \"#{Project.table_name}.id IN (%s)\" % ids.join(',')\n when '!*'\n # main project only\n project_clauses << \"#{Project.table_name}.id = %d\" % project.id\n else\n # all subprojects\n project_clauses << \"#{Project.table_name}.lft >= #{project.lft} AND #{Project.table_name}.rgt <= #{project.rgt}\"\n end\n elsif Setting.display_subprojects_issues?\n project_clauses << \"#{Project.table_name}.lft >= #{project.lft} AND #{Project.table_name}.rgt <= #{project.rgt}\"\n else\n project_clauses << \"#{Project.table_name}.id = %d\" % project.id\n end\n elsif project\n project_clauses << \"#{Project.table_name}.id = %d\" % project.id\n end\n project_clauses.any? ? project_clauses.join(' AND ') : nil\n end",
"def select(sql, name = nil)\n raise NotImplementedError, \"select is an abstract method\"\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n<<-SQL\n SELECT projects.title, SUM(pledges.amount)\n FROM projects\n JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY projects.title;\nSQL\nend",
"def index\n\n # @sql = \"Projects.name ILIKE '#{'%'+params[:name]+'%'}' \" if params[:name].present?\n @sql = params[:name].present? ? \"Projects.name ILIKE '#{'%'+params[:name]+'%'}' \" : \"Projects.name ILIKE '%' \"\n @sql += \"OR Projects.description ILIKE '#{'%'+params[:name]+'%'}' \" if params[:name].present?\n\n @sql += \"and Projects.category ILIKE '#{'%'+params[:categorysdigital]+'%'}' \" if params[:categorysdigital].present?\n if params[:categorysdigital].present?\n @sql += \"or Projects.category ILIKE '#{'%'+params[:categorysmarketing]+'%'}' \" if params[:categorysmarketing].present?\n else\n @sql += \"And Projects.category ILIKE '#{'%'+params[:categorysmarketing]+'%'}' \" if params[:categorysmarketing].present?\n end\n\n if params[:categorysdigital].present? || params[:categorysmarketing].present?\n @sql += \"or Projects.category ILIKE '#{'%'+params[:categorysdesign]+'%'}' \" if params[:categorysdesign].present?\n else\n @sql += \"And Projects.category ILIKE '#{'%'+params[:categorysdesign]+'%'}' \" if params[:categorysdesign].present?\n end\n\n @sql += \"and Projects.progress = #{params[:progresspropose].to_i} \" if params[:progresspropose].present?\n if params[:progresspropose].present?\n @sql += \"or Projects.progress = #{params[:progressselected].to_i} \" if params[:progressselected].present?\n else\n @sql += \"and Projects.progress = #{params[:progressselected].to_i} \" if params[:progressselected].present?\n end\n\n if params[:progressselected].present?\n @sql += \"or Projects.progress = #{params[:progressclose].to_i} \" if params[:progressclose].present?\n else\n @sql += \"and Projects.progress = #{params[:progressclose].to_i} \" if params[:progressclose].present?\n end\n\n # @sql += \"ORDER progress\"\n @projects = Project.where(@sql).order(:progress)\n @count = @projects.count\n @count_tt = Project.count\n end",
"def projects_countries(site, category_id = nil)\n if category_id.present? && category_id.to_i > 0\n if site.navigate_by_cluster?\n category_join = \"inner join clusters_projects as cp on cp.project_id = p.id and cp.cluster_id = #{category_id}\"\n else\n category_join = \"inner join projects_sectors as pse on pse.project_id = p.id and pse.sector_id = #{category_id}\"\n end\n end\n\n Country.find_by_sql(\n<<-SQL\nselect c.id,c.name,count(ps.*) as count from countries as c\n inner join countries_projects as pr on c.id=pr.country_id\n inner join projects as p on p.id=pr.project_id\n inner join projects_sites as ps on p.id=ps.project_id and ps.site_id=#{site.id}\n #{category_join}\n where p.primary_organization_id=#{self.id}\n group by c.id, c.name order by count DESC\nSQL\n ).map do |r|\n [r, r.count.to_i]\n end\n end",
"def projects_countries(site, category_id = nil)\n if category_id.present?\n if site.navigate_by_cluster?\n category_join = \"inner join clusters_projects as cp on cp.project_id = p.id and cp.cluster_id = #{category_id}\"\n else\n category_join = \"inner join projects_sectors as pse on pse.project_id = p.id and pse.sector_id = #{category_id}\"\n end\n end\n\n Country.find_by_sql(\n<<-SQL\nselect c.id,c.name,count(ps.*) as count from countries as c\n inner join countries_projects as pr on c.id=pr.country_id\n inner join projects as p on p.id=pr.project_id and (p.end_date is null OR p.end_date > now())\n inner join projects_sites as ps on p.id=ps.project_id and ps.site_id=#{site.id}\n #{category_join}\n where p.primary_organization_id=#{self.id}\n group by c.id, c.name order by count DESC\nSQL\n ).map do |r|\n [r, r.count.to_i]\n end\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM pledges\nINNER JOIN projects \nON pledges.project_id = projects.id\nGROUP BY project_id\nORDER BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n# Select projects title column and the sum of the pledges amount column\n# from the projects database,\n# join the pledges (Join table)\n# with projects.id and the pledges project id. Match these numbers\n# Group the tables together by Projects title and then\n# sort by projects.title\n\"SELECT Projects.title, SUM(Pledges.amount)\n FROM Projects\n JOIN Pledges\n ON Projects.id = Pledges.project_id\n GROUP BY Projects.title\n ORDER BY Projects.title;\n\"\nend",
"def get_project_name(id)\n con = PG::Connection.connect(\"localhost\",5432,nil,nil,\"aaa\",\"admin\")\n sql = \"SELECT name \"\n sql += \"FROM projects \"\n sql += \"WHERE id='#{id}' \"\n res = con.exec(sql)\n con.close\n name = \"NA\"\n name = res[0]['name'] if res.num_tuples > 0\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n<<-SQL\n SELECT DISTINCT title ,SUM(amount) FROM projects INNER JOIN pledges ON projects.id = pledges.project_id\n GROUP BY projects.title\n SQL\nend",
"def sql\n <<-SQL\n -- Search learning paths\n SELECT DISTINCT\n c.id,\n c.name,\n c.course_code,\n c.settings,\n cc.content,\n 'learning_path' AS content_type,\n c.id AS learning_path_id,\n 0 AS learning_objective_id\n FROM courses c\n LEFT OUTER JOIN fearless_taggings ts\n ON ts.taggable_id = c.id AND ts.taggable_type = 'LearningPath'\n LEFT OUTER JOIN fearless_tags t\n ON t.id = ts.tag_id\n LEFT OUTER JOIN fearless_custom_contents cc\n ON cc.contentable_id = c.id AND cc.contentable_type = 'LearningPath'\n WHERE 0=0\n #{construct_account_clause}\n #{construct_course_worklow_clause}\n #{construct_name_sql}\n #{construct_all_tags_search('t', 'name')}\n UNION ALL\n -- Search learning objectives\n SELECT DISTINCT\n cm.id,\n cm.name,\n c.course_code,\n c.settings,\n cc.content,\n 'learning_objective' AS content_type,\n cm.context_id::bigint AS learning_path_id,\n cm.id::bigint AS learning_objective_id\n FROM context_modules cm\n INNER JOIN courses c\n ON c.id = cm.context_id\n AND cm.context_type = 'Course'\n LEFT OUTER JOIN fearless_taggings ts\n ON ts.taggable_id = cm.id AND ts.taggable_type = 'LearningObjective'\n LEFT OUTER JOIN fearless_tags t\n ON t.id = ts.tag_id\n LEFT OUTER JOIN fearless_custom_contents cc\n ON cc.contentable_id = cm.id AND cc.contentable_type = 'LearningObjective'\n WHERE 0=0\n #{construct_account_clause}\n #{construct_generic_workflow_clause('cm')}\n #{construct_name_sql('cm')}\n #{construct_all_tags_search('t', 'name')}\n UNION ALL\n -- Search learning learning_event\n SELECT DISTINCT\n ct.id,\n ct.title AS name,\n c.course_code,\n c.settings,\n cc.content,\n 'learning_event' AS content_type,\n ct.context_id::bigint AS learning_path_id,\n ct.context_module_id::bigint AS learning_objective_id\n FROM content_tags ct\n INNER JOIN courses c\n ON c.id = ct.context_id\n AND ct.context_type = 'Course'\n LEFT OUTER JOIN fearless_taggings ts\n ON ts.taggable_id = ct.id AND ts.taggable_type = 'LearningEvent'\n LEFT OUTER JOIN fearless_tags t\n ON t.id = ts.tag_id\n LEFT OUTER JOIN fearless_custom_contents cc\n ON cc.contentable_id = ct.id AND cc.contentable_type = 'LearningEvent'\n WHERE 0=0\n #{construct_account_clause}\n #{construct_generic_workflow_clause('ct')}\n #{construct_name_sql('ct', 'title')}\n #{construct_all_tags_search('t', 'name')}\n SQL\n end",
"def get_category_name\n Category.find(:first, :select => ['name'],:conditions=>['has_complexity=?',false]).name rescue ''\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"\nSELECT \nProjects.title,\nSUM(Pledges.amount)\nFROM Pledges\nINNER JOIN Projects\nON Pledges.project_id = Projects.id\nGROUP BY Projects.title\nORDER BY Projects.title\n\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT Projects.title, SUM(pledges.amount) \nFROM projects \nJOIN pledges \nON Projects.id = pledges.project_id \nGROUP BY title\"; \nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM projects\nINNER JOIN pledges \nON projects.id=pledges.project_id\nGROUP BY projects.id\nORDER BY projects.title;\"\nend",
"def makeQueryTableAll(tableName)\n #sql = \"SELECT * FROM [\" << tableName << \"]\"\n sql = \"SELECT * FROM [\" << tableName << \"]\" << \" WHERE id < 3\"\n #puts(sql) #debug\n return sql\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"SELECT projects.title, sum_pledges FROM (SELECT pledges.project_id, SUM(pledges.amount) AS sum_pledges FROM pledges GROUP BY pledges.project_id) INNER JOIN projects ON projects.id = project_id ORDER BY projects.title\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n<<-SQL\nSELECT projects.title, SUM(pledges.amount) \nFROM projects \nINNER JOIN pledges on projects.id = pledges.project_id\nGROUP BY (pledges.project_id)\nORDER BY projects.title;\nSQL\nend",
"def category_totals(db, user_name, number)\r\n\tretrieve_totals = '\r\n\tSELECT categories.name, SUM(amount) FROM expenses\r\n\tJOIN users ON expenses.user_id = users.id\r\n\tJOIN categories ON expenses.category_id = categories.id\r\n\tWHERE categories.id = ?\r\n\tAND users.name = ?'\r\n\ttotals = db.execute(retrieve_totals, [number, user_name])[0]\r\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\r\n\"SELECT title, SUM(pledges.amount) FROM projects\r\nJOIN pledges ON projects.id = pledges.project_id\r\nGROUP BY projects.id\r\nORDER BY title ASC\"\r\nend",
"def add_category(db, category)\r\n\tnew_category = '\r\n\tINSERT INTO categories (name)\r\n\tVALUES (?)'\r\n\tdb.execute(new_category, [category])\r\nend",
"def select_category\n #Parbauda vai ekrans ir redzams\n @screens.screen_create_filter.visible?\n #Pievieno kategoriju no filtra datiem\n @screens.screen_create_filter.select_row(@filter_data.category)\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"Select title, amount from projects, pledges where projects.id = pledges.id order by title ASC;\"\nend",
"def projects_countries(site, category_id = nil, organization_id = nil, location_id = nil)\n if category_id.present? && category_id.to_i > 0\n if site.navigate_by_cluster?\n category_join = \"inner join clusters_projects as cp on cp.project_id = p.id and cp.cluster_id = #{category_id}\"\n else\n category_join = \"inner join projects_sectors as pse on pse.project_id = p.id and pse.sector_id = #{category_id}\"\n end\n end\n\n if organization_id.present? && organization_id.to_i > 0\n organization_filter = \"and p.primary_organization_id = #{organization_id}\"\n end\n\n if location_id.present?\n location_filter = \"and c.id IN (#{location_id})\"\n end\n\n Country.find_by_sql(\n<<-SQL\nselect c.id,c.name,count(ps.*) as count from countries as c\n inner join countries_projects as pr on c.id=pr.country_id #{location_filter}\n inner join projects as p on p.id=pr.project_id and (p.end_date is null OR p.end_date > now()) #{organization_filter}\n inner join projects_sites as ps on p.id=ps.project_id and ps.site_id=#{site.id}\n inner join donations as dn on dn.project_id = p.id\n #{category_join}\n where dn.donor_id = #{self.id}\n group by c.id, c.name order by count DESC\nSQL\n ).map do |r|\n [r, r.count.to_i]\n end\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT projects.title, SUM(pledges.amount) FROM pledges INNER JOIN projects ON projects.id=pledges.project_id GROUP BY projects.title;\"\n## FROM - where are they talking to each other - where is the scotch tape\nend",
"def select(componentName, text, componentInfo=nil)\n $marathon.select(ComponentId.new(componentName, componentInfo), text.to_s)\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n \"SELECT projects.title,\n SUM(pledges.amount)\n FROM pledges\n INNER JOIN projects\n ON projects.id = pledges.project_id\n GROUP BY projects.title;\"\n\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, \nSUM(pledges.amount) \nFROM projects\nJOIN pledges ON pledges.project_id = projects.id\nGROUP BY projects.title\nORDER BY projects.title ASC;\"\nend",
"def select_all(sql, name = nil) end",
"def select\n @pds_projects = PdsProject.includes(:company).where('ProjectID in (?)', PROJECT_LIST)\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, sum(amount) AS pledge_amount\nFROM pledges\nJOIN projects\nWHERE pledges.project_id = projects.id\nGROUP BY project_id\nORDER BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n <<-SQL\n SELECT\n title, sum(amount)\n FROM\n projects\n JOIN pledges\n ON pledges.project_id = projects.id\n GROUP BY\n title\n ORDER BY\n title\n SQL\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount )\nFROM projects \nJOIN pledges\nON projects.id = pledges.project_id \nGROUP BY projects.title \nORDER BY projects.title \";\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n \"SELECT projects.title,(SELECT SUM(pledges.amount))\n FROM projects\n INNER JOIN pledges ON projects.id = pledges.project_id\n GROUP BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n \"SELECT projects.title, sum(pledges.amount)\n FROM projects\n INNER JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY pledges.project_id\n ORDER BY projects.title ASC;\n \"\nend",
"def db_fetch\n \"SELECT *\" + from_table_where + sql_match_conditions\n end",
"def get_category(cate, limitl, limitr)\n return Product.find_by_sql(\"select * from products where tag like '%#{cate}%' order by id limit #{limitl}, #{limitr}\")\n end",
"def select_project\n @projects = Project.find(:all)\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT projects.title, SUM(pledges.amount) FROM pledges INNER JOIN projects ON projects.id = pledges.project_id GROUP BY projects.title ORDER BY projects.title \"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT projects.title, SUM(pledges.amount)\n FROM projects\n JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT title, SUM(amount)\nFROM projects\nINNER JOIN pledges\nON projects.id = pledges.project_id\nGROUP BY projects.title\nORDER BY projects.title;\"\nend",
"def sql_statement_find\n @sql_statement_find ||=\n <<-SQL\n SELECT\n applications.id AS id,\n teams.name AS team_name,\n projects.name AS project_name,\n (application_data -> :project_id)::int AS project_id,\n application_data -> :project_plan AS project_plan,\n application_data -> :why_selected_project AS why_selected_project,\n application_data -> :signed_off_at AS signed_off_at,\n (application_data -> :signed_off_by)::int AS signed_off_by,\n application_data -> :mentor_fav AS mentor_fav,\n CASE WHEN :project_id::text = 'project1_id' THEN 1 ELSE 2 END AS choice,\n hstore_to_json_loose(slice(application_data, ARRAY[:student0_attrs])) AS student0,\n hstore_to_json_loose(slice(application_data, ARRAY[:student1_attrs])) AS student1\n FROM applications\n INNER JOIN teams\n ON teams.id = applications.team_id\n INNER JOIN projects\n ON projects.id::text = applications.application_data -> :project_id\n WHERE (application_data -> :project_id)::int IN (:project_ids)\n AND applications.season_id = :season_id\n AND applications.id = :id;\n SQL\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT Projects.title, SUM(Pledges.amount)\n FROM projects\n JOIN pledges\n ON Projects.id = Pledges.project_id\n GROUP BY project_id\n ORDER BY Projects.title\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\n FROM pledges\n INNER JOIN projects\n ON pledges.project_id = projects.id\n GROUP BY projects.title\n ORDER BY projects.title\n\"\nend",
"def select(componentName, text, componentInfo=nil)\n $marathon.select(ComponentId.new(componentName, componentInfo), text.to_s)\nend",
"def sql\n @sql ||= begin\n bind_params = []\n 1.upto(selector_keys.length + setter_keys.length) { |i| bind_params << \"$#{i}\" }\n %{SELECT #{name}(#{bind_params.join(', ')})}\n end\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM projects\nJOIN pledges\nON projects.id = pledges.project_id\nGROUP BY projects.title;\"\nend",
"def getCat \n\t\tputs ''\n\t\tputs 'Fetching categories . . '\n\t\t@page.css('ul.dropdown li a').each do |cat|\n\t\t\tarr=[]\n\t\t\tarr.push cat.text\n\t\t\tarr.push cat['href']\n\t\t\t@arr_cat.push arr\n\t\t\tprint '. '\n\t\tend\n\t\ti=0\n\t\t@arr_cat.each do |pair|\n\t\t\t@db.execute 'insert into category values (?, ? ,?)', i, pair[0], pair[1]\n \t\t\ti +=1\n \t\tend\n\tend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM (pledges.amount)\nFROM projects\nINNER JOIN pledges\nON projects.id = pledges.project_id\nGROUP BY title\nORDER BY title ASC;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT Projects.title, SUM(Pledges.amount) FROM Projects JOIN Pledges ON Pledges.project_id = Projects.id GROUP BY Projects.title;\"\nend",
"def add_project_name_to_jql jql_string\n unless jql_string.empty?\n jql_string.insert(0, \"project=#{@project} AND \")\n else\n \"project=#{@project}\"\n end\n end",
"def search(category, query_term)\nresult = @conn.exec(\"SELECT * FROM students WHERE #{category} = '#{query_term}';\");\n puts student\n result.each do |student|\n puts \"#{k}: #{v}\"\n end\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT title, SUM(amount) FROM pledges INNER JOIN projects ON projects.id = pledges.project_id GROUP BY projects.id ORDER BY title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT projects.title, SUM(pledges.amount)\n FROM projects\n INNER JOIN pledges\n ON pledges.project_id = projects.id\n GROUP BY(projects.title);\"\nend",
"def show_categories(html_dsl)\r\n categories = Category.where(\"user_id = #{session[:user_id]} and category_id is null\").order('name ASC')\r\n category_html = create_category_table(categories)\r\n html_dsl.inject(category_html)\r\n end",
"def show_categories(html_dsl)\r\n categories = Category.where(\"user_id = #{session[:user_id]} and category_id is null\").order('name ASC')\r\n category_html = create_category_table(categories)\r\n html_dsl.inject(category_html)\r\n end",
"def selects_all_female_bears_return_name_and_age\n <<-SQL \n SELECT \n bears.name, \n bears.age \n FROM bears \n WHERE sex='F';\n SQL\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n \"SELECT projects.title, SUM(pledges.amount) FROM projects\n JOIN pledges ON projects.id = pledges.project_id\n GROUP BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n \"SELECT projects.title, SUM(pledges.amount) FROM projects INNER JOIN pledges ON pledges.project_id=projects.id GROUP BY projects.title ORDER BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM projects\nINNER JOIN pledges\nON projects.id = pledges.project_id GROUP BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n # SELECT titles, amounts FROM projects, pledges ORDER BY titles ASC\n #SELECT titles.projects, pledges.amounts ORDER BY titles ASC\n \"SELECT projects.title, SUM(pledges.amount) FROM projects\n JOIN pledges \n ON pledges.project_id = projects.id \n GROUP BY(pledges.project_id)\n ORDER BY projects.title ASC\n \";\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n \"SELECT projects.title, SUM(pledges.amount)\n FROM projects\n JOIN pledges ON pledges.project_id = projects.id\n GROUP BY title\n ORDER BY title ASC;\"\nend",
"def sql_statement_all\n @sql_statement_all ||=\n <<-SQL\n SELECT\n applications.id AS id,\n teams.name AS team_name,\n projects.name AS project_name,\n (application_data -> :project_id)::int AS project_id,\n application_data -> :signed_off_at AS signed_off_at,\n (application_data -> :signed_off_by)::int AS signed_off_by,\n application_data -> :mentor_fav AS mentor_fav,\n CASE WHEN :project_id::text = 'project1_id' THEN 1 ELSE 2 END AS choice\n FROM applications\n INNER JOIN teams\n ON teams.id = applications.team_id\n INNER JOIN projects\n ON projects.id::text = applications.application_data -> :project_id\n WHERE (application_data -> :project_id)::int IN (:project_ids)\n AND applications.season_id = :season_id;\n SQL\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount) FROM projects INNER JOIN pledges ON projects.id = pledges.project_id GROUP BY projects.title ORDER BY projects.title ASC;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"select\nprojects.title,\nsum(pledges.amount) as sum_all_pledges\nfrom projects\ninner join pledges\non projects.id = pledges.project_id\ngroup by projects.title\norder by projects.title;\n\"\nend",
"def category_selection(category)\n category = Public_apis.find_by_name(category)\n #goes over list item array . find method to find item\n\n \n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n \"SELECT projects.title, SUM(pledges.amount) \n FROM projects\n JOIN pledges\n ON pledges.project_id = projects.id\n GROUP BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM projects\nLEFT JOIN pledges\nON projects.id=pledges.project_id\nGROUP BY projects.title\nORDER BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n #SELECT title, SUM(quantity) FROM groceries GROUP BY aisle ORDER BY SUM(quantity);\n\n \"SELECT projects.title, sum( pledges.amount)\nFROM projects\nJOIN pledges\nwhere projects.id=pledges.project_id\ngroup by projects.title order by projects.title\n;\"\n\nend",
"def frey_example\n # Find all the cats that are the same color as the cat named 'Freyja'.\n # Including 'Freyja' in the results.\n # DO NOT USE A SUBQUERY\n\n execute(<<-SQL)\n SELECT\n color_cats.name\n FROM\n cats AS freyja_cats\n JOIN\n cats AS color_cats ON freyja_cats.color = color_cats.color\n WHERE\n freyja_cats.name = 'Freyja';\n SQL\nend",
"def select &blck\n @projects.select(&blck)\n end",
"def select &blck\n @projects.select(&blck)\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT p.title, SUM(pl.amount) FROM pledges pl INNER JOIN projects p ON pl.project_id = p.id GROUP BY pl.project_id ORDER BY p.title\"\nend"
] | [
"0.9198005",
"0.7067772",
"0.69905335",
"0.66503316",
"0.66215897",
"0.65129244",
"0.6485903",
"0.6323661",
"0.6060154",
"0.59388006",
"0.59372574",
"0.59352744",
"0.5899834",
"0.58821833",
"0.58694905",
"0.58531743",
"0.5852905",
"0.58394325",
"0.5818256",
"0.5783734",
"0.5781103",
"0.56976104",
"0.5696302",
"0.56917125",
"0.56917125",
"0.56897366",
"0.56817013",
"0.56785035",
"0.5635369",
"0.56272054",
"0.5618919",
"0.5617283",
"0.5613578",
"0.5588245",
"0.5581083",
"0.5573565",
"0.5572224",
"0.5572036",
"0.5567436",
"0.55431384",
"0.5539766",
"0.5526605",
"0.54874116",
"0.5479447",
"0.5478142",
"0.5477179",
"0.547482",
"0.54652953",
"0.54616153",
"0.5458757",
"0.5449138",
"0.5446543",
"0.5434867",
"0.54297477",
"0.54289407",
"0.54289323",
"0.5423611",
"0.5422225",
"0.5421358",
"0.5414736",
"0.540685",
"0.5392109",
"0.53859663",
"0.5384549",
"0.538104",
"0.53808844",
"0.5380002",
"0.5372036",
"0.5361571",
"0.53507704",
"0.5350323",
"0.53502434",
"0.5348631",
"0.5346829",
"0.5341254",
"0.5339656",
"0.5331514",
"0.53309333",
"0.5321829",
"0.53208303",
"0.53183997",
"0.53112626",
"0.53112626",
"0.52998656",
"0.529545",
"0.52898204",
"0.5285668",
"0.5283837",
"0.5283186",
"0.5283078",
"0.52823526",
"0.5275229",
"0.52730757",
"0.52725226",
"0.52673817",
"0.52635866",
"0.52593064",
"0.52575153",
"0.52575153",
"0.5253907"
] | 0.53057444 | 83 |
GET /bingos or /bingos.json | def index
@bingos = Bingo.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_brandings\n request :get, \"/v3/brandings.json\"\n end",
"def index\n @brags = Brag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brags }\n end\n end",
"def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend",
"def do_GET(request, response)\n status = 200\n content_type = \"text/html\"\n body = \"bender version #{BENDER_VERSION}\"\n body += \"\\n\"\n\n response.status = status\n response['Content-Type'] = content_type\n response.body = body\n response.body = body\n end",
"def list_all_aos_version_boxes(args = {}) \n get(\"/aosversions.json/aosversionbox\", args)\nend",
"def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend",
"def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend",
"def index\n @shop_section = ShopSection.find_by_short_url(\"brands\")\n @brands = Brand.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brands }\n end\n end",
"def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend",
"def index\n @bot_bingo_numbers = BotBingoNumber.all\n\n respond_to do |format|\n format.html # index.html.erb\n # frommat.json { render json: @bot_bingo_numbers }\n end\n end",
"def get_aos_version_box_by_name(args = {}) \n get(\"/aosversions.json/aosversionbox/name/#{args[:aosVersionBoxName]}\", args)\nend",
"def list\n get('/')\n end",
"def get(path, busca=nil)\n @client.get(path, busca)\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bot_bingo_number }\n end\n end",
"def index\n response = RestClient.get 'http://api.bitvalor.com/v1/order_book.json'\n data = JSON.parse(response.body)[\"bids\"]\n @fox = data.select {|element| element[0] == \"FOX\"}\n @b2u = data.select {|element| element[0] == \"B2U\"}\n @mbt = data.select {|element| element[0] == \"MBT\"}\n end",
"def show\n @verbo = Verbo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verbo }\n end\n end",
"def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend",
"def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end",
"def heros\n get('/hero/')\n end",
"def show\n @bb = Bb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bb }\n end\n end",
"def ambassador(params = {})\n self.class.get('/ambassador/get', params)\n end",
"def get\n start { |connection| connection.request http :Get }\n end",
"def index\n @bottlings = handle_sorting(:bottling, :sku, :wine, :bottle_size)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bottlings }\n end\n end",
"def index\n @bowlers = Bowler.all\n respond_with(@bowlers)\n end",
"def do_get\n Net::HTTP.get(URI.parse(api_url))\n end",
"def get_batterie_by_building\n @battery = Battery.where(building_id: params[:building_id])\n respond_to do |format| \n format.json { render :json => @battery }\n end\n \n end",
"def get(path)\n request = Net::HTTP::Get.new @uri.path+'/'+path\n request.basic_auth @api_key, ''\n request['User-Agent'] = USER_AGENT\n response = @https.request request\n JSON.parse response.body\n end",
"def show\n render \"api/v1/bounties/show\"\n end",
"def get_book(search)\n\trequest_string = \"https://www.googleapis.com/books/v1/volumes?q=#{search.gsub(\" \",\"+\")}\"\n\t\n\tsample_uri = URI(request_string) #opens a portal to the data at that link\n\tsample_response = Net::HTTP.get(sample_uri) #go grab the data in the portal\n\tsample_parsedResponse = JSON.parse(sample_response) #makes data easy to read\n\tsample_parsedResponse[\"items\"]\nend",
"def index\n @biddings = Bidding.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @biddings }\n end\n end",
"def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\nend",
"def getbatteries\n puts params\n buildid = params[\"buildingid\"]\n\n batteries = Battery.where(:building_id => buildid)\n\n puts batteries.inspect\n puts \"#################################################\"\n \n respond_to do |format|\n format.json { render json: batteries }\n end\n end",
"def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end",
"def index\n @kbs = Kb.search(params[:q]).page(params[:page]).order(\"id desc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @kbs }\n end\n end",
"def index\n @boks = Bok.all\n end",
"def info\n get '/'\n end",
"def index\n @bobs = Bob.paginate(:page => params[:page], :order => 'created_at DESC',:per_page => 30)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bobs }\n end\n end",
"def show\n @osoba = Osoba.find(params[:id])\n\n render json: @osoba\n end",
"def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end",
"def index\n @ginasios = Ginasio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ginasios }\n end\n end",
"def get_book_with_api(title)\n uri = URI.parse(URI.encode(\"https://www.googleapis.com/books/v1/volumes?q=#{title}\"))\n service = Books::ApiConnectService.new(uri)\n book_response = service.execute[\"items\"].first[\"volumeInfo\"]\n .select{ |key, value| key == \"title\" || key == \"description\" || key == \"publisher\" || key == \"publishedDate\" || key == \"imageLinks\"}\n @book_info_hash = book_response.inject({}) do |hash, (key, value)|\n if key.underscore == \"image_links\"\n hash[key.underscore] = book_response[\"imageLinks\"][\"smallThumbnail\"]\n else\n hash[key.underscore] = value\n end\n hash\n end\n end",
"def get_bundles(options = nil)\n @client.raw('get', '/content/pages', options)\n end",
"def show\n @boat = Boat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json {render json: @boat}\n end\n end",
"def show\n @bingo = Bingo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bingo }\n end\n end",
"def show\n if @bird\n respond_to do |format|\n format.json { render json: {required: @bird, properties: @bird.properties, families: @bird.families, title: \"POST /birds [request]\", description: \"Get bird by id\",:status => OK }}\n end\n else\n respond_to do |format|\n format.json { render json: {:status => NOT_FOUND} }\n end\n end\n end",
"def get(path, query={})\n request_json :get, path, query\n end",
"def index\n if current_authkey.authkey.eql?(\"#fl0wk27er\")\n @batons = Baton.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @batons }\n end\n elsif current_authkey.authkey.eql?(\"#daneld2130\")\n redirect_to daniel_batons_path\n elsif current_authkey.authkey.eql?(\"#cassaj0105\")\n redirect_to casa_batons_path\n elsif current_authkey.authkey.eql?(\"#hulkh2051\")\n redirect_to hulk_batons_path\n elsif current_authkey.authkey.eql?(\"#genllt5055\")\n redirect_to think_batons_path\n else\n redirect_to root_path\n end\n end",
"def get_all_orders() \n\tputs \"Getting all orders\"\n\tresponse = request_get(\"/api/order\")\n\tputs response.body\nend",
"def get(path, data={})\n http_verb :get, path, data\n end",
"def index\n @bemaps = Bemap.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bemaps }\n end\n end",
"def index\n @per_page_options = %w{ 21 51 99 }\n respond_to do |format|\n format.html # index.html.erb\n format.xml # index.xml.builder\n format.atom # index.atom.builder\n format.json { render :json => ServiceCatalographer::Api::Json.index(\"services\", json_api_params, @services).to_json }\n format.bljson { render :json => ServiceCatalographer::Api::Bljson.index(\"services\", @services).to_json }\n end\n end",
"def show\n @basin = Basin.find(params[:id])\n\n @client = YahooWeather::Client.new \n @response = @client.fetch_by_location('Massingir, Gaza, Mz','c')\n @reponse2 = @client.fetch_by_location('Louis Trichardt, Limpopo, South Africa','c')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @basin }\n\n end\n end",
"def index\n @lobs = Lob.all\n\n render json: @lobs\n end",
"def index\n @brands = Brand.all\n if params[:name]\n \t@brand = Brand.find_by_name(params[:name])\n end\n\n respond_to do |format|\n \tif @brand\n \t\tformat.html { redirect_to @brand }\n \t\tformat.json { render json: @brand }\n \telse\n\t format.html # index.html.erb\n \tformat.json { render json: @brands }\n end\n end\n end",
"def get_aos_version_by_name(args = {}) \n get(\"/aosversions.json/version/#{args[:aosVersionName]}\", args)\nend",
"def api_get(path, params = {})\n api_request(:get, path, :params => params)\n end",
"def index\n @banners = Banner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @banners }\n end\n end",
"def get_aos_version_box_by_id(args = {}) \n get(\"/aosversions.json/aosversionbox/#{args[:aosVersionBoxId]}\", args)\nend",
"def index\n @boms = Bom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @boms }\n end\n end",
"def index\n @baskets = Basket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @baskets }\n end\n end",
"def get(api)\n\t\t\tvalidate_api(api)\n\t\t\tparams = set_default_params(api[:params])\n\t\t\tquery = hash_to_querystring(params)\n\t\t\turl = \"#{api[:path]}?#{query}\"\n\t\t\tresponse = @http.get(url)\n\t\t\tputs \"#{response.code} - #{response.message}: #{api[:path]} \"\n\t\t\tcheck_cookie(response)\n\t\t\treport_error(response)\n\t\t\tresponse\n\t\tend",
"def show\n @boat = Boat.find(params[:id])\n\n render json: @boat\n end",
"def index\n @buses = Bus.order('leaving_from_id')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @buses }\n end\n end",
"def http( *args )\n p http_get( *args )\n end",
"def get_aos_version(args = {}) \n get(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def list_all_tenantcircles_for_a_version_box(args = {}) \n get(\"/aosversions.json/aosversionbox/circles/#{args[:aosVersionBoxId]}\", args)\nend",
"def show\n @bico = Bico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bico }\n end\n end",
"def index\n @birds = Bird.all.to_a\n begin\n respond_to do |format|\n format.json { render json: {items: @birds, description: \"List all visible birds in the registry\", additionalProperties: false, title: \"POST /birds [request]\",:status => OK } }\n end\n rescue => e\n render json: ({:status => INTERNAL_SERVER_ERROR})\n end\n end",
"def index\n @bitacoras = Bitacora.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bitacoras }\n end\n end",
"def index\n @bagtypes = Bagtype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bagtypes }\n end\n end",
"def view_api\n api_string = RestClient.get(\"https://itunes.apple.com/search?term=star+wars&entity=song&attribute=movieTerm\")\n api_hash = JSON.parse(api_string)\n\n end",
"def show\n @bruger = Bruger.find_by_id(current_user.id)\n @onske = Onske.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @onske }\n end\n end",
"def show\n @bottling = Bottling.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bottling }\n end\n end",
"def index\n if params[:title]\n @boats = Boat.where title: params[:title]\n else\n if params[:open_seats]\n @boats = Boat.where open_seats: params[:open_seats]\n else\n @boats = Boat.all\n end\n end\n render json: @boats\n end",
"def view_bleapp\n \tbegin\n \t\tproperty = Property.find(params[:property][:property_id])\n\t\t\t@bleapps = property.bleeapps\n\t\t\tif @bleapps.present?\n\t\t\t\trender :file => 'api/v1/property/view_bleapp'\n\t\t\telse\n\t\t\t\trender_json({\"status\" => \"Fail\", \"message\" => \"No bleapp found\"}.to_json)\n\t\t\tend\n \trescue\n \t \trender_json({\"status\" => \"Fail\", \"message\" => \"Something went wrong.\"}.to_json)\n \tend\n end",
"def index\n @brochures = Brochure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brochures }\n end\n end",
"def info\n get(\"/api-info\")\n end",
"def index\n #@boats = Boat.order(sort_column + ' ' + sort_direction)\n # @boats = Boat.all\n # if params[:search]\n @boats = Boat.search(params[:search])\n # else\n # @boats = Boat.order(sort_column + ' ' + sort_direction)\n # end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @boats }\n end\n end",
"def index\n results = []\n if params[:bbox]\n results = VAFacility.query(bbox: params[:bbox], type: params[:type], services: params[:services])\n end\n resource = Common::Collection.new(::VAFacility, data: results)\n resource = resource.paginate(pagination_params)\n render json: resource.data,\n serializer: CollectionSerializer,\n each_serializer: VAFacilitySerializer,\n meta: resource.metadata\n end",
"def show\n @bowl = Bowl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bowl }\n end\n end",
"def all\n api_get(path)\n end",
"def show\n @kb = Kb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @kb }\n end\n end",
"def GET; end",
"def lws_api_get(path)\n # See also catalog_controller for use of ENV['LWS_...']\n url ||= ENV['LWS_API_URL']\n url ||= \"#{ENV['LWS_CORE_URL']}/api\" if ENV['LWS_CORE_URL']\n \n # http://localhost:8888/api/collections\n resp = Net::HTTP.get_response(URI.parse(\"#{url || 'http://127.0.0.1:8888/api'}#{path}\"))\n result = JSON.parse(resp.body)\n end",
"def get endpoint\n do_request :get, endpoint\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def show\n @borad = Borad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @borad }\n end\n end",
"def index\n @bosses = Boss.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bosses }\n end\n end",
"def call_rest_getlbvstats\n print \"get lb vserver stats\\n\"\n @uri.path = \"/nitro/v1/config/lbvserver/\"\n @request = Net::HTTP::Get.new(@uri)\n @request.basic_auth \"#{@username}\", \"#{@password}\"\n @request.add_field('Content-Type', 'application/vnd.com.citrix.netscaler.lbvserver+json')\n\n Net::HTTP.start(@uri.host, @uri.port) { |http|\n response = http.request(@request)\n\n if response.code == \"200\"\n result = JSON.parse(response.body)\n File.open(\"lbvserver-stats.json\", \"w\") do |file|\n file.write(JSON.pretty_generate(result))\n end\n end\n }\n\n end",
"def index\n bookings = Booking.all\n\n if bookings\n render json: { status: 'SUCCESS', message: 'Successfuly got all bookings', data: bookings }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Something went wrong' }, status: :unprocessable_entity\n end\n end",
"def list_all_shards(args = {}) \n get(\"/shards.json/\", args)\nend",
"def get_json()\n\n http = Net::HTTP.new(STATUS_URI.host, STATUS_URI.port)\n http.use_ssl = false\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Get.new(\"/api/services.json\")\n\n response = http.request(request)\n JSON.parse(response.body)\nend",
"def show\n @bdatabase = Bdatabase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bdatabase }\n end\n end",
"def index\n #Busca Banco\n @bancos = Banco.where(nil) #Inicia Escopo\n @bancos = @bancos.codigo(params[:codigo]) if params[:codigo].present?\n @bancos = @bancos.descricao(params[:descricao]) if params[:descricao].present?\n #End Busca Banco\n \n @bancos = @bancos.paginate(:page => params[:page], :per_page => params[:per_page])\n respond_to do |format|\n format.html { render :index }\n format.json { render json:{ bancos: @bancos, total: @bancos.total_entries } }\n end\n end",
"def index\n\n response = @api.get_list({:destinationString => 'Media', :stateProvinceCode => 'PA'})\n @hotels = response.body['HotelListResponse']['HotelList']['HotelSummary']\n\n end",
"def get(path) # code generated from moviedb website\n url = URI(\"#{HOST_URL}#{path}#{ENV['API_KEY']}\")\n response = Net::HTTP.get_response(url)\n begin\n response_hash = JSON.parse(response.read_body)\n return response_hash\n rescue\n {}\n end\n end",
"def index\n respond_with Biblebook.all\n end",
"def get(path, options={})\n http_verb :get, path, options\n end",
"def get_banks\n HTTParty.get(BASE_URI + 'bank?country=ghana',\n headers: HEADERS).parsed_response\n end"
] | [
"0.6548724",
"0.6278269",
"0.6238488",
"0.61362135",
"0.6104914",
"0.6090801",
"0.6024141",
"0.59705967",
"0.5969265",
"0.59434414",
"0.5928445",
"0.58192694",
"0.57806283",
"0.57772",
"0.5764335",
"0.5763125",
"0.57601833",
"0.575247",
"0.5748528",
"0.5716802",
"0.57164854",
"0.5715342",
"0.57150215",
"0.57053006",
"0.569668",
"0.5694886",
"0.5694163",
"0.56895757",
"0.56830007",
"0.5679792",
"0.56792665",
"0.56550044",
"0.56523526",
"0.5650624",
"0.5645705",
"0.5641431",
"0.5640819",
"0.56276256",
"0.5615302",
"0.5615297",
"0.5615209",
"0.560482",
"0.56006956",
"0.55961204",
"0.5595075",
"0.5593636",
"0.5593273",
"0.55909675",
"0.5584989",
"0.5584017",
"0.55834717",
"0.5580343",
"0.5577306",
"0.5576998",
"0.5573513",
"0.556959",
"0.5568273",
"0.55682415",
"0.5566786",
"0.5554983",
"0.5553798",
"0.5550779",
"0.5547343",
"0.55458575",
"0.55442315",
"0.55395865",
"0.5535328",
"0.55335355",
"0.55330294",
"0.5530997",
"0.553085",
"0.55291",
"0.5519975",
"0.5511352",
"0.55110526",
"0.55091023",
"0.55067235",
"0.55030894",
"0.54990184",
"0.54982454",
"0.5498206",
"0.5497416",
"0.54967546",
"0.54852706",
"0.5482927",
"0.5480936",
"0.5480936",
"0.54808617",
"0.54744625",
"0.54711473",
"0.54694223",
"0.5467193",
"0.546634",
"0.54653704",
"0.5462788",
"0.546232",
"0.5456621",
"0.5454538",
"0.5452558",
"0.5451964"
] | 0.5804119 | 12 |
GET /bingos/1 or /bingos/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend",
"def get_aos_version_box_by_name(args = {}) \n get(\"/aosversions.json/aosversionbox/name/#{args[:aosVersionBoxName]}\", args)\nend",
"def get_brandings\n request :get, \"/v3/brandings.json\"\n end",
"def get_aos_version_by_name(args = {}) \n get(\"/aosversions.json/version/#{args[:aosVersionName]}\", args)\nend",
"def get_aos_version(args = {}) \n get(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def get_aos_version_box_by_id(args = {}) \n get(\"/aosversions.json/aosversionbox/#{args[:aosVersionBoxId]}\", args)\nend",
"def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend",
"def list_all_aos_version_boxes(args = {}) \n get(\"/aosversions.json/aosversionbox\", args)\nend",
"def do_GET(request, response)\n status = 200\n content_type = \"text/html\"\n body = \"bender version #{BENDER_VERSION}\"\n body += \"\\n\"\n\n response.status = status\n response['Content-Type'] = content_type\n response.body = body\n response.body = body\n end",
"def index\n @brags = Brag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brags }\n end\n end",
"def get(path, busca=nil)\n @client.get(path, busca)\n end",
"def get_batterie_by_building\n @battery = Battery.where(building_id: params[:building_id])\n respond_to do |format| \n format.json { render :json => @battery }\n end\n \n end",
"def get(path)\n request = Net::HTTP::Get.new @uri.path+'/'+path\n request.basic_auth @api_key, ''\n request['User-Agent'] = USER_AGENT\n response = @https.request request\n JSON.parse response.body\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bot_bingo_number }\n end\n end",
"def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend",
"def get\n start { |connection| connection.request http :Get }\n end",
"def show\n @verbo = Verbo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verbo }\n end\n end",
"def api_get(path, params = {})\n api_request(:get, path, :params => params)\n end",
"def getbatteries\n puts params\n buildid = params[\"buildingid\"]\n\n batteries = Battery.where(:building_id => buildid)\n\n puts batteries.inspect\n puts \"#################################################\"\n \n respond_to do |format|\n format.json { render json: batteries }\n end\n end",
"def show\n @bb = Bb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bb }\n end\n end",
"def index\n response = RestClient.get 'http://api.bitvalor.com/v1/order_book.json'\n data = JSON.parse(response.body)[\"bids\"]\n @fox = data.select {|element| element[0] == \"FOX\"}\n @b2u = data.select {|element| element[0] == \"B2U\"}\n @mbt = data.select {|element| element[0] == \"MBT\"}\n end",
"def show\n render \"api/v1/bounties/show\"\n end",
"def get(path, query={})\n request_json :get, path, query\n end",
"def index\n @bot_bingo_numbers = BotBingoNumber.all\n\n respond_to do |format|\n format.html # index.html.erb\n # frommat.json { render json: @bot_bingo_numbers }\n end\n end",
"def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end",
"def get(path)\n response = http.get(path) do |req|\n req.headers['Accept'] = 'application/json'\n req.headers['Authorization'] = \"Bearer #{api_token}\"\n end\n\n raise NotFound if response.status == 404\n raise 'TVDB Error' unless response.success?\n\n JSON.parse(response.body)\n end",
"def index\n @shop_section = ShopSection.find_by_short_url(\"brands\")\n @brands = Brand.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brands }\n end\n end",
"def get(path)\n # TODO: do more hardening on the path\n if path.include?('covid19')\n request = Net::HTTP::Get.new(path, @headers)\n else\n request = Net::HTTP::Get.new('/v2' + path, @headers)\n end\n send_request(request)\n end",
"def show\n @basin = Basin.find(params[:id])\n\n @client = YahooWeather::Client.new \n @response = @client.fetch_by_location('Massingir, Gaza, Mz','c')\n @reponse2 = @client.fetch_by_location('Louis Trichardt, Limpopo, South Africa','c')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @basin }\n\n end\n end",
"def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\nend",
"def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend",
"def get(path, data={})\n http_verb :get, path, data\n end",
"def get(*path, auto_paginate: false, query: nil, api_v1: true)\n get_method = auto_paginate ? :get_all : :get_one\n send(get_method, path, query: query, api_v1: api_v1)\n end",
"def get(path, options={})\n http_verb :get, path, options\n end",
"def http_get(path, query, format = :json)\n uri = URI.parse(\"http://#{Jamendo::API_SERVER}/v#{Jamendo::API_VERSION}/#{path}#{query}\")\n puts uri.request_uri\n http = Net::HTTP.new(uri.host, uri.port) \n request = Net::HTTP::Get.new(uri.request_uri)\n begin\n response = http.request(request)\n result = parse_response(response)\n assert_response(result[:headers])\n return result[:results]\n rescue JamendoError => e\n e.inspect\n end\n end",
"def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end",
"def http( *args )\n p http_get( *args )\n end",
"def do_get\n Net::HTTP.get(URI.parse(api_url))\n end",
"def call_rest_getlbvstats\n print \"get lb vserver stats\\n\"\n @uri.path = \"/nitro/v1/config/lbvserver/\"\n @request = Net::HTTP::Get.new(@uri)\n @request.basic_auth \"#{@username}\", \"#{@password}\"\n @request.add_field('Content-Type', 'application/vnd.com.citrix.netscaler.lbvserver+json')\n\n Net::HTTP.start(@uri.host, @uri.port) { |http|\n response = http.request(@request)\n\n if response.code == \"200\"\n result = JSON.parse(response.body)\n File.open(\"lbvserver-stats.json\", \"w\") do |file|\n file.write(JSON.pretty_generate(result))\n end\n end\n }\n\n end",
"def json_get(path, params={})\n json_request(:get, path, params)\n end",
"def getstubjson(title_number)\n uri = URI.parse($STUBJSON)\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new('/' + title_number)\n request.basic_auth $http_auth_name, $http_auth_password\n response = http.request(request)\n if (response.code != '200') then\n raise \"Error in getting JSON for: \" + title_number\n end\n return response.body\nend",
"def get_book_with_api(title)\n uri = URI.parse(URI.encode(\"https://www.googleapis.com/books/v1/volumes?q=#{title}\"))\n service = Books::ApiConnectService.new(uri)\n book_response = service.execute[\"items\"].first[\"volumeInfo\"]\n .select{ |key, value| key == \"title\" || key == \"description\" || key == \"publisher\" || key == \"publishedDate\" || key == \"imageLinks\"}\n @book_info_hash = book_response.inject({}) do |hash, (key, value)|\n if key.underscore == \"image_links\"\n hash[key.underscore] = book_response[\"imageLinks\"][\"smallThumbnail\"]\n else\n hash[key.underscore] = value\n end\n hash\n end\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend",
"def get_book(search)\n\trequest_string = \"https://www.googleapis.com/books/v1/volumes?q=#{search.gsub(\" \",\"+\")}\"\n\t\n\tsample_uri = URI(request_string) #opens a portal to the data at that link\n\tsample_response = Net::HTTP.get(sample_uri) #go grab the data in the portal\n\tsample_parsedResponse = JSON.parse(sample_response) #makes data easy to read\n\tsample_parsedResponse[\"items\"]\nend",
"def list_all_tenantcircles_for_a_version_box(args = {}) \n get(\"/aosversions.json/aosversionbox/circles/#{args[:aosVersionBoxId]}\", args)\nend",
"def show\n @boat = Boat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json {render json: @boat}\n end\n end",
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/photos/#{params[:id]}.json?token=#{ENV['API_KEY']}\"\n\t response = RestClient.get(url)\n\t @photo = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/photos.json?token=#{ENV['API_KEY']}\"\n response = RestClient.get(url)\n @photos = JSON.parse(response.body)\t\t \n\tend\n end",
"def show\n @boat = Boat.find(params[:id])\n\n render json: @boat\n end",
"def status\n get('/api/status')\n end",
"def show\n @bico = Bico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bico }\n end\n end",
"def get endpoint\n do_request :get, endpoint\n end",
"def get(path)\n req = Net::HTTP::Get.new(@base_url + path)\n response = handle_request(req)\n response.each {|k,v| puts \"#{k}: #{v}\"}\n response\n end",
"def get(path)\n request 'GET', path\n end",
"def show\n @bingo = Bingo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bingo }\n end\n end",
"def show\n @apk_bin = ApkBin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @apk_bin }\n end\n end",
"def show\n @baton = Baton.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @baton }\n end\n end",
"def get(path, params={}, options={})\n request(:get, api_path(path), params, options)\n end",
"def show\n @broad = Broad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @broad }\n end\n end",
"def get_json()\n\n http = Net::HTTP.new(STATUS_URI.host, STATUS_URI.port)\n http.use_ssl = false\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Get.new(\"/api/services.json\")\n\n response = http.request(request)\n JSON.parse(response.body)\nend",
"def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n puts JSON.pretty_generate(result)\n result\nend",
"def show\n @osoba = Osoba.find(params[:id])\n\n render json: @osoba\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(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 get\n check_response( @httpcli.get(@endpoint) )\n end",
"def get(*args)\n params = args.extract_options!\n @connection.get do |req|\n req.url versioned_path(args), params\n end\n end",
"def show\n @kb = Kb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @kb }\n end\n end",
"def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end",
"def get(path) # code generated from moviedb website\n url = URI(\"#{HOST_URL}#{path}#{ENV['API_KEY']}\")\n response = Net::HTTP.get_response(url)\n begin\n response_hash = JSON.parse(response.read_body)\n return response_hash\n rescue\n {}\n end\n end",
"def query_api(path)\n with_http_error_handling do\n res = RestClient.get(endpoint + path)\n h = Hash.from_xml(res.body)\n h[\"response\"]\n end\n end",
"def get(*args)\n prepare_request(:get, args)\n @@client.add(:get, @path, *args)\n end",
"def show\n if @bird\n respond_to do |format|\n format.json { render json: {required: @bird, properties: @bird.properties, families: @bird.families, title: \"POST /birds [request]\", description: \"Get bird by id\",:status => OK }}\n end\n else\n respond_to do |format|\n format.json { render json: {:status => NOT_FOUND} }\n end\n end\n end",
"def info\n get '/'\n end",
"def get(endpoint, url, args, version = 'v1')\n qs = build_qs(args)\n req_url = \"#{url}/api/#{version}/#{endpoint}?#{qs}\"\n\n request(req_url, :GET)\n end",
"def get_one(*path, query: nil, api_v1: true)\n url = encode_url(path: path, query: query, api_v1: api_v1)\n faraday_safe(:get, url).body\n end",
"def lws_api_get(path)\n # See also catalog_controller for use of ENV['LWS_...']\n url ||= ENV['LWS_API_URL']\n url ||= \"#{ENV['LWS_CORE_URL']}/api\" if ENV['LWS_CORE_URL']\n \n # http://localhost:8888/api/collections\n resp = Net::HTTP.get_response(URI.parse(\"#{url || 'http://127.0.0.1:8888/api'}#{path}\"))\n result = JSON.parse(resp.body)\n end",
"def get(path)\n request(:get, path, {})\n end",
"def show\n @bdatabase = Bdatabase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bdatabase }\n end\n end",
"def api_get url_suffix\n url = URI::encode \"#{@@oauth_info[:api_url]}/gems/#{url_suffix}\"\n data = {:client_id => @@oauth_info[:client_id]}\n headers = {:Authorization => \"Bearer #{@access_token}\"}\n\n conn = get_conn url\n #Try request 3 times\n for i in 1..3\n res = conn.get(url, data, headers)\n if res.status == 200 then return JSON.parse(res.body) end\n sleep 1\n end\n raise OAuthSessionError, \"GET Failed. Status: #{res.status}. Body: #{res.body}\"\n end",
"def show\n @bl = Bl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bl }\n end\n end",
"def get(path, params={})\n RestClient.get request_base+path, {params: params}\n end",
"def index\n @bingos = Bingo.all\n end",
"def show\n @bloom = Bloom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bloom }\n end\n end",
"def get_bundles(options = nil)\n @client.raw('get', '/content/pages', options)\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get(api)\n\t\t\tvalidate_api(api)\n\t\t\tparams = set_default_params(api[:params])\n\t\t\tquery = hash_to_querystring(params)\n\t\t\turl = \"#{api[:path]}?#{query}\"\n\t\t\tresponse = @http.get(url)\n\t\t\tputs \"#{response.code} - #{response.message}: #{api[:path]} \"\n\t\t\tcheck_cookie(response)\n\t\t\treport_error(response)\n\t\t\tresponse\n\t\tend",
"def get(api, params={})\n url2json(:GET, \"#{@endpoint}#{api}\", params)\n end",
"def show\n @bowl = Bowl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bowl }\n end\n end",
"def index\n @biddings = Bidding.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @biddings }\n end\n end",
"def test_read_all_info\n get '/v1/read_all?data=eyJOYW1lIjogIkVkdWFyZG8iLCAiQ291bnRyeSI6ICJCcmF6aWwiIH0%3D'\n assert last_response.ok?\n assert last_response.body.include?('Eduardo')\n assert last_response.body.include?('Brazil')\n end",
"def get(path, params={})\n params[:apikey] = self.api_key\n RestClient::Request.execute(\n :method => :get,\n :url => \"#{self.uri}#{path}\",\n :headers => {\n :params => params\n },\n :verify_ssl=> @ssl_verify )\n end",
"def show\n @bottling = Bottling.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bottling }\n end\n end",
"def info\n get(\"/api-info\")\n end",
"def get_json(path)\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n #puts \"🤖 GET #{path}\"\n #puts \"HTTP #{response.code}\"\n #puts JSON.pretty_generate(result)\n result\nend",
"def index\n @banners = Banner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @banners }\n end\n end",
"def product(name)\n get(\"/apiproducts/#{name}\")\n end",
"def view_api\n api_string = RestClient.get(\"https://itunes.apple.com/search?term=star+wars&entity=song&attribute=movieTerm\")\n api_hash = JSON.parse(api_string)\n\n end",
"def list_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: BundleApi.list ...\"\n end\n # resource path\n local_var_path = \"/bundles.json\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n 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 = []\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 = ['basic']\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 => 'BundleList')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BundleApi#list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\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"
] | [
"0.6444401",
"0.6403265",
"0.6371681",
"0.6245945",
"0.6212942",
"0.62011105",
"0.61603516",
"0.6127232",
"0.61207837",
"0.6028157",
"0.59965247",
"0.5916836",
"0.5856851",
"0.58536226",
"0.5846458",
"0.58419615",
"0.5839283",
"0.58358264",
"0.5835792",
"0.5830779",
"0.58174735",
"0.5811518",
"0.57990146",
"0.57898223",
"0.5754944",
"0.57447624",
"0.57372457",
"0.5732941",
"0.5727138",
"0.57250243",
"0.5721813",
"0.57197326",
"0.5713645",
"0.5713612",
"0.57102406",
"0.57091254",
"0.5706241",
"0.56884223",
"0.56635815",
"0.5661608",
"0.56601363",
"0.5653802",
"0.5652354",
"0.5652354",
"0.5650688",
"0.56492025",
"0.564896",
"0.56444013",
"0.56328464",
"0.5623634",
"0.5622144",
"0.562139",
"0.561303",
"0.5602854",
"0.56025004",
"0.5601168",
"0.559125",
"0.5585166",
"0.55836636",
"0.5583367",
"0.55829924",
"0.5580924",
"0.55791783",
"0.5577809",
"0.5575742",
"0.55729425",
"0.5571459",
"0.5561805",
"0.5558597",
"0.55580664",
"0.5554576",
"0.5554061",
"0.5553959",
"0.5549898",
"0.55467546",
"0.5545763",
"0.55408376",
"0.5538765",
"0.5538646",
"0.5537718",
"0.55375725",
"0.5537417",
"0.5536558",
"0.5532304",
"0.55235076",
"0.55207914",
"0.55207914",
"0.5517315",
"0.5516287",
"0.5514489",
"0.5508783",
"0.55060714",
"0.55020034",
"0.5496063",
"0.54940665",
"0.54928946",
"0.5484843",
"0.5484082",
"0.54795736",
"0.54755306",
"0.547552"
] | 0.0 | -1 |
POST /bingos or /bingos.json | def create
@bingo = Bingo.new(bingo_params)
respond_to do |format|
if @bingo.save
format.html { redirect_to @bingo, notice: "Bingo was successfully created." }
format.json { render :show, status: :created, location: @bingo }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @bingo.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(bin_params)\n @rest.post('save', bin_params)\n end",
"def api_gateway_post(path, params)\n api_gateway_body_fwd = params.to_json\n rack_input = StringIO.new(api_gateway_body_fwd)\n\n post path, real_params = {}, 'rack.input' => rack_input\nend",
"def post(path, data = {})\n request 'POST', path, body: data.to_json\n end",
"def create\n @osoba = Osoba.new(params[:osoba])\n\n if @osoba.save\n render json: @osoba, status: :created, location: @osoba\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end",
"def api_gateway_post(path, params)\n api_gateway_body_fwd = params.to_json\n rack_input = StringIO.new(api_gateway_body_fwd)\n\n post path, real_params = {}, {\"rack.input\" => rack_input}\nend",
"def add_aos_version_box(args = {}) \n post(\"/aosversions.json/aosversionbox\", args)\nend",
"def http_post(path, request)\n @http.post(\n :body => JSON(:request => request.to_hash),\n :headers => headers,\n :path => \"/api/v2/#{path}\",\n :expects => [200, 201, 202]\n )\n end",
"def create\n @bingo = Bingo.new(params[:bingo])\n\n respond_to do |format|\n if @bingo.save\n format.html { redirect_to(@bingo, :notice => 'Bingo was successfully created.') }\n format.xml { render :xml => @bingo, :status => :created, :location => @bingo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bingo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_branding(params)\n request :post, \"/v3/brandings.json\", params\n end",
"def create(url, data)\n RestClient.post ENV['APIBASE']+url, data, :content_type => :json\nend",
"def api_post(action, data, binary_key = nil)\n api_request(action, data, 'POST', binary_key)\n end",
"def api_post(path, data = {})\n api_request(:post, path, :data => data)\n end",
"def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend",
"def post_api(path, params={}, headers={})\n headers.merge!('CONTENT_TYPE' => \"application/json\")\n post path, params, headers\nend",
"def create\n @boc = Boc.new(boc_params)\n\n respond_to do |format|\n if @boc.save\n format.html { redirect_to new_boc_path, notice: 'Boc was successfully created.' }\n format.json { render :show, status: :created, location: @boc }\n else\n format.html { render :new }\n format.json { render json: @boc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_check(excon, body)\n excon.request(\n method: :post,\n path: '/check',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend",
"def post(path, body = nil, ctype = 'text/plain')\n body = body.to_json unless body.is_a?(String)\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :post, nil, body)\n end",
"def create\n @boook = Boook.new(boook_params)\n\n respond_to do |format|\n if @boook.save\n format.html { redirect_to @boook, notice: 'Boook was successfully created.' }\n format.json { render :show, status: :created, location: @boook }\n else\n format.html { render :new }\n format.json { render json: @boook.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @biotop = Biotop.new(biotop_params)\n\n respond_to do |format|\n if @biotop.save\n format.html { redirect_to @biotop, notice: 'Biotop was successfully created.' }\n format.json { render :show, status: :created, location: @biotop }\n else\n format.html { render :new }\n format.json { render json: @biotop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @boat = Boat.new(boat_params)\n\n if @boat.save\n render json: @boat, status: :created, location: @boat\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end",
"def 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 create body = {}\n @connection.request(method: :post, path: \"/volumes/create\", headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end",
"def post(path, json, params = {})\n if path.include?('covid19')\n request = Net::HTTP::Post.new(path, @headers)\n else\n request = Net::HTTP::Post.new('/v2' + path, @headers)\n end\n request.add_field('Content-Type', 'application/json')\n request.body = json\n params.each do |k, v|\n request[k] = v\n end\n send_request(request)\n end",
"def create\n\t\tboat = Boat.new(boat_params)\n \tif boat.save\n \t\trender json: boat, status: 201\n \tend\n\tend",
"def post_rest_api(endpoint, data, http)\n rest_api_endpoint = \"/classifier-api/v1/#{endpoint}\"\n\n # Create an HTTP POST request against the specified REST API endpoint\n request = Net::HTTP::Post.new(rest_api_endpoint)\n # Set the Content-Type and data of the HTTP POST request\n request.content_type = \"application/json\"\n request.body = data\n # Submit the request\n response = http.request(request)\n # Return the response bosy (JSON containing the result of the POST operation)\n response.body\nend",
"def api_post(action, data)\n api_request(action, data, 'POST')\n end",
"def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts JSON.pretty_generate(result)\n result\nend",
"def create\n @blivot = Blivot.new(blivot_params)\n\n respond_to do |format|\n if @blivot.save\n format.html { redirect_to @blivot, notice: 'Blivot was successfully created.' }\n format.json { render :show, status: :created, location: @blivot }\n else\n format.html { render :new }\n format.json { render json: @blivot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end",
"def post(path, data={})\n request(:post, path, data)\n end",
"def create\n @bnpb = Bnpb.new(bnpb_params)\n\n respond_to do |format|\n if @bnpb.save\n format.html { redirect_to @bnpb, notice: 'Bnpb was successfully created.' }\n format.json { render :show, status: :created, location: @bnpb }\n else\n format.html { render :new }\n format.json { render json: @bnpb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post endpoint, data\n do_request :post, endpoint, data\n end",
"def POST; end",
"def http_post(path, data, content_type = 'application/json')\n http_methods(path, :post, data, content_type)\n end",
"def post(path, params={}, options={})\n request(:post, api_path(path), params, options)\n end",
"def post_json(path, body)\n uri = build_uri(path)\n #puts \"🤖 POST #{path}\"\n #puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n #puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n #puts result[:result]\n result\nend",
"def create\n @bokin = Bokin.new(params[:bokin])\n \n @bokin.name = current_user.name\n @bokin.photourl = current_user.screen_name\n \n \n respond_to do |format|\n if @bokin.save\n format.html { redirect_to @bokin, :notice => 'Bokin was successfully created.' }\n format.json { render :json => @bokin, :status => :created, :location => @bokin }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @bokin.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @basin = Basin.new(params[:basin])\n\n respond_to do |format|\n if @basin.save\n format.html { redirect_to @basin, notice: 'Basin was successfully created.' }\n format.json { render json: @basin, status: :created, location: @basin }\n else\n format.html { render action: \"new\" }\n format.json { render json: @basin.errors, status: :unprocessable_entity }\n end\n end\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 post(data = {})\n call data, method: :post\n end",
"def create\n @verbo = Verbo.new(params[:verbo])\n\n respond_to do |format|\n if @verbo.save\n format.html { redirect_to @verbo, notice: 'Verbo was successfully created.' }\n format.json { render json: @verbo, status: :created, location: @verbo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @verbo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, **args); end",
"def post(path, params={})\n RestClient.post request_base+path, params\n end",
"def post(path, body = nil, options={})\n options[\"format\"] = \"json\"\n connection.post do |request|\n request.url URI.encode(path)\n request.params.merge! options\n request.body = body if body\n end\n end",
"def post\n resource.post(request, response)\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 post(*args)\n request(:post, *args)\n end",
"def create\n @baton = Baton.new(params[:baton])\n\n respond_to do |format|\n if @baton.save\n format.html { redirect_to @baton, notice: 'Baton was successfully created.' }\n format.json { render json: @baton, status: :created, location: @baton }\n else\n format.html { render action: \"new\" }\n format.json { render json: @baton.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n banners = Banner.where(:id => params[:platform].delete(:banners))\n @platform = Platform.new(params[:platform])\n @platform.banners = banners\n\n respond_to do |format|\n if @platform.save\n format.html { redirect_to @platform, notice: 'Platform was successfully created.' }\n format.json { render json: @platform, status: :created, location: @platform }\n else\n format.html { render action: \"new\" }\n format.json { render json: @platform.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @borad = Borad.new(params[:borad])\n\n respond_to do |format|\n if @borad.save\n format.html { redirect_to @borad, :notice => 'Borad was successfully created.' }\n format.json { render :json => @borad, :status => :created, :location => @borad }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @borad.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @bike_rack = BikeRack.new(bike_rack_params)\n\n respond_to do |format|\n if @bike_rack.save\n flash[:success] = 'Bike rack was successfully created.'\n format.html { redirect_to @bike_rack }\n format.json { render :show, status: :created, location: @bike_rack }\n else\n flash[:danger] = 'There was a problem with creating Bike rack.'\n format.html { render :new }\n format.json { render json: @bike_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n megam_rest.post_appdefn(to_hash)\n end",
"def post(path, data=nil)\n request(:post, path, data)\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend",
"def post(request)\n # sure thing!\n json_response(200, { message: \"This dummy POST endpoint didn't do anything.\" })\n end",
"def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{uri}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend",
"def post(*args)\n request :post, *args\n end",
"def create\n @bin = Bin.new(bin_params)\n\n respond_to do |format|\n if save_bin(@bin)\n format.html { redirect_to @bin, notice: 'Bin was successfully created.' }\n format.json { render json: { ok: true, bin: @bin } }\n else\n format.html { render :new }\n format.json {\n bin = Bin.find_by(id: @bin.id) || {}\n render json:\n { ok: false, errors: @bin.errors.full_messages, bin: bin }\n }\n end\n end\n end",
"def create\n @bs_type = BsType.new(bs_type_params)\n\n respond_to do |format|\n if @bs_type.save\n format.html { redirect_to @bs_type, notice: 'Bs type was successfully created.' }\n format.json { render :show, status: :created, location: @bs_type }\n else\n format.html { render :new }\n format.json { render json: @bs_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bot_bingo_number = BotBingoNumber.new(bot_bingo_number_params)\n\n respond_to do |format|\n if @bot_bingo_number.save\n format.html { redirect_to @bot_bingo_number, notice: 'Bot bingo number was successfully created.' }\n format.json { render json: @bot_bingo_number, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @bot_bingo_number.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_data(body)\r\n raise ConfigError, 'no json_records' if body.empty?\r\n # Create REST request header\r\n header = get_header(body.bytesize)\r\n # Post REST request \r\n response = RestClient.post(@uri, body, header)\r\n\r\n return response\r\n end",
"def submit(verb, data)\n start do |connection|\n request = http verb\n request.body = data\n connection.request request\n end\n end",
"def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end",
"def create\n @bb = Bb.new(params[:bb])\n\n respond_to do |format|\n if @bb.save\n format.html { redirect_to @bb, notice: 'Bb was successfully created.' }\n format.json { render json: @bb, status: :created, location: @bb }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, params={})\n request(:post, path, params)\n end",
"def post(path, params={})\n request(:post, path, params)\n end",
"def post(path, params={})\n request(:post, path, params)\n end",
"def binocular_params\n params.require(:binocular).permit(:name, :brand, :description, :magnifications, :notes)\n end",
"def create\n @businesstype = Businesstype.new(businesstype_params)\n\n respond_to do |format|\n if @businesstype.save\n format.html { redirect_to @businesstype, notice: 'Businesstype was successfully created.' }\n format.json { render :show, status: :created, location: @businesstype }\n else\n format.html { render :new }\n format.json { render json: @businesstype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_json(path, body)\n uri = build_uri(path)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n result = JSON.parse(response.body)\n puts result\n result\nend",
"def upload_submission(sub_info)\n uri = URI.parse(TARGET_API)\n http = Net::HTTP.new(uri.host, uri.port)\n\n req = Net::HTTP::Post.new(\"/ontologies/#{sub_info['ontology']['acronym']}/submissions\")\n req['Content-Type'] = 'application/json'\n req['Authorization'] = \"apikey token=#{TARGET_APIKEY}\"\n\n # Check if the source BioPortal is pulling the ontology from an URL\n # If yes then we will pull the ontology from this place (allow auto update of the ontology when the ontology is changed in its source URL)\n if sub_info['pullLocation'].nil?\n pull_location = \"#{sub_info['ontology']['links']['download']}?apikey=#{SOURCE_APIKEY}\"\n else\n pull_location = sub_info['pullLocation']\n end\n\n # Extract contacts\n contacts = []\n sub_info['contact'].each do |contact|\n contacts.push({'name': contact['name'],'email': contact['email']})\n end\n\n # Build the json body\n # hasOntologyLanguage options: OWL, UMLS, SKOS, OBO\n # status: alpha, beta, production, retired\n req.body = {\n 'contact': contacts,\n 'hasOntologyLanguage': sub_info['hasOntologyLanguage'],\n 'released': sub_info['released'],\n 'ontology': \"#{TARGET_API}/ontologies/#{sub_info['ontology']['acronym']}\",\n 'description': sub_info['description'],\n 'status': sub_info['status'],\n 'version': sub_info['version'],\n 'homepage': sub_info['homepage'],\n 'documentation': sub_info['documentation'],\n 'publication': sub_info['publication'],\n 'naturalLanguage': sub_info['naturalLanguage'],\n 'pullLocation': pull_location\n }.to_json\n\n #puts req.body.to_s\n response = http.start do |http|\n http.request(req)\n end\n\n return response\nend",
"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 post(path, options={})\n request :post, path, options\n end",
"def post(api, params)\n url2json(:POST, \"#{@endpoint}#{api}\", params)\n end",
"def create\n @tarot_bot = TarotBot.new(tarot_bot_params)\n\n if @tarot_bot.save\n render json: { status: :ok }\n else\n render json: { status: :internal_server_error }\n end\n end",
"def post url, object = nil\n request url, HTTP::Post, object\n end",
"def post(path, params = nil)\n response = @connection.post do |req|\n req.headers = generate_headers\n req.url path\n req.body = params.to_json\n end\n Arke::Log.fatal(build_error(response)) if response.env.status != 201\n response\n end",
"def create\n @bordado = Bordado.new(params[:bordado])\n\n respond_to do |format|\n if @bordado.save\n format.html { redirect_to @bordado, notice: 'Bordado was successfully created.' }\n format.json { render json: @bordado, status: :created, location: @bordado }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bordado.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(*args)\n super(*wrap_for_json_api(*args))\n end",
"def create\n @bowler = Bowler.new(bowler_params)\n @bowler.save\n respond_with(@bowler)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def create\n megam_rest.post_appreq(to_hash)\n end",
"def post(resource, params)\n case resource\n when \"pedidos\", \"place_order\", \"new_order\" then url = \"/pedidos\"\n when \"envios\", \"shipping\" then url = \"/envios\"\n else url = \"/#{resource}\"\n end\n\n post_request(url, params)\n end",
"def transmit(path, data)\n http_post (host + path),\n {'Content-Type' => 'application/json'},\n [data.to_json]\n end",
"def create\n @bingo_game = BingoGame.create(numbers: BingoNumber.all.shuffle.to_json, index: -1, current_number: nil)\n content = { 'id': '', 'instruction': 'Waiting to start'}\n ActionCable.server.broadcast 'bingo', content: content\n\n respond_to do |format|\n if @bingo_game.save\n format.html { redirect_to @bingo_game, notice: 'bingo game was successfully created.' }\n format.json { render json: @bingo_game, status: :created, location: @bingo_game }\n else\n format.html { render action: \"index\" }\n format.json { render json: @bingo_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, body = '', headers = {})\n headers = { 'Content-Type' => 'application/json' }.merge(headers)\n request(:post, path, body, merge_default_headers(headers))\n end",
"def create\n @verb = Verb.new(verb_params)\n\n if @verb.save\n render json: @verb, status: :created, location: @verb\n else\n render json: @verb.errors, status: :unprocessable_entity\n end\n end",
"def post options\n rest_request({ method: :post }.merge(options))\n end",
"def post options\n rest_request({ method: :post }.merge(options))\n end",
"def create\n @obra = Obra.new(params[:obra])\n\n respond_to do |format|\n if @obra.save\n format.html { redirect_to @obra, notice: 'Obra was successfully created.' }\n format.json { render json: @obra, status: :created, location: @obra }\n else\n format.html { render action: \"new\" }\n format.json { render json: @obra.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, opts = {})\n request(:post, path, opts).body\n end",
"def create_ping\n post 'ping'\n end",
"def create\n @borc = Borc.new(params[:borc])\n\n respond_to do |format|\n if @borc.save\n format.html { redirect_to @borc, notice: 'Borc was successfully created.' }\n format.json { render json: @borc, status: :created, location: @borc }\n else\n format.html { render action: \"new\" }\n format.json { render json: @borc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bla = Bla.new(params[:bla])\n\n respond_to do |format|\n if @bla.save\n format.html { redirect_to @bla, :notice => 'Bla was successfully created.' }\n format.json { render :json => @bla, :status => :created, :location => @bla }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @bla.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.60138226",
"0.59686786",
"0.5959125",
"0.59083915",
"0.5904262",
"0.5836802",
"0.5806822",
"0.5793631",
"0.5792562",
"0.57917786",
"0.5762452",
"0.57120883",
"0.5661779",
"0.5615058",
"0.55956227",
"0.5592449",
"0.55892354",
"0.55570793",
"0.5538656",
"0.55330443",
"0.5530593",
"0.54834175",
"0.54750484",
"0.54743105",
"0.54704815",
"0.5444565",
"0.5444187",
"0.5443924",
"0.5443413",
"0.5440439",
"0.5438691",
"0.5432136",
"0.5428222",
"0.54255843",
"0.54058665",
"0.540457",
"0.54034114",
"0.5401087",
"0.5398852",
"0.53826267",
"0.5375625",
"0.53739625",
"0.5372703",
"0.53699523",
"0.53662556",
"0.5363474",
"0.53430855",
"0.53366125",
"0.53359795",
"0.532851",
"0.53184813",
"0.531748",
"0.5316193",
"0.5309221",
"0.5308774",
"0.5308177",
"0.5304726",
"0.53010577",
"0.5300791",
"0.52978355",
"0.5283199",
"0.5277151",
"0.52765226",
"0.52754796",
"0.5275037",
"0.5273805",
"0.5273805",
"0.5273805",
"0.5268619",
"0.5257372",
"0.5257113",
"0.5253554",
"0.5250214",
"0.52471644",
"0.5233164",
"0.5232677",
"0.5231251",
"0.5231158",
"0.52269727",
"0.5226796",
"0.5226529",
"0.52230793",
"0.52230793",
"0.52230793",
"0.52230793",
"0.52230793",
"0.52210426",
"0.52135026",
"0.5205574",
"0.5201694",
"0.5200027",
"0.5199332",
"0.5198251",
"0.5198251",
"0.5194335",
"0.5193179",
"0.5180751",
"0.51744473",
"0.51709783",
"0.51707286"
] | 0.6080252 | 0 |
PATCH/PUT /bingos/1 or /bingos/1.json | def update
respond_to do |format|
if @bingo.update(bingo_params)
format.html { redirect_to @bingo, notice: "Bingo was successfully updated." }
format.json { render :show, status: :ok, location: @bingo }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @bingo.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 @bingo = Bingo.find(params[:id])\n\n respond_to do |format|\n if @bingo.update_attributes(params[:bingo])\n format.html { redirect_to(@bingo, :notice => 'Bingo was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bingo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boc.update(boc_params)\n format.html { redirect_to @boc, notice: 'Boc was successfully updated.' }\n format.json { render :show, status: :ok, location: @boc }\n else\n format.html { render :edit }\n format.json { render json: @boc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boolio.update( boolio_params )\n format.html { redirect_to @boolio, notice: 'Boolio was successfully updated.' }\n format.json { render :show, status: :ok, location: @boolio }\n else\n format.html { render :edit }\n format.json { render json: @boolio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n respond_to do |format|\n if @boook.update(boook_params)\n format.html { redirect_to @boook, notice: 'Boook was successfully updated.' }\n format.json { render :show, status: :ok, location: @boook }\n else\n format.html { render :edit }\n format.json { render json: @boook.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @osoba = Osoba.find(params[:id])\n\n if @osoba.update(params[:osoba])\n head :no_content\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update # PATCH\n raise NotImplementedError\n end",
"def restobooking\n @buchung = Buchung.find(params[:id])\n @buchung.status='B' \n \n respond_to do |format|\n if @buchung.update_attributes(params[:buchung])\n format.html { redirect_to @buchung, notice: 'Buchung wurde erfolgreich geaendert.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @buchung.errors, status: :unprocessable_entity }\n end\n end \n end",
"def 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 @bounty.update(bounty_params)\n format.html { redirect_to @bounty, notice: 'Bounty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bounty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lob = Lob.find(params[:id])\n\n if @lob.update(lob_params)\n head :no_content\n else\n render json: @lob.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @blivot.update(blivot_params)\n format.html { redirect_to @blivot, notice: 'Blivot was successfully updated.' }\n format.json { render :show, status: :ok, location: @blivot }\n else\n format.html { render :edit }\n format.json { render json: @blivot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @my_boice.update(my_boice_params)\n format.html { redirect_to @my_boice, notice: 'My boice was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_boice }\n else\n format.html { render :edit }\n format.json { render json: @my_boice.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 @bla = Bla.find(params[:id])\n\n respond_to do |format|\n if @bla.update_attributes(params[:bla])\n format.html { redirect_to @bla, :notice => 'Bla was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bla.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @basin = Basin.find(params[:id])\n\n respond_to do |format|\n if @basin.update_attributes(params[:basin])\n format.html { redirect_to @basin, notice: 'Basin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @basin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bowl = Bowl.find(params[:id])\n \n # set bowl modify time\n @bowl.modified = Time.now\n \n respond_to do |format|\n if @bowl.update_attributes(params[:bowl])\n \n Rails.logger.info \"Updating Bowl Contents\"\n \n # remove all contents for this bowl and add new\n @bowl.contents.delete_all(\"bowl_id=\" + @bowl.id)\n \n params.keys.each do |param|\n if param.start_with?(\"input_\") and (params[param] != \"\") \n @bowl.contents.create(:bowl_id => @bowl.id, :dryfruit_id => param[6, 2], :quantity => params[param]) \n end\n end\n\n format.html { redirect_to bowls_path, :notice => 'Bowl was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bowl.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @biotop.update(biotop_params)\n format.html { redirect_to @biotop, notice: 'Biotop was successfully updated.' }\n format.json { render :show, status: :ok, location: @biotop }\n else\n format.html { render :edit }\n format.json { render json: @biotop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bb = Bb.find(params[:id])\n\n respond_to do |format|\n if @bb.update_attributes(params[:bb])\n format.html { redirect_to @bb, notice: 'Bb was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @lob.update(lob_params)\n format.html { redirect_to root_url, notice: 'Lob was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @lob.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def patch!\n request! :patch\n end",
"def update\n @verb = Verb.find(params[:id])\n\n if @verb.update(verb_params)\n head :no_content\n else\n render json: @verb.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @bot_bingo_number.update(bot_bingo_number_params)\n format.html { redirect_to @bot_bingo_number, notice: 'Bot bingo number was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bot_bingo_number.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ipc_boeing.update(ipc_boeing_params)\n format.html { redirect_to @ipc_boeing, notice: 'Ipc boeing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ipc_boeing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bnpb.update(bnpb_params)\n format.html { redirect_to @bnpb, notice: 'Bnpb was successfully updated.' }\n format.json { render :show, status: :ok, location: @bnpb }\n else\n format.html { render :edit }\n format.json { render json: @bnpb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @breet.update(breet_params)\n format.html { redirect_to @breet, notice: 'Breet was successfully updated.' }\n format.json { render :show, status: :ok, location: @breet }\n else\n format.html { render :edit }\n format.json { render json: @breet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bl = Bl.find(params[:id])\n\n respond_to do |format|\n if @bl.update_attributes(params[:bl])\n format.html { redirect_to @bl, notice: 'Bl was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bl.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @robo.update(robo_params)\n format.html { redirect_to @robo, notice: 'Robo was successfully updated.' }\n format.json { render :show, status: :ok, location: @robo }\n else\n format.html { render :edit }\n format.json { render json: @robo.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 patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update\n respond_to do |format|\n if @boleta.update(boleta_params)\n format.html { redirect_to @boleta, notice: 'Boleta was successfully updated.' }\n format.json { render :show, status: :ok, location: @boleta }\n else\n format.html { render :edit }\n format.json { render json: @boleta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @verbo = Verbo.find(params[:id])\n\n respond_to do |format|\n if @verbo.update_attributes(params[:verbo])\n format.html { redirect_to @verbo, notice: 'Verbo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @verbo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @brag = Brag.find(params[:id])\n\n respond_to do |format|\n if @brag.update_attributes(params[:brag])\n format.html { redirect_to @brag, notice: 'Brag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @brag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @http_body = args[:http_body] if args.key?(:http_body)\n end",
"def update\n @b = B.find(params[:id])\n\n respond_to do |format|\n if @b.update_attributes(params[:b])\n format.html { redirect_to @b, notice: 'B was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @b.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sugar_bag = SugarBag.find(params[:id])\n\n respond_to do |format|\n if @sugar_bag.update_attributes(params[:sugar_bag])\n format.html { redirect_to @sugar_bag, notice: 'Sugar bag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sugar_bag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boat.update(boat_params)\n format.html { redirect_to @boat, notice: 'Boat was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat }\n else\n format.html { render :edit }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boat.update(boat_params)\n format.html { redirect_to @boat, notice: 'Boat was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat }\n else\n format.html { render :edit }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boat.update(boat_params)\n format.html { redirect_to @boat, notice: 'Boat was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat }\n else\n format.html { render :edit }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @box = Box.find(params[:id])\n\n respond_to do |format|\n if @box.update_attributes(params[:box])\n format.html { redirect_to @box, notice: 'Box was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @box.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bunny.update(bunny_params)\n format.html { redirect_to @bunny, notice: 'Bunny was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bunny.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bento.update(bento_params)\n format.html { redirect_to @bento, notice: 'Bento was successfully updated.' }\n format.json { render :show, status: :ok, location: @bento }\n else\n format.html { render :edit }\n format.json { render json: @bento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n prms = @boat_type.is_modification? ? modification_params : boat_type_params\n respond_to do |format|\n if @boat_type.update(prms)\n format.html { redirect_to edit_boat_type_path(@boat_type), notice: 'Тип лодки успешно обновлён' }\n format.json { render json: @boat_type.hash_view('control'), status: :ok}\n else\n format.html { render :edit }\n format.json { render json: @boat_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bicepstriceps1.update(bicepstriceps1_params)\n format.html { redirect_to \"/bicepstriceps1s\"}\n format.json { render :show, status: :ok, location: @bicepstriceps1 }\n else\n format.html { render :edit }\n format.json { render json: @bicepstriceps1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @batch = Batch.find(params[:id])\n\n respond_to do |format|\n if @batch.update_attributes(params[:batch])\n format.html { redirect_to @batch, notice: 'Batch was successfully updated.' }\n format.json { respond_with_bip(@batch) }\n else\n format.html { redirect_to @batch }\n format.json { respond_with_bip(@batch) }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end",
"def update\n @bico = Bico.find(params[:id])\n\n respond_to do |format|\n if @bico.update_attributes(params[:bico])\n format.html { redirect_to @bico, notice: 'Bico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boite.update(boite_params)\n format.html { redirect_to @boite, notice: 'Boite was successfully updated.' }\n format.json { render :show, status: :ok, location: @boite }\n else\n format.html { render :edit }\n format.json { render json: @boite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @repuesto_bolet.update(repuesto_bolet_params)\n format.html { redirect_to @repuesto_bolet, notice: 'Repuesto bolet was successfully updated.' }\n format.json { render :show, status: :ok, location: @repuesto_bolet }\n else\n format.html { render :edit }\n format.json { render json: @repuesto_bolet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(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\trespond_to do |format|\n\tif @precio_boleto.update(precio_boleto_params)\n\t\tformat.html { redirect_to @precio_boleto, notice: 'Precio boleto was successfully updated.' }\n\t\tformat.json { head :no_content }\n\telse\n\t\tformat.html { render action: 'edit' }\n\t\tformat.json { render json: @precio_boleto.errors, status: :unprocessable_entity }\n\tend\n\tend\nend",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def update\n respond_to do |format|\n if @bow.update(bow_params)\n format.html { redirect_to @bow, notice: 'Bow was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n request_body_Data= '{ \"widget\":\n {\n \"name\" : \"'+params[:name]+'\",\n \"description\" : \"'+params[:description]+'\"\n }}'\n response = RestClient::Request.new({\n method: :put,\n url: ENV['API_URL'] + '/widgets/' + params[:id],\n payload: request_body_Data,\n headers: { Authorization: session[:access_token], content_type: 'application/json'}\n }).execute do |response, request, result|\n case response.code\n when 400\n [ :error, JSON.parse(response) ]\n when 200\n [ :success, JSON.parse(response) ]\n json=JSON.parse(response)\n @widget= Widget.new do |widget|\n widget.id=json[\"data\"][\"widget\"][\"id\"]\n widget.name=json[\"data\"][\"widget\"][\"name\"]\n widget.description=json[\"data\"][\"widget\"][\"description\"]\n widget.kind=json[\"data\"][\"widget\"][\"kind\"]\n widget.userid=json[\"data\"][\"widget\"][\"user\"][\"id\"]\n widget.username=json[\"data\"][\"widget\"][\"user\"][\"name\"]\n widget.owner=json[\"data\"][\"widget\"][\"owner\"]\n end\n else\n fail \"Invalid response #{response.to_str} received.\"\n end\n end\n respond_to do |format|\n if @widget\n format.html { redirect_to @widget, notice: 'Widget was successfully updated.' }\n format.json { render :show, status: :ok, location: @widget }\n else\n format.html { render :edit }\n format.json { render json: @widget.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bits_1.update(bits_1_params)\n format.html { redirect_to @bits_1, notice: 'Bits 1 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bits_1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bin.assign_attributes bin_params\n\n respond_to do |format|\n if save_bin @bin\n format.html { redirect_to @bin, notice: 'Bin was successfully updated.' }\n format.json { render json: { ok: true, bin: @bin } }\n else\n Rails.logger.error \"Failed to update bin #{params[:id]}\"\n format.html { render :edit }\n format.json { render json: {\n # Respond with the current state of the bin in the database\n ok: false, errors: @bin.errors.full_messages, bin: Bin.find_by(id: params[:id]) }\n }\n end\n end\n end",
"def update\n respond_to do |format|\n if @intranet_boleto.update(intranet_boleto_params)\n format.html { redirect_to @intranet_boleto, notice: \"Boleto was successfully updated.\" }\n format.json { render :show, status: :ok, location: @intranet_boleto }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @intranet_boleto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kb = Kb.find(params[:id])\n\n respond_to do |format|\n if @kb.update_attributes(params[:kb])\n format.html { redirect_to @kb, :notice => 'Kb was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @kb.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @business = Business.find(params[:id])\n authorize! :update, @business\n\n respond_to do |format|\n if @business.update_attributes(business_params || {})\n format.html { redirect_to business_path(@business), notice: 'Business was successfully updated.' }\n format.json do\n respond_with_bip(@business.becomes(Business), param: param_key)\n end\n else\n format.html { render action: \"edit\" }\n format.json do\n respond_with_bip(@business.becomes(Business), param: param_key)\n end\n end\n end\n end",
"def update\n respond_to do |format|\n if @bussiness.update(bussiness_params)\n format.html { redirect_to current_user, notice: 'Business was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bussiness.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n put :update\n end",
"def update\n respond_to do |format|\n if @singleb.update(singleb_params)\n format.html { redirect_to @singleb, notice: 'Singleb was successfully updated.' }\n format.json { render :show, status: :ok, location: @singleb }\n else\n format.html { render :edit }\n format.json { render json: @singleb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rest_api.update(rest_api_params)\n format.html { redirect_to @rest_api, notice: 'Rest api was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rest_api.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bike_rack.update(bike_rack_params)\n flash[:success] = 'Bike rack was successfully updated.'\n format.html { redirect_to @bike_rack }\n format.json { render :show, status: :ok, location: @bike_rack }\n else\n flash[:danger] = 'There was a problem editing Bike rack.'\n format.html { render :edit }\n format.json { render json: @bike_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end",
"def update\n @bill = Bill.find(params[:id])\n\n if @bill.update(params[:bill])\n head :no_content\n else\n render json: @bill.errors, status: :unprocessable_entity\n end\n end",
"def update\n @bowler.update(bowler_params)\n respond_with(@bowler)\n end",
"def update\n @bp = Bp.find(params[:id])\n\n respond_to do |format|\n if @bp.update_attributes(params[:bp])\n format.html { redirect_to @bp, notice: 'Bp was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @api_book = Api::Book.find(params[:id])\n\n if @api_book.update(api_book_params)\n head :no_content\n else\n render json: @api_book.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @bb.update(bb_params)\n format.html { redirect_to @bb, notice: 'Bb was successfully updated.' }\n format.json { render :show, status: :ok, location: @bb }\n else\n format.html { render :edit }\n format.json { render json: @bb.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(data = :object || :json)\n end",
"def update\n @broad = Broad.find(params[:id])\n\n respond_to do |format|\n if @broad.update_attributes(params[:broad])\n format.html { redirect_to @broad, notice: 'Broad was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @broad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boeking.update(boeking_params)\n format.html { redirect_to @boeking, notice: 'Boeking was successfully updated.' }\n format.json { render :show, status: :ok, location: @boeking }\n else\n format.html { render :edit }\n format.json { render json: @boeking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bbhk.update(bbhk_params)\n format.html { redirect_to @bbhk, notice: 'Bbhk was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bbhk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @barrack = Barrack.find(params[:id])\n\n respond_to do |format|\n if @barrack.update_attributes(params[:barrack])\n format.html { redirect_to @barrack, notice: 'Barrack was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @barrack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bread.update(bread_params)\n format.html { redirect_to @bread, notice: 'パン情報を編集した.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bread.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bacon.update(bacon_params)\n format.html { redirect_to @bacon, notice: 'Bacon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bacon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @precio_boleto.update(precio_boleto_params)\n format.html { redirect_to @precio_boleto, notice: 'Precio boleto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @precio_boleto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @bag.update(bag_params)\n format.html { redirect_to @bag, notice: \"Bag was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bag }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bagtype = Bagtype.find(params[:id])\n\n respond_to do |format|\n if @bagtype.update_attributes(params[:bagtype])\n format.html { redirect_to @bagtype, notice: 'Bagtype was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bagtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n if @api_v1_item.update(api_v1_item_params)\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end",
"def update\n @go_slim = GoSlim.find(params[:id])\n\n respond_to do |format|\n if @go_slim.update_attributes(params[:go_slim])\n format.html { redirect_to @go_slim, notice: 'Go slim was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @go_slim.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n set_boat\n respond_to do |format|\n if @boat.update(boat_params)\n format.html { redirect_to harbour_boats_path, notice: 'Boat was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat }\n else\n format.html { render :edit }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @box = Box.find(params[:id])\n authorize! :edit, @box\n\n respond_to do |format|\n @box.update_attributes(params[:box])\n @box.status = 'active'\n if @box.save\n format.html { redirect_to @box, notice: 'Box was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @box.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bill = Bill.find_by(uid:params[:id]).extend(Billit::BillRepresenter)\n @bill.from_json(request.body.read)\n @bill.save\n begin\n Sunspot.index!(@bill)\n rescue\n puts \"#{$!}\"\n puts \"unindexed bill: \" + @bill.uid\n end\n respond_with @bill, :represent_with => Billit::BillRepresenter\n end",
"def update\n @business_object = BusinessObject.find(params[:id])\n\n respond_to do |format|\n if @business_object.update_attributes(params[:business_object])\n format.html { redirect_to @business_object, :notice => 'Business object was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @business_object.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boredom.update(boredom_params)\n format.html { redirect_to @boredom, notice: 'Boredom was successfully updated.' }\n format.json { render :show, status: :ok, location: @boredom }\n else\n format.html { render :edit }\n format.json { render json: @boredom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bingo_hall.update(bingo_hall_params)\n format.html { redirect_to @bingo_hall, notice: \"Bingo hall was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bingo_hall }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bingo_hall.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bucket_bloc.update(bucket_bloc_params)\n format.html { redirect_to @bucket_bloc, notice: 'Bucket bloc was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bucket_bloc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bundle = Bundle.find(params[:id])\n\n\n respond_to do |format|\n params[:bundle][:category] = params[:bundle][:category].strip.downcase\n params[:bundle][:style] = params[:bundle][:style].strip.downcase\n params[:bundle][:color] = params[:bundle][:color].strip.downcase\n params[:bundle][:brand] = params[:bundle][:brand].strip.downcase\n params[:bundle][:make] = params[:bundle][:make].strip.downcase\n params[:bundle][:location] = params[:bundle][:location].strip.downcase\n\n if @bundle.update_attributes(params[:bundle])\n format.html { redirect_to @bundle, notice: 'Bundle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bundle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @businesstype = Businesstype.find(params[:id])\n\n respond_to do |format|\n if @businesstype.update_attributes(params[:businesstype])\n format.html { redirect_to @businesstype, notice: 'Businesstype was successfully updated.' }\n format.json { render :show, status: :ok, location: @businesstype }\n else\n format.html { render :edit }\n format.json { render json: @businesstype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @banco.update(banco_params)\n format.html { redirect_to(:bancos, :notice => t('activerecord.successful.messages.updated', :model => @banco.class.model_name.human))}\n format.json { render :show, status: :ok, location: @banco }\n else\n format.html { render :edit }\n format.json { render :json => { :errors => @banco.errors.full_messages }, :status => 422 }\n end\n end\n end"
] | [
"0.63641137",
"0.61937726",
"0.6184194",
"0.61706156",
"0.60791093",
"0.60707104",
"0.6046116",
"0.60317063",
"0.6023285",
"0.6017018",
"0.60140634",
"0.6006524",
"0.6001912",
"0.5988944",
"0.5987002",
"0.5956738",
"0.5949767",
"0.59442556",
"0.5937486",
"0.59274864",
"0.59080565",
"0.5883579",
"0.5866676",
"0.5847685",
"0.5838576",
"0.5837015",
"0.5836323",
"0.5832594",
"0.5829333",
"0.5816245",
"0.5807154",
"0.5802759",
"0.58000845",
"0.5795903",
"0.57887495",
"0.57858324",
"0.5775261",
"0.5768628",
"0.5754119",
"0.57389104",
"0.57389104",
"0.57389104",
"0.5732562",
"0.5725407",
"0.5720487",
"0.5716559",
"0.5706077",
"0.5703599",
"0.56970614",
"0.56964284",
"0.5694069",
"0.569229",
"0.56920326",
"0.5691991",
"0.56857",
"0.5680474",
"0.567799",
"0.567799",
"0.56773317",
"0.5669005",
"0.5665273",
"0.5662428",
"0.56560516",
"0.56559896",
"0.56536615",
"0.5648822",
"0.56483954",
"0.564542",
"0.56394583",
"0.56390417",
"0.5636978",
"0.56345093",
"0.56307966",
"0.5630753",
"0.56290656",
"0.5625959",
"0.5622048",
"0.56195205",
"0.56189495",
"0.56113696",
"0.56088626",
"0.55980706",
"0.55947727",
"0.5594187",
"0.5591416",
"0.55908406",
"0.5584231",
"0.55812114",
"0.5576628",
"0.55756485",
"0.55752134",
"0.55640554",
"0.55618954",
"0.5560448",
"0.5557163",
"0.5554859",
"0.5548422",
"0.55467516",
"0.55456364",
"0.5545265"
] | 0.6497161 | 0 |
DELETE /bingos/1 or /bingos/1.json | def destroy
@bingo.destroy
respond_to do |format|
format.html { redirect_to bingos_url, notice: "Bingo was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete()\n @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(path)\n RestClient.delete request_base+path\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end",
"def destroy\n @bingo = Bingo.find(params[:id])\n @bingo.destroy\n\n respond_to do |format|\n format.html { redirect_to(bingos_url) }\n format.xml { head :ok }\n end\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def destroy\n @verbo = Verbo.find(params[:id])\n @verbo.destroy\n\n respond_to do |format|\n format.html { redirect_to verbos_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def delete\n if body.empty? && params[:id]\n client.delete(params)\n elsif body.empty?\n client.delete_by_query(params.merge(body: body.merge(ALL)))\n else\n client.delete_by_query(params.merge(body: body))\n end\n end",
"def destroy\n @baton = Baton.find(params[:id])\n @baton.destroy\n\n respond_to do |format|\n format.html { redirect_to batons_url }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n api(\"Delete\")\n end",
"def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end",
"def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @lob.destroy\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @basin = Basin.find(params[:id])\n @basin.destroy\n\n respond_to do |format|\n format.html { redirect_to basins_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bla = Bla.find(params[:id])\n @bla.destroy\n\n respond_to do |format|\n format.html { redirect_to blas_url }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def delete(path)\n request(:delete, path)\n end",
"def destroy\n @b = B.find(params[:id])\n @b.destroy\n\n respond_to do |format|\n format.html { redirect_to bs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @boc.destroy\n respond_to do |format|\n format.html { redirect_to bocs_url, notice: 'Boc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bodega.destroy\n respond_to do |format|\n format.html { redirect_to bodegas_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n request 'DELETE', path\n end",
"def destroy\n @bl = Bl.find(params[:id])\n @bl.destroy\n\n respond_to do |format|\n format.html { redirect_to bls_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 delete_api(name)\n url = '/apis/' + name\n payload = {}\n process_kong_request(url, :DELETE, payload)\n end",
"def delete(path, opts = {})\n input_json = {\n path: path,\n }\n response = @session.do_rpc_endpoint(\"/#{ @namespace }/delete\", input_json)\n Dropbox::API::File.from_json(Dropbox::API::HTTP.parse_rpc_response(response))\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end",
"def destroy\n @bow.destroy\n respond_to do |format|\n format.html { redirect_to bows_url }\n format.json { head :no_content }\n end\n end",
"def 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 @bb = Bb.find(params[:id])\n @bb.destroy\n\n respond_to do |format|\n format.html { redirect_to bbs_url }\n format.json { head :no_content }\n end\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def destroy\n @bbhk.destroy\n respond_to do |format|\n format.html { redirect_to bbhks_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n\t\trequest(path, :delete)\n\tend",
"def destroy\n @brag = Brag.find(params[:id])\n @brag.destroy\n\n respond_to do |format|\n format.html { redirect_to brags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rb.destroy\n respond_to do |format|\n format.html { redirect_to rbs_url, notice: 'Erfolgreich gelöscht.' }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def destroy\n compute.delete_flavor(params[:id])\n \n\n respond_to do |format|\n format.html { redirect_to flavors_path }\n format.json { head :ok }\n end\n end",
"def destroy\n @bico = Bico.find(params[:id])\n @bico.destroy\n\n respond_to do |format|\n format.html { redirect_to bicos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n api_client.delete(url)\n end",
"def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end",
"def destroy\n @bits_1.destroy\n respond_to do |format|\n format.html { redirect_to bits_1s_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 delete(*args)\n request(:delete, *args)\n end",
"def delete(path)\n request(:delete, path)\n end",
"def destroy\n @bdatabase = Bdatabase.find(params[:id])\n @bdatabase.destroy\n\n respond_to do |format|\n format.html { redirect_to bdatabases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bixo = Bixo.find(params[:id])\n @bixo.destroy\n\n respond_to do |format|\n format.html { redirect_to(bixos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @apk_bin = ApkBin.find(params[:id])\n @apk_bin.destroy\n\n respond_to do |format|\n format.html { redirect_to apk_bins_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lob.destroy\n\n head :no_content\n end",
"def destroy\n @borc = Borc.find(params[:id])\n @borc.destroy\n\n respond_to do |format|\n format.html { redirect_to borcs_url }\n format.json { head :no_content }\n end\n end",
"def delete endpoint\n do_request :delete, endpoint\n end",
"def delete(*rest) end",
"def delete!\n request! :delete\n end",
"def delete(object)\n full_name = extract_full_name object\n post 'api/del', :id => full_name\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @verb.destroy\n\n head :no_content\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete(path, params={}, options={})\n request(:delete, api_path(path), params, options)\n end",
"def destroy\n @osoba = Osoba.find(params[:id])\n @osoba.destroy\n\n head :no_content\n end",
"def destroy\n @gasto = Gasto.find(params[:id])\n @gasto.destroy\n\n respond_to do |format|\n format.html { redirect_to gastos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def destroy\n @singleb.destroy\n respond_to do |format|\n format.html { redirect_to singlebs_url, notice: 'Singleb was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def b2_delete_file(file)\n\n if parse_files_json(file) == {}\n\n puts \"File not present\"\n\n else\n \n result_hash = convert_json(b2_delete_file_version(file))\n\n if result_hash[\"fileName\"] == file\n puts \"File deleted successfully\"\n else\n puts \"Error deleting file\"\n end\n\n end\n\nend",
"def destroy\n @bread.destroy\n respond_to do |format|\n format.html { redirect_to breads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @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 delete(path, data = {})\n self.class.delete path, :body => data.merge(:u => access_token)\n end",
"def destroy\n @bounty.destroy\n respond_to do |format|\n format.html { redirect_to bounties_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 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 @blivot.destroy\n respond_to do |format|\n format.html { redirect_to blivots_url, notice: 'Blivot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def deletes_to(path,opts={},&block) #:nodoc: \n crud_to(:delete,path,opts[:params] || {},opts,&block)\n end",
"def destroy\n @obra = Obra.find(params[:id])\n @obra.destroy\n\n respond_to do |format|\n format.html { redirect_to obras_url }\n format.json { head :no_content }\n end\n end",
"def delete(type, id)\n http_delete @target, \"#{type_info(type, :path)}/#{Addressable::URI.encode(id)}\", @auth_header, @zone\n end",
"def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, opts = {})\n request(:delete, path, opts).body\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def destroy\n @sabio = Sabio.find(params[:id])\n @sabio.destroy\n\n respond_to do |format|\n format.html { redirect_to sabios_url }\n format.json { head :ok }\n end\n end",
"def 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 @bay.destroy\n respond_to do |format|\n format.html { redirect_to bays_url, notice: 'La bahía fue eliminada exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def delete(path, params = {})\n Chirpy.request params.merge({:path => path, :method => 'delete'}.merge(authentication))\n end",
"def destroy\n # sorry but not delete is not allow\n #@bundle = Bundle.find(params[:id])\n #@bundle.destroy\n\n respond_to do |format|\n format.html { redirect_to bundles_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.7174855",
"0.6819275",
"0.6819275",
"0.6819275",
"0.6819275",
"0.6779041",
"0.67647356",
"0.6686858",
"0.6672149",
"0.66356415",
"0.65998554",
"0.6573875",
"0.65631115",
"0.65615565",
"0.6554658",
"0.6531609",
"0.6522462",
"0.6522462",
"0.6522094",
"0.65001297",
"0.6486295",
"0.6486153",
"0.6477038",
"0.64743626",
"0.6431117",
"0.64275295",
"0.6405662",
"0.63976634",
"0.6396891",
"0.63918847",
"0.6385467",
"0.63844883",
"0.63821304",
"0.63613284",
"0.6360253",
"0.63586915",
"0.63586915",
"0.63584054",
"0.63522935",
"0.6350439",
"0.63469535",
"0.6340051",
"0.6330048",
"0.63289714",
"0.6322368",
"0.6320752",
"0.6320408",
"0.63059556",
"0.6305719",
"0.6304142",
"0.6300947",
"0.6297753",
"0.6294223",
"0.6288844",
"0.6288435",
"0.6286901",
"0.62849957",
"0.62822855",
"0.6271795",
"0.62698597",
"0.62696594",
"0.62678003",
"0.62612635",
"0.62607294",
"0.6260263",
"0.6254034",
"0.6251216",
"0.6248969",
"0.62432945",
"0.62369686",
"0.6230067",
"0.6228104",
"0.6226585",
"0.6226409",
"0.62256813",
"0.6221565",
"0.6220557",
"0.62184006",
"0.62155116",
"0.6211631",
"0.6211631",
"0.6211631",
"0.6211631",
"0.6211631",
"0.6211631",
"0.6211631",
"0.620518",
"0.6201391",
"0.6199668",
"0.61959916",
"0.61943626",
"0.61923146",
"0.6190017",
"0.61893356",
"0.618651",
"0.618651",
"0.618651",
"0.6182192",
"0.6181502",
"0.6180766"
] | 0.65921074 | 11 |
Use callbacks to share common setup or constraints between actions. | def set_bingo
@bingo = Bingo.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def startcompany(action)\n @done = true\n action.setup\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 setup\n #implement in subclass;\n end",
"def after_set_callback; end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def around_hooks; end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def 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 shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def duas1(action)\n action.call\n action.call\nend"
] | [
"0.6165152",
"0.60463154",
"0.59467196",
"0.5917112",
"0.5890387",
"0.58345735",
"0.57773316",
"0.56991524",
"0.56991524",
"0.565454",
"0.5622282",
"0.54232633",
"0.54119074",
"0.54119074",
"0.54119074",
"0.53937256",
"0.53801376",
"0.5358599",
"0.53412294",
"0.5340814",
"0.53314966",
"0.53114754",
"0.52984965",
"0.52977055",
"0.5296272",
"0.5260649",
"0.5245076",
"0.52388334",
"0.52388334",
"0.52388334",
"0.52388334",
"0.52388334",
"0.5235081",
"0.52321917",
"0.5228592",
"0.5220735",
"0.52198535",
"0.52139324",
"0.5208539",
"0.5206585",
"0.5178542",
"0.5175199",
"0.5173538",
"0.5167041",
"0.51614195",
"0.51577675",
"0.5153909",
"0.51528823",
"0.5152225",
"0.51429904",
"0.5141399",
"0.51345575",
"0.51145",
"0.5114052",
"0.5114052",
"0.5110216",
"0.5108656",
"0.50935394",
"0.5089196",
"0.5081936",
"0.5079627",
"0.50675833",
"0.5056105",
"0.5053687",
"0.5050475",
"0.5050475",
"0.503471",
"0.5028311",
"0.501982",
"0.50157547",
"0.5013552",
"0.50014806",
"0.50011593",
"0.49976763",
"0.4990292",
"0.4990292",
"0.49882022",
"0.4981269",
"0.49792367",
"0.49766538",
"0.4967978",
"0.49667212",
"0.4958987",
"0.49572337",
"0.49550423",
"0.4954479",
"0.4952353",
"0.494726",
"0.4944055",
"0.4935437",
"0.4931248",
"0.49283475",
"0.49281213",
"0.49268973",
"0.4921738",
"0.49204507",
"0.4918924",
"0.49182287",
"0.4916538",
"0.49158585",
"0.49156788"
] | 0.0 | -1 |
Only allow a list of trusted parameters through. | def bingo_params
params.fetch(:bingo, {})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def allow_params_authentication!; end",
"def whitelisted_args\n args.select &:allowed\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def filtered_parameters; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def expected_permitted_parameter_names; end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def check_params; true; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def allowed?(*_)\n true\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def valid_params?; end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def url_allowlist=(_arg0); end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def list_params\n params.permit(:list_name)\n end",
"def valid_params_request?; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end",
"def safelists; end",
"def authorize_own_lists\n authorize_lists current_user.lists\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def lists_params\n params.require(:list).permit(:name)\n\n end",
"def list_params\n params.require(:list).permit(:name, :user_id)\n end",
"def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end",
"def check_params\n true\n end",
"def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def whitelist; end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.permit(:name)\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def permitted_params\n []\n end",
"def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end",
"def params(list)\n @declared_params = list\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end",
"def allow(ids); end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end",
"def safelist; end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def valid_for_params_auth?; end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def permitters\n @_parametrizr_permitters || {}\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def url_allowlist; end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def quote_params\n params.permit!\n end"
] | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.6326454",
"0.63140553",
"0.6299814",
"0.62642586",
"0.626006",
"0.62578833",
"0.6236823",
"0.6227561",
"0.6221758",
"0.62200165",
"0.620879",
"0.61983657",
"0.6195055",
"0.6172993",
"0.6156856",
"0.61558664",
"0.61521494",
"0.6135789",
"0.6121145",
"0.61118174",
"0.60736513",
"0.6071645",
"0.60632104",
"0.60549796",
"0.6043906",
"0.6034662",
"0.60207325",
"0.6018568",
"0.6016575",
"0.60103434",
"0.60084206",
"0.600763",
"0.6007443",
"0.6003619",
"0.6003619",
"0.5995791",
"0.5993301",
"0.5993231",
"0.5984926",
"0.597122",
"0.5968121",
"0.5965808",
"0.59640145",
"0.59632224",
"0.59602356",
"0.59332967",
"0.5927556",
"0.5922805",
"0.5909745",
"0.5905083",
"0.5904304",
"0.5893434",
"0.58888215",
"0.58823985",
"0.58823985",
"0.58823985",
"0.5873434",
"0.58619875",
"0.58533794",
"0.5845531",
"0.58426666",
"0.58360124",
"0.583218",
"0.5828041",
"0.5827927",
"0.5816121",
"0.5814705",
"0.5812719",
"0.581121",
"0.5803423",
"0.5803423",
"0.57995003",
"0.5794207",
"0.5784923",
"0.5781365",
"0.5776385",
"0.5774859",
"0.57671493",
"0.5766998",
"0.57618684",
"0.5758038"
] | 0.0 | -1 |
Get the object with the given name. | def get(name, &constructor)
hashed[name] || if constructor
obj = constructor.call(name)
add(obj)
obj
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find name\n object = objects.find { |o| o.name == name.to_s }\n end",
"def find_object(name); end",
"def find_obj_for_name(name)\n idx = @field_names.index(name)\n if idx\n instantiate_obj(idx)\n @field_objs[idx].obj\n else\n nil\n end\n end",
"def get(name)\n name.downcase!\n parts = name.split('::')\n name = name.to_sym\n\n @mutex.synchronize do\n object = @objects[name]\n unless object || @objects.include?(name)\n @directories.each do |directory|\n path = File.join(directory, @subdir, *parts) + '.rb'\n next unless File.exists?(path)\n object = load_file(parts.last, path)\n break\n end\n # Set even if not found to record misses\n @objects[name] = object\n end\n object\n end\n end",
"def find_first(name)\n object = build(name)\n object.retrieve\n end",
"def get_object(name)\n gtk_builder_get_object(@builder, name)\n end",
"def get_instance_by_name\n # return the existing object if any, otherwise return true\n end",
"def get(name)\n name = camelize(name) if name.downcase == name\n begin\n Object.const_get(name)\n rescue NameError\n nil\n end\n end",
"def get(name)\n lookup(key(name.to_s))\n end",
"def find_object(name)\n @search_paths.unshift(@cache[name]) if @cache[name]\n @search_paths.unshift(Registry.yardoc_file)\n\n # Try to load it from in memory cache\n log.debug \"Searching for #{name} in memory\"\n obj = try_load_object(name, nil)\n return obj if obj\n\n log.debug \"Searching for #{name} in search paths\"\n @search_paths.each do |path|\n next unless File.exist?(path)\n log.debug \"Searching for #{name} in #{path}...\"\n Registry.load(path)\n obj = try_load_object(name, path)\n return obj if obj\n end\n nil\n end",
"def get_object(obj_name)\n key = obj_name.to_s\n obj = @cache[key]\n unless obj\n if extra_inputs_has(key)\n obj = @extra_inputs[key]\n else\n case @defs[key]\n when MethodDef\n obj = construct_method(key)\n when FactoryDef\n obj = construct_factory(key)\n @cache[key] = obj\n else\n obj = construct_object(key)\n @cache[key] = obj if @defs[key].singleton?\n end\n end\n end\n obj\n end",
"def get_object_by_id(class_name, id)\n obj = nil\n get_objects_of_class(class_name).each do |o|\n if o.id == id\n obj = o\n break\n end\n end\n obj\n end",
"def get(name)\n __get(name, false)\n end",
"def find_by_name(name)\n find_by('name', name)\n end",
"def _get(name, obj = @obj)\n return obj[name] if obj[name]\n return _dir(name, obj)\n end",
"def find(name)\n instances.find { |instance| instance.name == (name) }\n end",
"def [](name)\n @lock.synchronize do\n # Return nil if there is no object with that name.\n return nil unless (id = @root_objects[name])\n\n POXReference.new(self, id)\n end\n end",
"def object(name)\n @bucket.object(@root_path + name)\n end",
"def by_name(name)\n elt = self[name]\n return elt unless elt.nil?\n\n @elements.each_key do |subelt_name|\n if self[subelt_name].is_a?(Model)\n elt = self[subelt_name][name]\n return elt unless elt.nil?\n end\n end\n\n nil\n end",
"def get(name); end",
"def get_instance_by_name(group, name)\n get_instances(group).each {|instance|\n return instance if (instance.tags['name_s'] || \"\").casecmp(name) == 0\n return instance if (instance.tags['Name'] || \"\").casecmp(name) == 0\n }\n raise \"unknown instance: #{name} in group #{group} \"\n end",
"def find( model, name )\n model( model )[name ] rescue nil\n end",
"def get(name)\n send(name)\n end",
"def read(name)\n Oj.load(@redis.get(name))\n end",
"def get(name)\n name = camelize(name) if name.downcase == name\n begin\n const_get(name)\n rescue NameError\n nil\n end\n end",
"def find_model(name)\n ole = ole_obj.Models(name)\n model_from_ole(ole)\n rescue\n puts \"model #{name} not found\"\n nil\n end",
"def get_resource(name)\n resource = Resource.new\n resource.name = name\n resource.get_resource\n yield resource.resource if block_given?\n resource\n end",
"def find_by_name(name)\n end",
"def get_by_name(name, query={})\n\n # 空またnilの場合listと同じURLにリクエストしてしまい意図しないレスポンスが返ってくる\n if name.nil? || name.empty?\n raise Yao::InvalidRequest.new(\"Invalid request with empty name or nil\")\n end\n\n begin\n GET(create_url(name), query)\n rescue Yao::ItemNotFound, Yao::NotFound => e\n item = find_by_name(name).select { |r| r.name == name }\n if item.size > 1\n raise Yao::TooManyItemFonud.new(\"More than one resource exists with the name '#{name}'\")\n elsif item.size.zero?\n raise e\n end\n GET(create_url(item.first.id), query)\n end\n end",
"def get(name)\n data[name]\n end",
"def get_object(object_key)\n return get_objects(object_key)[object_key]\n end",
"def [](name)\n @by_name[name]\n end",
"def get( name )\n @jobs.each { |job| return job if job[:name] == name }\n nil\n end",
"def find(name)\n result = nil\n connect do |conn|\n begin\n conn.search2(dn(name), 0, \"objectclass=*\") do |result|\n # Convert to puppet-appropriate attributes\n return entry2provider(result)\n end\n rescue => detail\n return nil\n end\n end\n end",
"def find_by_name name\n name = CGI.escape name.downcase.gsub(/\\s/, '')\n DynamicModel.new perform_request api_url \"summoners/by-name/#{name}\"\n end",
"def find_by_name name\n name = CGI.escape name.downcase.gsub(/\\s/, '')\n DynamicModel.new perform_request api_url \"summoners/by-name/#{name}\"\n end",
"def get_object!(bucket_name, key, **opts)\n bucket = get_bucket!(bucket_name, **opts)\n obj = bucket.file(key)\n return obj if obj\n raise ObjectNotFoundError.new(\n \"Object \\\"#{key}\\\" not found in bucket \\\"#{bucket.name}\\\"\"\n )\n end",
"def find_by_name(name)\n for item in self.collection\n return item if item.name == name\n end\n\n # didn't find item in collection, return nil\n return nil\n end",
"def find_model(name)\n @models[name.to_s.downcase.to_sym]\n end",
"def get_user(name)\n @model.find_by(name: name)\n end",
"def object_for(path)\n # We do the traversal so that the user does not need to.\n path.split(\"/\").inject(self) {|tree, name|\n tree.objects.find {|obj| obj.name == name }\n }\n end",
"def getItemByPageName(name)\n request('getItemByPageName', {'name' => name})\n end",
"def name\n object[\"name\"]\n end",
"def get(name)\n @all.find { |e| e.name == name.to_s || e.name == \"#{name}_engine\" }\n end",
"def try_load_object(name, cache_path)\n obj = Registry.at(name)\n cache_object(name, cache_path) if obj && cache_path\n obj\n end",
"def get(name)\n self._list.detect { |entry| entry.name == name.to_sym }\n end",
"def find_or_create_by_name(name)\n obj = self.find_by_name(name)\n if obj == nil\n obj = self.create(name)\n end\n obj\n end",
"def []( name )\r\n result = @resources[name]\r\n\r\n if result.nil?\r\n result = autoload(name)\r\n if result\r\n self[name] = result\r\n result.name = name\r\n end\r\n end\r\n\r\n return result\r\n end",
"def get_info_object(rpm_name)\n unless @unique_objects.has_key?(rpm_name)\n new_info_object(rpm_name)\n end\n object = @unique_objects[rpm_name]\n return object\n end",
"def find_obj\n @obj = eval(resource_name).find_by(id: params[:id])\n end",
"def fetch(name); end",
"def find(name)\n Template.find(name)\n end",
"def find_by_name(name)\n binding.pry\n self.name\n end",
"def get_next_for(name)\n factories[name].get_next_object\n end",
"def get_object(goid)\n @game_objects[goid]\n end",
"def lookup(name)\n if @map[name]\n @map[name]\n else\n # Descendant classes should be loaded for this to work\n @klass.descendants.each do |klass|\n proto_model = klass.factory.lookup(name)\n return proto_model if proto_model\n end\n \n nil\n end\n end",
"def get_user(name)\n User.where(name:).first\n end",
"def find_by_name(name)\n domain_record = finder(:select => [:id, :name], :conditions => {:name => name})\n return nil if domain_record.nil?\n\n new(domain_record)\n end",
"def get_const_by_name(name)\n consts = name.split(\"::\")\n obj = Object\n begin\n consts.each{|const| \n obj = obj.const_get(const)\n }\n rescue\n Log.logger_for(:configuration).error(\"No such class defined: #{name}\")\n end\n return obj\n end",
"def get_instance(name)\n name = name[0, 2].upcase\n cls = case name\n when 'ET'\n 'Rbeapi::Api::EthernetInterface'\n when 'PO'\n 'Rbeapi::Api::PortchannelInterface'\n when 'VX'\n 'Rbeapi::Api::VxlanInterface'\n when 'VL'\n 'Rbeapi::Api::VlanInterface'\n else\n 'Rbeapi::Api::BaseInterface'\n end\n\n return @instances[name] if @instances.include?(cls)\n instance = Rbeapi::Utils.class_from_string(cls).new(@node)\n @instances[name] = instance\n instance\n end",
"def find_by_name(name)\n # this works because of `def item.=='\n item = @set.find { |c| c == name }\n item\n end",
"def item(name)\n __item(name)\n end",
"def use(name)\n model.repository.by_name(name)\n end",
"def use(name)\n model.repository.by_name(name)\n end",
"def child(name)\n children.select { |child| child.name == name }.first || NonexistentFSObject.new(name, self)\n end",
"def method_missing(name, *args)\n obj = find(name.to_s)\n if obj\n return obj.value\n else\n return nil\n end\n end",
"def [](name)\n get_scene.lookup(name)\n end",
"def object(query, kwargs = {})\n objs = objects(query, kwargs)\n return objs.length == 1 ? objs[0] : nil\n end",
"def get_object\n class_name = self.target_type.classify\n klass = Object.const_get(class_name)\n return klass.find(self.target_id)\n end",
"def find(name)\n list[name]\n end",
"def association_instance_get(name)\n @association_cache[name.to_sym]\n end",
"def get(name)\n return @table[name] if @table.has_key?(name)\n return @parent.get(name) unless @parent.nil?\n return nil\n end",
"def find(id)\n @objects[id]\n end",
"def [](name)\n self.persistent_class.get_property(name.to_s) rescue nil\n end",
"def get(name)\n @j_map.get(name)\n end",
"def for(name, obj = nil)\n on(obj).where(:name => name.to_s.downcase)\n end",
"def get_object_from_db_id(db_object_id)\n get_object_from_db_object(@db_class.find(db_object_id))\n end",
"def get_by_name(name)\n network=connection.lookup_network_by_name(name)\n return network\n # new(:raw => network)\n end",
"def find_or_create_resource_for(name)\r\n resource_name = name.to_s.camelize\r\n resource_name.constantize\r\n rescue NameError\r\n resource = self.class.const_set(resource_name, Class.new(ActiveTamino::Base))\r\n resource.collection = self.class.collection\r\n resource.credentials = self.class.credentials\r\n resource.doctype = self.class.doctype\r\n resource\r\n end",
"def association_instance_get(name)\n @association_cache[name]\n end",
"def association_instance_get(name)\n @association_cache[name]\n end",
"def get( name, *args )\n point = find_definition( name )\n raise ServiceNotFound, \"#{fullname}.#{name}\" unless point\n\n point.instance( self, *args )\n end",
"def [](name)\n @hash.fetch(name)\n end",
"def [](name)\n mapping(name).try(:read)\n end",
"def get_entity( name, parent_context = nil )\n id = @entity_names[ get_entity_unique_name(name, parent_context) ]\n @entity_list[ id ]\n end",
"def get_field_by_name(name)\n self.class.get_field_by_name(name)\n end",
"def get_field_by_name(name)\n self.class.get_field_by_name(name)\n end",
"def object_as(name)\n define_method(name) { @object }\n end",
"def find_by_name(id)\n end",
"def fetch_character_by_name(name)\n uri = URI(BASE_URI + \"?name=#{name}\")\n characters = make_request(uri)\n if characters[0]\n Character.new(characters[0])\n else\n \"Couldn't find a character with that name...\"\n end\n end",
"def lookup(id)\n\t\t@objects[id]\n\tend",
"def find_container_model_by_name(name)\n container_models[name.to_str]\n end",
"def fetch_property(name)\n properties.where(\"name = ?\", name).first\n end",
"def get_node_by_name(name, options={})\n options[:exactget] ||= {}\n options[:exactget][:name] = name\n ret = get_nodes(options)\n if ret.empty?\n warn \"Cannot find node #{name}\"\n ret = nil\n elsif ret.values.size == 1\n ret = ret.values[0]\n else\n raise \"Multiple nodes returned for #{name}\"\n end\n ret \n end",
"def find(name)\n\t\t\tif @table.has_key?(name)\n\t\t\t\treturn @table[name]\n\t\t\telsif @parent.nil?\n\t\t\t\treturn nil\n\t\t\telse\n\t\t\t\t@parent.find(name)\n\t\t\tend\n\t\tend",
"def find(name)\n @@subclasses.fetch(name.to_s, nil)\n end",
"def get!(resource_type, name)\n result = get(resource_type, name)\n if !result\n raise \"#{identifier(resource_type, name)} not found!\"\n end\n result\n end",
"def find_node_by_name(name)\n @nodes[name]\n end",
"def find(name)\n m = match(name)\n m.count == 1 ? m[0] : nil\n end",
"def get_game(game_name)\n\tgame_name = game_name.to_s\n\tObject.const_get(game_name)\nend"
] | [
"0.82078433",
"0.7963105",
"0.7895797",
"0.7325606",
"0.7305935",
"0.7161962",
"0.71344703",
"0.70946926",
"0.70404834",
"0.6965126",
"0.6944315",
"0.6825027",
"0.67925805",
"0.67812896",
"0.673814",
"0.67343986",
"0.6720087",
"0.67141956",
"0.66879404",
"0.66870683",
"0.66428894",
"0.65942824",
"0.6594265",
"0.6506574",
"0.6503521",
"0.64967513",
"0.64699906",
"0.64644754",
"0.644505",
"0.6442251",
"0.64421916",
"0.6440835",
"0.6401801",
"0.63934356",
"0.638816",
"0.638816",
"0.6373901",
"0.63703096",
"0.63482827",
"0.63450944",
"0.63310254",
"0.6326925",
"0.6323248",
"0.6294543",
"0.6293626",
"0.62897336",
"0.6282651",
"0.6278539",
"0.6276209",
"0.62667036",
"0.62443507",
"0.6226599",
"0.6224734",
"0.6215911",
"0.619933",
"0.6182261",
"0.6178651",
"0.61738116",
"0.61735755",
"0.61679435",
"0.61609894",
"0.6123211",
"0.611798",
"0.611798",
"0.61058396",
"0.6090457",
"0.607544",
"0.60725933",
"0.60679483",
"0.60559446",
"0.6046382",
"0.60407335",
"0.6032875",
"0.6026584",
"0.6021788",
"0.60216606",
"0.6018161",
"0.60021853",
"0.5991107",
"0.5975808",
"0.5975808",
"0.5968509",
"0.5968308",
"0.5966645",
"0.5966154",
"0.5961068",
"0.5961068",
"0.59597576",
"0.59506214",
"0.59332883",
"0.59275794",
"0.59249586",
"0.5909442",
"0.5906768",
"0.5902263",
"0.58992326",
"0.58886737",
"0.58859396",
"0.58806765",
"0.5875106"
] | 0.60384387 | 72 |
The index as a sorted list. All Enumerable methods act on this list. | def list
@list ||= []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_index\n pos = nil\n pos ||= self.position if self.respond_to?(:position)\n [pos || 9999, self.id]\n end",
"def sort_index\n self.index || 0\n end",
"def zindexed\n all.sort_by(&:zindex)\n end",
"def sorted_indices\n return method_missing(:sorted_indices) unless vector?\n ary = self.to_flat_array\n ary.each_index.sort_by { |i| ary[i] } # from: http://stackoverflow.com/a/17841159/170300\n end",
"def sort_and_include_index\n #get sorted values and indexes based and return 2 dimension array [value, index]\n self.map.with_index.sort.map {|v,i| [v,i]}\n end",
"def to_hash\n @index\n end",
"def keys\n @index.range(0, -1)\n end",
"def index_as\n Array(@index_as)\n end",
"def indices\n @indices.to_a\n end",
"def index\n @entries = Entry.ordered\n end",
"def index\n @index ||= self.class.index\n end",
"def list\n index\n end",
"def order\n sorted = self.sort\n hash = Hash.new {|h,k| h[k] = [] }\n self.each_with_index do |sortd,i|\n hash[sortd] << i\n end\n ord = sorted.map do |val|\n hash[val].shift\n end\n Runarray::NArray.new('int').replace(ord)\n end",
"def to_a\n indices\n end",
"def index_as\n Array(@index_as)\n end",
"def to_a\n a = []\n @index.each_value do |s|\n s.each do |t|\n a << t\n end\n end\n a\n end",
"def indexed\n self['indexed']\n end",
"def order\n @order || index\n end",
"def list_methods\n index.keys.sort\n end",
"def __sortable__\n self\n end",
"def index; @index; end",
"def index\r\n @index ||= 0\r\n end",
"def sort!\n return @array.sort! unless @current_index.between? 0, @array.size.pred\n\n current_item = @array.at @current_index\n offset = @array.to_a[0...@current_index].count current_item\n\n @array.sort!\n\n center_indices_at (@array.to_a.index(current_item) + offset)\n\n self\n end",
"def list\n to_hash.keys.sort\n end",
"def as_indexed_json\n indexed_values\n end",
"def index\n @states = State.sorted # sorted defined in model, creating instance variable @states\n end",
"def indexes\n @indexes ||= []\n end",
"def index\n @reports = Report.sorted\n end",
"def ordered_list; end",
"def [](idx)\n if idx.is_a?(Range)\n return @index[idx].each_with_index.map {|val, idx| force_load(idx)}\n end\n # idx is an index now\n force_load(idx)\n end",
"def index\n @lists = Blog::List.sorted\n end",
"def index\n @countries = Country.sorted\n end",
"def index\n @ticket_items = TicketItem.sorted\n end",
"def names\n @index.keys\n end",
"def index\r\n build_index unless @index\r\n @index\r\n end",
"def all_indices\n @indices ||= []\n @indices.dup\n end",
"def index()\n INDEXES.find { |i| (self + i).exist? }&.yield_self { |i| self + i }\n end",
"def supports_index_sort_order?\n false\n end",
"def supports_index_sort_order?\n false\n end",
"def index_as\n if @index_as\n Array(@index_as)\n else\n self.proxied_term.index_as\n end\n end",
"def entries\n @entries.sort!{|a, b| a.range.low <=> b.range.low }\n end",
"def ordered_values; end",
"def sort\n return @sort\n end",
"def sorted_keys; end",
"def dumpIndex()\n\t\t@index.each do | key, val |\n\t\t\tputs \"#{key} : #{val}\"\n\t\tend\n\tend",
"def index\n @index ||= 1\n end",
"def [](index)\n Array.new([index])\n end",
"def get_sorted_array\n @ary.sort\n end",
"def index\n @index ||= RecordHistory.new(sibling_versions, self.class).index(self)\n end",
"def index\n @katbib2 = Katbib2.sorted\n end",
"def keys\n index.keys.collect {|keys| keys.to_s }\n end",
"def index ; @index ; end",
"def index\n @index ||= tree.all_data.index(entry)\n end",
"def to_hash\n @index.inject({}) do |hsh, index|\n hsh[index] = self[index]\n hsh\n end\n end",
"def to_hash\n @index.inject({}) do |hsh, index|\n hsh[index] = self[index]\n hsh\n end\n end",
"def index\n get_sorted_objects(params)\n render :template => 'sortable/index'\n end",
"def index_model\n model().default_order\n end",
"def [](index)\r\n @internal_list[index]\r\n end",
"def sort_by! &block\n return @array.to_enum(:sort_by!) unless block_given?\n\n current_item = @array.at @current_index\n offset = @array.to_a[0...@current_index].count current_item\n\n @array.sort_by! &block\n\n center_indices_at (@array.to_a.index(current_item) + offset)\n\n self\n end",
"def [](index)\n @index[index]\n end",
"def index\n list\n end",
"def index\n list\n end",
"def sortable(pos)\n @sortable[pos]\n end",
"def index\n @array = [45, 6, 32, 0]\n end",
"def index\n @lists = List.order(name: :asc)\n end",
"def index\n @stories = Story.sorted\n end",
"def [] index\r\n @list[index]\r\n end",
"def index\n @index\n end",
"def index\n @index\n end",
"def index\n @key_indicate_map_indicator_keys = KeyIndicateMap::IndicatorKey.order(sort_column + \" \" + sort_direction)\n end",
"def index\n return @content.index\n end",
"def yale_nd_row_as_sorted_set i\n require 'set'\n SortedSet.new(yale_nd_row(i, :array))\n end",
"def elements\n unless @elements\n ary = tsort\n ary.reverse!\n @elements = ary\n end\n @elements\n end",
"def sort_order\n super\n end",
"def iterator\n AlphabeticalOrderIterator.new(@collection)\n end",
"def sort\n conditions = scope_condition\n list_items = order_by_position(conditions, :created_at.desc).to_a\n\n list_items.each_with_index do |list_item, index|\n list_item.set_my_position index + 1\n end\n end",
"def sort\n conditions = scope_condition\n list_items = order_by_position(conditions, :created_at.desc).to_a\n\n list_items.each_with_index do |list_item, index|\n list_item.set_my_position index + 1\n end\n end",
"def index\n \n @subjects = Subject.sorted\n \n end",
"def index\n @gigs = Gig.reorder(gig_when: :asc)\n end",
"def index\n unless @descriptor_index\n @descriptor_index = all.inject({}) do |hash,d|\n hash[d.index_key] = d\n hash\n end\n end\n @descriptor_index\n end",
"def <=> other\n index <=> other.index\n end",
"def find_index(index)\n self.indexes[Array(index).collect(&:to_s).sort.collect(&:to_sym)]\n end",
"def indices\n @data.keys\n end",
"def all_indices_by_rank\n all_access_path.\n reject{|ap| ap.is_a?(ActiveFacts::Metamodel::ForeignKey)}.\n sort_by{|ap| ap.all_index_field.to_a.flat_map{|ixf| (c = ixf.component) ? c.rank_path : 0}.compact }\n end",
"def each_with_index(&block)\n to_a.each_with_index(&block)\n end",
"def each_with_index(&block)\n to_a.each_with_index(&block)\n end",
"def sortable_sort\n @sortable_sort\n end",
"def index\n @things = Thing.rank(:row_order).all\n end",
"def keys\n each_with_index.map {|_, index| index }\n end",
"def position_in_list\n self[order_column]\n end",
"def index_by\n\t\t\t\tmap { |n| [yield(n), n] }.to_hash\n\t\t end",
"def index\n @listings = Listing.all.sort_by { |listing| listing.value_score }\n end",
"def expand_and_order(*indexes)\n ixs = []\n indexes.flatten.each do |index|\n if index.is_a?(Range)\n if index.first > index.last\n ixs << (index.last..index.first).to_a\n else\n ixs << index.to_a\n end\n else\n ixs << index\n end\n end\n ixs.flatten.sort\n end",
"def [](index)\n @list[index]\n end",
"def idx\n @ob.get_idx\n end",
"def index\n @prospects = Prospect.order(sort_column + ' ' + sort_direction)\n end",
"def sorted_contents\r\n @contents.keys.sort\r\n end",
"def outidx\n @index_range.begin\n end",
"def scores_index\n @scores_idx\n end",
"def sort_titles_by_index\n validate_titles.sort_by { |titles| titles.second.to_i }\n end",
"def sort\n self[:sort]\n end"
] | [
"0.7057693",
"0.6644014",
"0.64960253",
"0.63106245",
"0.62940466",
"0.6220144",
"0.61537105",
"0.6112791",
"0.6035116",
"0.6032387",
"0.6009315",
"0.595714",
"0.5952997",
"0.59483504",
"0.59429246",
"0.5929319",
"0.5913949",
"0.5910413",
"0.58835936",
"0.58468324",
"0.5817047",
"0.5811742",
"0.5809702",
"0.5789293",
"0.5710975",
"0.5703424",
"0.57005906",
"0.56981236",
"0.5681327",
"0.5671228",
"0.56503445",
"0.5645653",
"0.56401163",
"0.56310505",
"0.5628344",
"0.56099254",
"0.5602259",
"0.55815256",
"0.55815256",
"0.55541193",
"0.5544288",
"0.5544232",
"0.553108",
"0.55136347",
"0.551165",
"0.55068976",
"0.5485252",
"0.54825807",
"0.54785955",
"0.54745483",
"0.54640067",
"0.54617804",
"0.54594815",
"0.5454756",
"0.5454756",
"0.54346883",
"0.5434065",
"0.5423804",
"0.5423188",
"0.5410685",
"0.5395726",
"0.5395726",
"0.5384568",
"0.5382329",
"0.53796995",
"0.5376277",
"0.5363503",
"0.53543854",
"0.53543854",
"0.53468055",
"0.5333506",
"0.5330636",
"0.5325391",
"0.5322545",
"0.53179157",
"0.53146005",
"0.53146005",
"0.53075874",
"0.530517",
"0.530111",
"0.52949613",
"0.5291886",
"0.52895695",
"0.5284306",
"0.52842563",
"0.52842563",
"0.52824265",
"0.5271829",
"0.5270892",
"0.52618736",
"0.5260722",
"0.52595943",
"0.52580196",
"0.52578104",
"0.5256658",
"0.52562505",
"0.52547586",
"0.524916",
"0.524663",
"0.5240883",
"0.5236864"
] | 0.0 | -1 |
Clear all the elements of this index | def clear
hashed.clear
list.clear
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_index\n @index = nil\n end",
"def clear\n @hash.del\n @index.del\n end",
"def clear\n @values.clear\n end",
"def clear\n @store.fill(nil,0...@size)\n end",
"def clear\n @field.each_index { |i| @field[i] = 0 }\n end",
"def clear\n @a.clear\n end",
"def reset\n @index = -1\n @element = nil\n @value = nil\n end",
"def clear() end",
"def clear() end",
"def clear\n with(keys: EMPTY_ARRAY)\n end",
"def clear_all\n data.delete_all\n self\n end",
"def clear\n @by_id.values.each{|x| x.clear }\n end",
"def clear_index!\n search_backend.clear_index!\n end",
"def clear\n @values.each { |v| v.deleted = true }\n end",
"def clear\n do_clear\n end",
"def clear_index\n @descriptor_index.clear if @descriptor_index\n end",
"def clear\n end",
"def clear\n end",
"def clear\n self.rows = nil\n end",
"def clear\n end",
"def clear!\n @all = Set.new\n end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def reset_index_information\n @indexes = nil\n end",
"def clear\n end",
"def clear\n end",
"def clear\n end",
"def clear\n @index = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }\n end",
"def clear\n @selected_indices.clear\n super\n end",
"def clear!\n @tracking.drop\n @user_data.drop\n create_indices\n end",
"def clear\n\t\tend",
"def clear\n\n end",
"def clear\n @table = Array.new(@table.size)\n @count = 0\n end",
"def clear\n @table = Array.new(@table.size)\n @count = 0\n end",
"def clear\n\n @consequences.clear\n @index = 0\n end",
"def clear\n raise \"not implemented\"\n end",
"def clear(opts = {}) \n save(setup_commit_options({:message => \"all clear\"}.merge(opts))) do |index|\n if tree = index.current_tree\n tree.contents.each do |entry|\n index.delete(key_for(entry.name))\n end\n end\n end\n end",
"def clear(opts = {}) \n save(setup_commit_options({:message => \"all clear\"}.merge(opts))) do |index|\n if tree = index.current_tree\n tree.contents.each do |entry|\n index.delete(key_for(entry.name))\n end\n end\n end\n end",
"def reset\n clear\n @position = 0\n @current_index = 0\n end",
"def clear\n keys.each do |k|\n Jeapie.instance_variable_set(\"@#{k}\", nil)\n end\n end",
"def clear\n @items = []\n end",
"def clear!; end",
"def clear!; end",
"def clear!; end",
"def clear\n\t\t@first = nil\n\t\t@last = nil\n\tend",
"def reset()\n #This is a stub, used for indexing\n end",
"def reset()\n #This is a stub, used for indexing\n end",
"def clear\n @data = {}\n @next_keys = {}\n end",
"def clear(_options = nil)\n # TODO: Support namespaces\n @client.delete_by_query index: @index_name, type: 'entry', body: { query: { match_all: {} } }\n end",
"def clear\n\n self.list=([])\n end",
"def clear ; @data.clear ; end",
"def clear\n @count = 0\n @head = nil\n end",
"def clear\n return\n end",
"def clear!\n @documents = {}\n @attributes = {}\n @lookup_map = nil\n @all_loaded = false\n @all = []\n end",
"def reset_index\n @index = 0\n end",
"def clearAretes()\n laTaille = @aretes.size()\n for i in 0...laTaille do\n @aretes[0].supprimer()\n end\n end",
"def clear\n @lock.synchronize do\n @values.clear\n @references_to_keys_map.clear\n end\n end",
"def clear\n raise NotImplementedError\n end",
"def clear\n raise NotImplementedError\n end",
"def clear\n @table.clear\n end",
"def clear\n @atlas.clear\n end",
"def clear!\n @data = []\n return self\n end",
"def clear!\n @columns.clear\n @columns_hash.clear\n @primary_keys.clear\n @tables.clear\n @version = nil\n end",
"def clear()\n merge(clear: 'true')\n end",
"def clear\n @list = []\n end",
"def clear() \n @obj.clear() \n end",
"def clear\n @next = nil\n @size = 0\n @stored = {}\n nil\n end",
"def clear!\n @items.clear\n end",
"def clear\n @level = 0\n @out = []\n @labels = []\n self\n end",
"def clear!\n set_ds_field []\n end",
"def clear!\n set_ds_field []\n end",
"def clear\n # Remove all of the shortcut methods\n cell_names.each {|name| builder.undef_cell(name)}\n cells.clear\n end",
"def clear_all\n NotImplementedError\n end",
"def clear!\n end",
"def clear\n io.truncate(0)\n io_index.clear\n self\n end",
"def clear\n @items.clear\n end",
"def clear!\n fields.each { |tag, field| self.__send__(\"#{field.name}=\", nil) }\n end",
"def clear\n ts = @_st_tableSize\n if ts > 20\n ts = 19\n end\n self.__clear(ts)\n end",
"def clear\n\t\twhile self.length > 0\n\t\t\tremove self.head\n\t\tend\n\tend",
"def clear\n\t\twhile self.length > 0\n\t\t\tremove self.head\n\t\tend\n\tend",
"def clear\n\t\twhile self.length > 0\n\t\t\tremove self.head\n\t\tend\n\tend",
"def reset\n each(&:reset)\n self\n end",
"def clear!\n @items.clear\n end",
"def clear!\n @slots.map(&:clear!)\n @filled = 0\n end",
"def remove_all()\n @items.clear()\n end",
"def clear\n @data.resize(0, 0)\n self\n end",
"def delete_all\n target.clear\n end",
"def clear\n set :map_view, nil\n set :data_set, nil\n end",
"def clear\n store.clear\n end",
"def clear\n @adapter.clear(collection)\n end",
"def clear\n @mutex.synchronize do\n @tuples.clear\n @objects.clear\n @catdata.clear\n end\n self\n end",
"def reset\n @array = nil\n end",
"def clear\n @components.clear\n end",
"def reset\n @rows = nil\n end",
"def clear\n @count = 0\n @head = nil\n @tail = nil\n end"
] | [
"0.7990437",
"0.7962762",
"0.7558882",
"0.75502926",
"0.75215465",
"0.7488922",
"0.7482482",
"0.7476773",
"0.7476773",
"0.7474873",
"0.7455337",
"0.74487585",
"0.73992544",
"0.73864233",
"0.735399",
"0.7347851",
"0.7338201",
"0.7338201",
"0.7321778",
"0.7310709",
"0.730543",
"0.73029923",
"0.73029923",
"0.73029923",
"0.73029923",
"0.73029923",
"0.73029923",
"0.73029923",
"0.7302627",
"0.7289964",
"0.7289964",
"0.7289964",
"0.7242764",
"0.7203333",
"0.7193759",
"0.71810436",
"0.71775866",
"0.71661764",
"0.71661764",
"0.7100717",
"0.7090513",
"0.7070189",
"0.7070189",
"0.7043484",
"0.7031751",
"0.70285404",
"0.7017058",
"0.7017058",
"0.7017058",
"0.70033264",
"0.6998639",
"0.6998639",
"0.6992102",
"0.69760334",
"0.69473743",
"0.69348586",
"0.69336456",
"0.6931658",
"0.6919536",
"0.6915933",
"0.6912562",
"0.6901215",
"0.6898997",
"0.6898997",
"0.686733",
"0.6866828",
"0.6863993",
"0.6858454",
"0.68556",
"0.6854375",
"0.68535584",
"0.6847385",
"0.6841685",
"0.6840854",
"0.6827483",
"0.6827483",
"0.68228275",
"0.6818898",
"0.6811643",
"0.68079585",
"0.6803478",
"0.6797554",
"0.6790347",
"0.6785485",
"0.6785485",
"0.6785485",
"0.67841595",
"0.6772284",
"0.67612445",
"0.67606205",
"0.67597747",
"0.6758162",
"0.675618",
"0.6752968",
"0.6736155",
"0.6724307",
"0.6719273",
"0.6684807",
"0.6682391",
"0.6673613"
] | 0.682065 | 77 |
The size of the index | def size
list.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size\n index.size\n end",
"def size\n index.size\n end",
"def size\n @index.size\n end",
"def size\n @index.size\n end",
"def size\n @index.keys.uniq.count\n end",
"def size()\n #This is a stub, used for indexing\n end",
"def size()\n #This is a stub, used for indexing\n end",
"def size()\n #This is a stub, used for indexing\n end",
"def dim\n @indexes.size\n end",
"def count\n index.length\n end",
"def size; @size end",
"def size= length\n #This is a stub, used for indexing\n end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size\n @n\n end",
"def size\n @n\n end",
"def size() end",
"def size() end",
"def size() end",
"def size() end",
"def size() end",
"def size() end",
"def size_index_header\n 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 8 + 2 + 8\n end",
"def length()\n #This is a stub, used for indexing\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n end",
"def size\n end",
"def chunk_size()\n #This is a stub, used for indexing\n end",
"def size\n @hash_array.length\n end",
"def size\n @hash_array.length\n end",
"def size\n return @size\n end",
"def size\n return @size\n end",
"def size\n @size\n end",
"def size\n @count\n end",
"def size\n @count\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def ntCount\n return @ntIndex.length\n end",
"def size\n return @size\n end",
"def size\n return @size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n @size\n end",
"def size\n end",
"def size\n\t\t@length\n\tend",
"def size #:nodoc:\n 1\n end",
"def size #:nodoc:\n 1\n end",
"def size\n @size.size\n end",
"def length \n io_index.length\n end",
"def length\n size\n end",
"def size\n @size ||= (@key_map || @row || []).size\n end",
"def size\n @hash.size\n end",
"def size\n @hash.size\n end",
"def size\n @hash.size\n end",
"def size\n length\n end",
"def size\n self.data.keys.size\n end",
"def length()\n #This is a stub, used for indexing\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end"
] | [
"0.9004925",
"0.9004925",
"0.8971291",
"0.8921261",
"0.8371172",
"0.8232891",
"0.8232891",
"0.81063324",
"0.80845815",
"0.78683794",
"0.78486717",
"0.77066845",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.7670265",
"0.766371",
"0.766371",
"0.7626928",
"0.7626928",
"0.7626928",
"0.7626928",
"0.7626928",
"0.7626928",
"0.7551905",
"0.75456244",
"0.7539007",
"0.7539007",
"0.7539007",
"0.7509964",
"0.7509964",
"0.75050586",
"0.7502979",
"0.7502979",
"0.74999654",
"0.74999654",
"0.7481353",
"0.7455228",
"0.7455228",
"0.7439063",
"0.7439063",
"0.7439063",
"0.74262226",
"0.74172837",
"0.74172837",
"0.7409969",
"0.7409969",
"0.7409969",
"0.7409969",
"0.7409969",
"0.7409969",
"0.7409969",
"0.7404238",
"0.74015564",
"0.73997974",
"0.7391578",
"0.7391578",
"0.7388183",
"0.7378344",
"0.7371661",
"0.7371248",
"0.73674136",
"0.73674136",
"0.73674136",
"0.73632306",
"0.7362896",
"0.73599815",
"0.73418975",
"0.73418975",
"0.73418975",
"0.73418975",
"0.73418975",
"0.73418975",
"0.73418975",
"0.73418975",
"0.73418975",
"0.73418975",
"0.73418975",
"0.73418975",
"0.73418975",
"0.73418975",
"0.73418975",
"0.73418975",
"0.73418975"
] | 0.0 | -1 |
Test inclusion, given an object. | def include?(el)
list.include?(el)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_include collection, obj, msg = nil\n assert_respond_to collection, :include?\n\n message ||= \"#{collection.inspect}\\ndoes not include\\n#{obj.inspect}.\"\n assert_block message do collection.include?(obj) end\n end",
"def assert_include(collection, object, message=nil)\n _wrap_assertion do\n assert_respond_to(collection, :include?,\n \"The collection must respond to :include?.\")\n full_message = build_message(message,\n \"<?> expected to include\\n<?>.\",\n collection,\n object)\n assert_block(full_message) do\n collection.include?(object)\n end\n end\n end",
"def include?(obj)\n false\n end",
"def include?(object)\n each {|item| return true if item == object }\n false\n end",
"def include?(obj)\n each { |o| return true if obj == o }\n false\n end",
"def include?(obj)\n if include_kind && !include_kind.any?{|kind| obj.send(kind)}\n return false\n end\n if exclude_kind && exclude_kind.any?{|kind| obj.send(kind)}\n return false\n end\n true\n end",
"def include?(obj)\n each { |o| return true if o == obj }\n false\n end",
"def link_include_object(obj); end",
"def link_include_object(obj); end",
"def assert_includes(collection, obj, msg = T.unsafe(nil)); end",
"def test_0210_includeq\n @@log.debug \"test_0210_includeq starts\" if @@log.debug?\n assert_respond_to(@list, :include?, \"test_0210_includeq_respond\")\n # Test does include\n assert(@list.include?(@bsb),\"test_0210_includeq_basic\")\n # Test does not include\n ta = Person.new(\"A\", \"B\", \"C\", 456)\n assert(@list.include?(ta) == false,\"test_0210_includeq_backwards\")\n\n @@log.debug \"test_0210_includeq ends\" if @@log.debug?\n end",
"def deny_include(collection, obj, message = nil)\n assert_respond_to collection, :include?\n message ||= \"#{collection.inspect} includes #{obj.inspect}.\"\n assert_block message do !collection.include? obj end\n end",
"def is_in(_obj)\n raise NotImplementedError\n end",
"def include? object\n !!find(object)\n end",
"def include?(object)\n records.include?(object)\n end",
"def test_includes_car\n car = Car.new\n arr = [1, 2, 3]\n arr << car\n\n assert_includes(arr, car)\n end",
"def include?(obj)\n @members.include? obj\n end",
"def refute_includes(collection, obj, msg = T.unsafe(nil)); end",
"def test_include?\n assert_includes list, 'xyz'\nend",
"def include?(arg0)\n end",
"def include?(obj)\n @data.key?(obj)\n end",
"def include?(arg_)\n _get_objdata(arg_) ? true : false\n end",
"def include?(item)\n end",
"def include?(obj)\n self.each{|*val|\n return true if val.__svalue == obj\n }\n false\n end",
"def test_not_included\n refute_includes(list, 'xyz')\nend",
"def include?(something); end",
"def in?(object)\n object.include?(self)\n end",
"def in?(object)\n object.include?(self)\n end",
"def assert_included(collection, item)\n assert_block \"#{collection} was expected to include #{item} but does not.\" do\n collection.include?(item)\n end\n end",
"def include?(arg)\n arg.is_a?(Module) ? !!included_modules.detect{ |m| m === arg } : store.include?(arg)\n end",
"def include?(path)\n path_to_object(path) ? true : false\n end",
"def test_include\n list = []\n list << 'xyz'\n assert_includes list, 'xyz'\n end",
"def include?(object)\n object.start >= @start && object.end <= @end\n end",
"def include?(item)\n return true\n end",
"def set_inclusion\n @inclusion = Inclusion.find(params[:id])\n end",
"def includes\n end",
"def includes\n end",
"def test_include\n character1 = Character.new(BLANK_RACE)\n character2 = Character.new(BLANK_RACE)\n party = Party.new([character1, Character.new(BLANK_RACE)])\n assert(party.include?(character1), \"Party should include the character\")\n refute(party.include?(character2), \"Party should not include the character\")\n end",
"def check_object(object)\n return add_node(object) unless include_object?(object)\n if is_node?(object)\n object\n else\n get_node(object)\n end\n end",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def include?( object )\n has_node?( object ) ||\n has_edge?( object )\n end",
"def test_include(all,one)\n return expect(all).to include(one)\n end",
"def test_include(all,one)\n return expect(all).to include(one)\n end",
"def test_include(all,one)\n return expect(all).to include(one)\n end",
"def assert_not_include(collection, object, message=nil)\n _wrap_assertion do\n assert_respond_to(collection, :include?,\n \"The collection must respond to :include?.\")\n full_message = build_message(message,\n \"<?> expected to not include\\n<?>.\",\n collection,\n object)\n assert_block(full_message) do\n not collection.include?(object)\n end\n end\n end",
"def include_object?(object)\n if is_node?(object)\n @nodes.each { |node| return true if node == object }\n else\n @nodes.each { |node| return true if node.object == object }\n end\n\n false\n end",
"def include?(name); end",
"def included(object)\n super\n\n Flaggable.setup_flaggable_object(object)\n\n # Add the feature check methods to the object's internal feature class.\n #\n object.instance_feature_class.internal_feature_checks_module.include internal_feature_checks_module\n\n # Because we added feature check methods above, include again to make them available.\n #\n object.instance_feature_class.include object.instance_feature_class.internal_feature_checks_module\n\n # Add the feature methods to the object's internal feature class.\n #\n object.instance_feature_class.internal_feature_module.include internal_feature_module\n\n # Add our feature flags to the object's feature flags.\n #\n object.instance_feature_class.feature_flags.concat(feature_flags)\n end",
"def included(klass); end",
"def included(klass); end",
"def contains_object(obj_name)\n key = obj_name.to_s\n @defs.keys.member?(key) or extra_inputs_has(key)\n end",
"def assert_includes_module( mod_or_class, mod, msg = nil )\n # Make sure we've been passed the proper sort of objects\n assert mod_or_class.respond_to?( :included_modules, \"#{mod_or_class} doesn't respond to included_modules()\" )\n raise ArgumentError.new( \"#{mod} is not a module\" ) unless mod.kind_of?( Module )\n\n msg = message(msg){ \"#{mod_or_class} should have included module #{mod}\" }\n \n assert mod_or_class.included_modules.include?(mod), msg\n end",
"def set_inclusion\n @inclusion = DeckInclusion.find(params[:id])\n end",
"def include?( index_name = nil, object = nil, & block )\n \n return_value = nil\n \n if index_name\n return_value = index( index_name ).include?( object, & block )\n else\n return_value = super( object, & block )\n end\n \n return return_value\n \n end",
"def include?(o)\n @hash[o]\n end",
"def include?(obj)\n n = 0\n lim = self.__size\n while n < lim\n if self.__at(n) == obj\n return true\n end\n n += 1\n end\n false\n end",
"def confirm_inclusion(album)\n begin\n ret = false\n category = album['Category'] ? album.Category.Name.to_s : ''\n subCategory = album['SubCategory'] ? ' / ' + album.SubCategory.Name.to_s : ''\n $stderr.print \"Include: \" + category + subCategory + ' / ' + album.Title + ' ? (y|N|x) '\n response = $stdin.gets\n return nil if (response =~ /^x/i)\n return (response =~ /^y/i) ? true : false\n rescue Exception => e\n return nil\n end\nend",
"def included?\n @_included\n end",
"def include?(o)\n @hash.include?(o)\n end",
"def canAddItemToVest _obj, _args\n \"_obj canAddItemToVest _args;\" \n end",
"def include?(name)\n includes?(name)\n end",
"def conditions_met?(object, associations); end",
"def including?(a_user)\n inclusions.find_by_included_user_id(a_user.id)\n end",
"def creating_object_association_for?(object, association)\n object_associations[object.bullet_key].present? &&\n object_associations[object.bullet_key].include?(association)\n end",
"def exists(_obj)\n raise NotImplementedError\n end",
"def test_e123_include_intersect\n verify_method :e123_include_intersect,\n :with =>\n [\n {\n params: [2, 1, 2],\n predicate: Proc.new { |all, intersect, include| check_included_intersected(2, 1, 2, all, intersect, include) }\n },\n {\n params: [5, 1, 10],\n predicate: Proc.new { |all, intersect, include| check_included_intersected(5, 1, 10, all, intersect, include) }\n }\n ]\n\n end",
"def assert_includes(collection, member, message=nil) \n IncludeAssay.assert!(collection, member, :message=>message, :backtrace=>caller)\n end",
"def can_have_associated_objects?(obj)\n true\n end",
"def include?(item)\n ret = false\n @resources.each{ |rsc| ret = true if rsc == item }\n @authors.each{ |auth| ret = true if auth == item } unless ret \n ret\n end",
"def isKindOf _obj, _args\n \"_obj isKindOf _args;\" \n end",
"def include?(item)\r\n $game_party.usable?(item)\r\n end",
"def included(mod); end",
"def match(object); end",
"def assertKindOfTest klass, object\n assertKindOf klass, object\n end",
"def include(*expected)\n Matchers::Include.new(*expected)\n end",
"def include?(item)\n self.__contains__(item).rubify\n end",
"def canAddItemToUniform _obj, _args\n \"_obj canAddItemToUniform _args;\" \n end",
"def include?(arg)\n case arg\n when Symbol\n !lookup_name(arg.id2name).nil?\n when String\n !lookup_name(arg).nil?\n when Integer\n !lookup_id(arg).nil?\n when self\n possible_match = lookup_id(arg.id)\n !possible_match.nil? && possible_match == arg\n else\n false\n end\n end",
"def included; end",
"def using_include(array, element)\n\tarray.include?(element)\nend",
"def include?\n @options[:include]\n end",
"def test_that_include_method_works\n tree = BinarySearchTree.new\n tree.insert(60, \"movie a\")\n assert tree.include?(60)\n end",
"def not_in(_obj)\n raise NotImplementedError\n end",
"def include?(o)\n @hash.has_value?(o)\n end",
"def inclusion(attrs, array)\n Array(attrs).each do |attr|\n error(attr, \"should be one of #{array}\") unless array.include?(@object.send(attr))\n end\n end",
"def test_object\n obj = Object.new\n assert_equal(\"Is ruby object passed? ... true\",\n \"Is ruby object passed? ... #{car(cons(obj, nil)) == obj}\")\n end",
"def ==(obj)\n obj.is_a?(ScrapedObjectResult) &&\n base_object_klass == obj.base_object_klass &&\n id == obj.id \n end",
"def includes item\n msg = \"#{self} did not include #{item}\"\n check_if self.include?(item), msg\n end",
"def validate_inclusion_of(attr, options = { })\n EdgeCase::RSpecExpectationMatchers::ProvidesFor::ActiveRecord::ValidatesInclusionOf.new(attr, options)\n end",
"def on_include(&block)\n self.inclusion = block\n self\n end",
"def releasable?(obj)\n \tif is_approved_draft?(obj.release_status)\n \t\tif is_section_head?\n \t\t\tif (obj.uploader_role == 'Normal' && uploader_from_same_section(obj.uploaded_by_section))\n \t\t\t\ttrue\n \t\t\tend\n \t\telsif is_department_head?\n \t\t\tif obj.uploader_role == 'Sectionhead'\n \t\t\t\ttrue\n \t\t\tend\n \t\tend\n \tend\n end",
"def test_template_objects_alive\n process :assign_this\n assert !@response.has_template_object?('hi')\n assert @response.has_template_object?('howdy')\n end",
"def identifies_as?( object )\n \n return ::IdentifiesAs.object_identifies_as?( self, object ) \n \n end",
"def include; end",
"def include; end",
"def assert_has_stream_for(object); end"
] | [
"0.70792687",
"0.68800586",
"0.67808855",
"0.66712016",
"0.66225934",
"0.6603678",
"0.65995663",
"0.6597239",
"0.6597239",
"0.64808583",
"0.6416508",
"0.63551056",
"0.63488597",
"0.6271307",
"0.6248458",
"0.6222926",
"0.6210622",
"0.62017757",
"0.6195194",
"0.6175727",
"0.6173598",
"0.6084869",
"0.60759956",
"0.60591817",
"0.60500014",
"0.60354185",
"0.6024551",
"0.6024551",
"0.5969622",
"0.59441173",
"0.5943377",
"0.59391415",
"0.59050924",
"0.58320844",
"0.58127713",
"0.57714397",
"0.57714397",
"0.5771321",
"0.5757512",
"0.57563925",
"0.57557136",
"0.57557136",
"0.57557136",
"0.57557136",
"0.57557136",
"0.5746134",
"0.57188714",
"0.57188714",
"0.57188714",
"0.56964606",
"0.5694432",
"0.5689193",
"0.56302506",
"0.5605923",
"0.5605923",
"0.55978924",
"0.5596275",
"0.55955076",
"0.5570226",
"0.5559465",
"0.5530848",
"0.55304116",
"0.55124724",
"0.5509865",
"0.55036",
"0.54912573",
"0.54875463",
"0.5454809",
"0.54506075",
"0.5419036",
"0.54126275",
"0.54064393",
"0.53958833",
"0.53927386",
"0.5377116",
"0.53761744",
"0.5375094",
"0.5373347",
"0.5372821",
"0.5363118",
"0.5360444",
"0.5359848",
"0.5359819",
"0.53431964",
"0.53379935",
"0.5306437",
"0.5305749",
"0.5302523",
"0.52978265",
"0.52859485",
"0.52854264",
"0.52837473",
"0.528154",
"0.5273728",
"0.5272508",
"0.5270904",
"0.52677375",
"0.52662677",
"0.5264966",
"0.5264966",
"0.52592635"
] | 0.0 | -1 |
Test inclusion, given a key | def has_key?(name)
hashed.has_key? name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def include?(key); end",
"def include?(key); end",
"def include_key?(key)\n\t\t\ttrue\n\t\tend",
"def include?(key)\n has_key?(key)\n end",
"def include?(key)\n Options.check_valid_key(key)\n @data.include?(key.to_sym)\n end",
"def include?(key)\n # Ensure a Ruby true is returned\n item_exists(key) == true\n end",
"def include?(key)\n @item.key?(key)\n end",
"def include?(key)\n @item.key?(key)\n end",
"def include?(key)\n @hash.has_key?(key.to_s)\n end",
"def include?(key)\n key_to_hashes(key).all? do |hash|\n filter.set?(hash)\n end\n end",
"def include?(key)\n value.include?(key)\n end",
"def include?(key)\n @dao.count(selector(key)) > 0\n end",
"def include?(key)\n @data.include? key\n end",
"def include?(key)\n @collection.include?(key)\n end",
"def include?(key)\n key = key.to_sym\n cache.keys.include?(key) || values.keys.include?(key)\n end",
"def include?(key)\n return false unless @data.is_a?(Hash)\n\n @data.include?(compatible_key(key))\n end",
"def include?(key)\n key = key.to_sym\n cache.keys.include?(key) || values.keys.include?(key)\n end",
"def key?(key)\n keys.include?(key) || keys.map(&:to_s).include?(key)\n end",
"def key?(key)\n keys.include?(key) || keys.map(&:to_s).include?(key)\n end",
"def include?(key)\n self.each_key.any? { |k|\n k.casecmp?(key)\n }\n end",
"def include?(key)\n\t\tself.keywords.include?(key)\n\tend",
"def item_included?(str, hash)\n hash.each do |key, value|\n return true if key == str\n end\n false\nend",
"def has_key?(key); end",
"def has_key?(key); end",
"def include?(key)\n @driver.include?(key)\n end",
"def include? key\n\t\t@data_base.has_key? key\n\tend",
"def has_key?(key)\n keys.include?(key)\n end",
"def key?(key); end",
"def key?(key); end",
"def key?(key); end",
"def key?(key); end",
"def key?(key); end",
"def key?(key); end",
"def include?(key = nil)\n key ||= Stash.caller_name\n @store.include? key.to_sym\n end",
"def in?(key)\n return true if get(key)\n false\n end",
"def include?(key)\n @services.key?(key)\n end",
"def include?(key)\n return false if @binding && !@object.include?(key) && (parts?(key) && !parts_for(key).content?)\n respond_to?(key) || @object.include?(key)\n end",
"def contains?(key)\n @key_data.has_key?(key)\n end",
"def include?(key)\n status = @repo.staging_area.file_status(key)\n ![:unknown, :removed].include?(status)\n end",
"def string_include_key?(string, key)\n \nend",
"def string_include_key?(string, key)\n \nend",
"def string_include_key?(string, key)\n \nend",
"def test_Hash_InstanceMethods_include?\n\t\th = {'a'=>100, 'b'=>200}\n\t\tassert_equal(true, h.include?('a'))\n\t\tassert_equal(true, h.include?('b'))\n\t\tassert_equal(false, h.include?('c'))\n\tend",
"def has_key?(key)\n params.keys.include?(key)\n end",
"def include?(key)\n File.exist?(cache_path(key))\n end",
"def has_key?(key)\n any? {|mod| mod.name == key}\n end",
"def include?(key = nil)\n key ||= BasicCache.caller_name\n key = key.to_sym\n @store.include?(key) && Time.now - @store[key].stamp < @lifetime\n end",
"def include?(key)\n found = structures.reverse_each.find { |container| container.include?(key) }\n !found.nil? && (found[key] != Utils::DeletedMarker)\n end",
"def has_key? key; key? key; end",
"def contains?(key)\n not get(key).nil?\n end",
"def has_key?(p0) end",
"def include?(key)\n current = @head\n while current.next_node != nil\n return true if current.value == key\n current = current.next_node\n end\n\n return true if current.value == key\n\n false\n end",
"def capable?(key); end",
"def has_key? key\n (self.class.order + @order).include? key\n end",
"def include?(key)\n\t\t\t\tsuper || @l2.include?(key)\n\t\t\tend",
"def ext_include?(key_world)\n map { |e| e.include?(key_world) }.any?\n end",
"def always_return_key?(key)\n key.start_with?('activerecord.attributes.', 'user.', 'sample.', 'helpers.')\n end",
"def contains?(key)\n @semaphore.synchronize {\n @key_data.has_key?(key)\n }\n end",
"def include?(v)\n\t\t\t\t@lookup.has_key?(v)\n\t\t\tend",
"def valid?(key)\n MENUS.keys.map(&:to_sym).include?(key.to_sym)\n end",
"def includes?(array, target)\n array.each do |k, v|\n if k == key\n return true\n elsif v.class.to_s == \"Array\"\n v.each do |inner_array|\n return has_key(inner_array, key)\n end\n else\n return false\n end\n end\n\nend",
"def key?(key)\n @items.key?(key)\n end",
"def includes!(*keys)\n keys.to_sargs.all? {|k| v = self[k]; !v.nil? && !(v.is_a?(String) && v.empty?) }\n end",
"def key?(key)\n\t\t\t\tif key\n\t\t\t\t\t@keyed.key?(key)\n\t\t\t\tend\n\t\t\tend",
"def has_key?( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && contains_key( key )\n end",
"def key?(key, options = {})\n load(key, options) != nil\n end",
"def include?(entry)\n @cache.has_key?(key_for(entry))\n end",
"def my_include?(dict, query)\n dict.each do |valid_word|\n if valid_word == query\n return true\n end\n end\n return false\nend",
"def include?(key)\n is_array = Array.try_convert(key) ? true : false\n arr_key = is_array ? key : [key]\n hsh_key = {}\n\n arr_key.each do |k|\n indexes = []\n indexes_for(k) { |idx| indexes << idx }\n hsh_key[k.to_s] = {key: k, future: [], included: true, indexes: indexes}\n end\n\n # if the first bit returned from redis is 0 we don't look at this any further?\n @redis.pipelined do\n hsh_key.each_pair do |k,v|\n v[:future][0] = @redis.getbit(@options[:key_name], v[:indexes].shift)\n end\n end\n\n @redis.pipelined do\n hsh_key.each_pair do |k,v|\n # filter all that are 0\n # 0 means this element is not within the bloomfilter, no need for further lookup\n next if v[:future][0].value == 0\n v[:indexes].each_with_index do |idx, i|\n v[:future][i+1] = @redis.getbit(@options[:key_name], idx)\n end\n end\n end\n\n in_filter = []\n hsh_key.each_pair do |k,v|\n # if we have a zero in our result array we (most likely) havent seen this value yet\n # if we don't have a zero in our result array we (most likely) have seen this value already\n in_filter << k unless v[:future].map{|f|f.value}.include?(0)\n end\n\n unless is_array\n if in_filter.length == 1\n return true\n else\n return false\n end\n end\n\n return in_filter\n end",
"def key?(key)\n super(convert_key(key))\n end",
"def key?(key)\n configuration.key?(key)\n end",
"def supported_key?(key)\n Primer::Classify::UTILITIES[key].present?\n end",
"def string_include_key?(string, key)\n return false if string.length < key.length\n key.each_char do |ele|\n return true if string.include?(ele)\n end\n\n \nend",
"def add?(key)\n hashes = key_to_hashes(key).reject { |hash| filter.set?(hash) }\n hashes.each { |hash| filter.set!(hash) }\n hashes.any?\n end",
"def include?(key)\n is_array = Array.try_convert(key) ? true : false\n arr_key = is_array ? key : [key]\n hsh_key = {}\n\n arr_key.each do |k|\n hsh_key[k] = {key: k, future: [], indexes: indexes_for(k) }\n end\n\n # if the first bit returned from redis is 0 we don't look at this any further?\n @redis.pipelined do\n hsh_key.each_pair do |k,v|\n v[:future][0] = @redis.getbit(@options[:key_name], v[:indexes].shift)\n end\n end\n\n @redis.pipelined do\n hsh_key.each_pair do |k,v|\n # filter all that are 0\n # 0 means this element is not within the bloomfilter, no need for further lookup\n next if v[:future][0].value == 0\n v[:indexes].each_with_index do |idx, i|\n v[:future][i+1] = @redis.getbit(@options[:key_name], idx)\n end\n end\n end\n\n in_filter = []\n hsh_key.each_pair do |k,v|\n # if we have a zero in our result array we (most likely) havent seen this value yet\n # if we don't have a zero in our result array we (most likely) have seen this value already\n in_filter << k unless v[:future].map{|f|f.value}.include?(0)\n end\n\n # handle single element case\n unless is_array\n if in_filter.length == 1\n return true\n else\n return false\n end\n end\n\n return in_filter\n end",
"def include?(v)\n @c.get(v.to_s) == v\n end",
"def params_has_key *args\n args.each do |key|\n unless params.has_key? key.to_s\n return false\n end\n end\n return true\nend",
"def key?(key)\n super(convert_key(key))\n end",
"def key?(key)\n super(convert_key(key))\n end",
"def contains_expected_keys?(data, *expected_keys)\n expected_keys.each do |expected_key|\n return false until data.keys.include? expected_key\n end\n return true\nend",
"def has_key?(key)\n super(convert_key(key))\n end",
"def has_key?(key)\n super(convert_key(key))\n end",
"def has_key?(key)\n\t\tmust_be_in_synchronize_block\n\t\treturn @collection.has_key?(key)\n\tend",
"def used_key?(key, strict = false)\n used_key_names(strict).include?(key)\n end",
"def member_of?(key, value)\n val = get(key)\n val and val.include?(value)\n end",
"def in?(key)\n start_slot = hasher(key, @keys.size)\n position = start_slot\n found = false\n\n while @keys[position] != nil and !found\n if @keys[position] == key\n found = true\n else\n position = rehash(position, @keys.size)\n break if position == start_slot\n end\n end\n\n found\n end",
"def includes? hash\n hash.each_pair do |key, value|\n return false unless send(\"#{key}\") == value\n end\n true\n end",
"def key?(key)\n public_method_defined?(key.to_sym)\n end",
"def include?(entry)\n @index.has_key?(entry)\n end",
"def include?(o)\n @hash[o]\n end",
"def registered?(key)\n data.key?(key)\n end",
"def verify_key(key, context = nil)\n key && String(key)\n end",
"def has?(key)\n respond_to? key\n end",
"def has_key?(key)\n raise NotImplementedError\n end",
"def has_key?(field_name); end",
"def include?(aNode)\n key2node.include?(aNode)\n end",
"def key?(key)\n @configuration.key?(key)\n end",
"def include?(item)\n end",
"def has_key?(attr_name)\n keys.include?(attr_name.to_s)\n end",
"def authenticate?(attribute, key)\n if attribute.include key\n return true\n else\n return false\n end\n end",
"def include?(item)\r\r\n item[:discovered]\r\r\n end"
] | [
"0.819327",
"0.819327",
"0.80304337",
"0.7812022",
"0.7755964",
"0.75676215",
"0.754065",
"0.754065",
"0.7508924",
"0.74936813",
"0.74640435",
"0.7443972",
"0.73460233",
"0.7286211",
"0.71615535",
"0.7156305",
"0.71237874",
"0.710555",
"0.710555",
"0.7105036",
"0.7067437",
"0.7045424",
"0.7020607",
"0.7020607",
"0.70085514",
"0.69238514",
"0.6894054",
"0.685349",
"0.685349",
"0.685349",
"0.685349",
"0.685349",
"0.685349",
"0.67934597",
"0.67932004",
"0.67278296",
"0.6723557",
"0.6659582",
"0.66266024",
"0.66248786",
"0.66248786",
"0.66248786",
"0.6619646",
"0.6605913",
"0.6592389",
"0.6588574",
"0.6565387",
"0.6561971",
"0.6553885",
"0.65341747",
"0.65265405",
"0.65092486",
"0.65092283",
"0.65037405",
"0.6488984",
"0.6474143",
"0.6473236",
"0.64582974",
"0.6403047",
"0.63854706",
"0.63578165",
"0.6334479",
"0.6328125",
"0.6311003",
"0.62888813",
"0.628544",
"0.6279113",
"0.62453204",
"0.6240035",
"0.62349075",
"0.6221998",
"0.62219894",
"0.6202391",
"0.61991143",
"0.61897427",
"0.6187933",
"0.6184365",
"0.61681813",
"0.61681813",
"0.6156441",
"0.6133333",
"0.61291796",
"0.6120721",
"0.61128134",
"0.6108179",
"0.609665",
"0.60854536",
"0.60719895",
"0.6071761",
"0.6069336",
"0.6062519",
"0.6062037",
"0.6061588",
"0.60534203",
"0.60480136",
"0.6047684",
"0.604349",
"0.6041488",
"0.60320413",
"0.6027223",
"0.602289"
] | 0.0 | -1 |
Add an object to the index. | def add(obj)
return self if self.has_key? name_of(obj)
hook_wrap :add, obj do
begin
name = name_of(obj)
insert_sorted(obj)
hashed[name] = obj
obj
rescue Exception => e
delete(name)
raise e
end
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(object)\n push(new_entry_for_object(object))\n end",
"def add_object(object, objectID = nil, request_options = {})\n check_object(object)\n if objectID.nil? || objectID.to_s.empty?\n client.post(Protocol.index_uri(name), object.to_json, :write, request_options)\n else\n client.put(Protocol.object_uri(name, objectID), object.to_json, :write, request_options)\n end\n end",
"def add(obj)\n @set.addObject obj\n end",
"def add(id, object)\n self.objects[id] = object\n end",
"def <<(index)\n @indexes[index.name] = index\n end",
"def add(record)\n handle_drb_error { @server.add index_name, record.to_doc }\n end",
"def add_object(object)\n\t\t\t\tfname=\"ArWorkitem.\"+__method__.to_s\n\t\t\t\tret=0\n\t\t\t\ttype_object=object.model_name\n\t\t\t\tfields = self.field_hash\n\t\t\t\tif fields == nil\n\t\t\t\t\tfields = {}\n\t\t\t\t\tfields[\"params\"] = {}\n\t\t\t\tend\n\t\t\t\turl=\"/\"+type_object+\"s\"\n\t\t\t\turl+=\"/\"+object.id.to_s\n\t\t\t\tlabel=type_object+\":\"+object.ident\n\t\t\t\tunless fields[\"params\"][url]==label\n\t\t\t\t\tfields[\"params\"][url]=label\t\n\t\t\t\t\tret+=1\n\t\t\t\t\tself.replace_fields(fields)\n\t\t\t\telse\n\t\t\t\t\tLOG.info (fname) {\"objet deja present dans cette tache\"}\n\t\t\t\tend\n\t\t\t\tret\n\t\t\tend",
"def add(object)\n @objects << object\n end",
"def add(o); addObject o end",
"def add( resource )\n entries.merge!( resource.index_dump )\n mark_modified\n end",
"def insert(index,object)\n\nend",
"def add(class_name, object)\n @data = get_all()\n \n @data[class_name].push(object.to_hash())\n \n save()\n end",
"def store(obj_type, name, object)\n validate(\n {\n :obj_type => obj_type,\n :name => name,\n :object => object,\n },\n {\n :object => { :respond_to => :to_json },\n }\n )\n rows = get_view(\"id_map\", \"name_to_id\", :key => [ obj_type, name ])[\"rows\"]\n uuid = rows.empty? ? UUIDTools::UUID.random_create.to_s : rows.first.fetch(\"id\")\n\n db_put_response = @rest.put_rest(\"#{couchdb_database}/#{uuid}\", object)\n\n if object.respond_to?(:add_to_index)\n Chef::Log.info(\"Sending #{obj_type}(#{uuid}) to the index queue for addition.\")\n object.add_to_index(:database => couchdb_database, :id => uuid, :type => obj_type)\n end\n\n db_put_response\n end",
"def add_to_index(item)\n @content << '\\index{' + (item) + '}'\n end",
"def write object, index\n raise NotImplementedError\n end",
"def safe_add_index(*args, **options); end",
"def insert(index, object)\n # raises IndexOutOfBoundsException if index is out of bounds [0, @length)\n # TODO\n end",
"def add(file)\n # add file to object db\n return false if !File.exists?(file)\n return false if !File.file?(file)\n \n sha = get_raw_repo.put_raw_object(File.read(file), 'blob')\n \n # add it to the index\n @git_index.add(file, sha)\n end",
"def add(object, parent=nil)\n iter = self.append parent\n case object\n when Hash\n update_iter_from_hash iter, object\n else\n update_iter_from_object iter, object\n end\n iter[ self.class.column_id[:object] ] = object\n iter\n end",
"def insert( object, tier_index )\n ensure_tiers(tier_index) if @extend\n \n @length += 1\n @tiers[tier_index].unshift object\n end",
"def add_at_index(index, val)\n \n end",
"def index(obj)\n if @index && !loaded?\n @index.call(obj)\n else\n super\n end\n end",
"def add_object(obj)\n sym = obj.class.to_s.to_sym\n\n unless @list.has_key?(sym)\n @list[sym] = []\n end\n\n @list[sym].push(obj)\n end",
"def addItemToVest _obj, _args\n \"_obj addItemToVest _args;\" \n end",
"def add(path, data='', on_fs=false)\n exec { index.add(path, data, on_fs) }\n end",
"def add(type_, object_)\n @config.lock\n\n # Some sanity checks of the arguments.\n if object_.nil?\n raise ObjectKeyError, \"Attempt to add a nil object\"\n end\n unless @types.has_key?(type_)\n raise ObjectKeyError, \"Unrecognized type: #{type_}\"\n end\n\n # Synchronize the actual add to protect against concurrent mutation.\n @mutex.synchronize do\n _internal_add(type_, object_, nil, nil)\n end\n self\n end",
"def << (obj)\n @objects << obj if obj\n end",
"def add obj\n\t\t\t@objs2 += [obj] \n\t\tend",
"def addItem _obj, _args\n \"_obj addItem _args;\" \n end",
"def add\n puts \"Adding the following URL to the index: #{url}\".green\n update_attributes!(:title => title,\n :keywords => keywords,\n :created_at => Time.now,\n :updated_at => Time.now)\n end",
"def add_to_index(key, item)\n index = @indexes[key]\n index[item] = index[item].nil? ? [page_number] : index[item] << page_number\n end",
"def add(bucket, obj)\n @buffer[bucket] << obj\n check_and_write bucket\n end",
"def add(obj)\n Maglev::PERSISTENT_ROOT[self][obj.__id__] = obj\n end",
"def add_to_index(name, key, node); end",
"def insert_object g\n @objects.add g\n end",
"def add_index(entity, field, value)\n return false unless index?(field)\n if (java_array?(value))\n conv_value = value.map{|x| indexed_value_for(field, x)}.to_java(Java::OrgNeo4jIndexLucene::ValueContext)\n else\n conv_value = indexed_value_for(field, value)\n end\n index = index_for_field(field.to_s)\n index.add(entity, field, conv_value)\n end",
"def add(o)\n @hash[o] = true\n self\n end",
"def <<(object)\n # TODO\n end",
"def add_to_index(index, a, b, c)\n begin\n index[a][b] << c\n rescue\n index[a] ||= {}\n index[a][b] = [c]\n end\n # The old, slow way of doing things...the new way is nearly linear at\n # 0.0005 seconds per transaction at 100 inserts\n # and 0.000529 seconds per transaction at 10,000 inserts.\n # \n # if index.keys.include?(a) and index[a].keys.include?(b)\n # index[a][b] << c\n # elsif index.keys.include?(a)\n # index[a][b] = [c]\n # else\n # index[a] = {}\n # index[a][b] = [c]\n # end\n end",
"def add_at(index,value)\n raise \"Index is lower that current index\" if index < max_index\n\n @add_at_next = index + 1\n pos = position_for_index(index)\n\n if out_of_range?(index)\n @store.fill_with_nils\n elsif higher?(index)\n (pos-1).downto(@position) { |i| @store.put(i,nil) } if @current_index >= @size\n @store.put(pos,nil) # We clean the value, if not it gets used by @before_add\n end\n\n set_value(pos,value)\n @position = pos + 1\n @current_index = index\n self\n end",
"def add_at(obj, tx, ty)\n if @classes.include?(obj.class)\n @grid[tx][ty] = obj\n end\n rescue NoMethodError\n warn(\"WARNING: Tried to insert element at invalid index (#{obj}, #{tx}|#{ty})\")\n add(obj)\n end",
"def add_index(*fields)\n @add_indexed_field = fields\n end",
"def add(point, index, attrib, metadata = nil)\n item = node_class.new(point, attrib, @insert_point, metadata)\n @lookup[index] = item\n @items[@insert_point] = item\n heapify(@insert_point)\n @insert_point += 1\n end",
"def save(obj)\n return true if index_current? obj\n\n delete obj, true\n\n update_index obj, false do |item|\n item.add ids: [obj.id]\n\n if obj.respond_to? :ttl\n item.set ttl: obj.ttl.to_f\n end\n end\n end",
"def << (record)\n raise \"Obj should be a Record\" unless record.class == Record\n @entries << record\n end",
"def add(index, type, id, doc, params={})\n doc.each do |key, val|\n # make sure dates are in a consistent format for indexing\n doc[key] = val.iso8601 if val.respond_to?(:iso8601)\n end\n\n resp = put do |req|\n req.url \"/#{index}/#{type}/#{id}\", params\n req.body = doc\n end\n resp.body\n end",
"def add_to_index(records, **opt)\n fields = records.map(&:emma_metadata)\n $stderr.puts \"=== STEP #{__method__} | #{Emma::ThreadMethods.thread_name} | #{records.size} recs = #{records.map { |r| manifest_item_id(r) }} | #{fields.size} fields = #{fields.inspect.truncate(1024)}\" # TODO: testing - remove\n result = ingest_api.put_records(*fields)\n remaining, failure = process_ingest_errors(result, *records)\n\n opt[:success] = 'indexed' # TODO: I18n\n opt[:meth] = __method__\n opt[:initial] = { failure: failure }\n\n now = DateTime.now\n run_step(remaining, **opt) do |_id, rec|\n rec.update_columns(last_indexed: now)\n end\n end",
"def assignAsCargoIndex _obj, _args\n \"_obj assignAsCargoIndex _args;\" \n end",
"def add_index(table, fields, **kwargs)\n current_instructions << Instructions::AddIndex.new(\n **kwargs,\n table: table,\n fields: fields,\n )\n end",
"def add(idx)\n # Don't need to worry about duplicates thanks to Set data structure.\n stack.last << idx\n end",
"def add_record(record)\n return unless allow_indexing?(record)\n\n condensed_record = condense_record(record)\n atoms = add_occurences(condensed_record, record.id)\n\n @storage.add(atoms)\n end",
"def add_to_index(vendor_prod_id, name, severity)\n year = NvdFileSystem::year_from_name(name)\n\n path=\"#{@nvdfs.root_path}/index\"\n Dir.mkdir path unless Dir.exist? path\n path += \"/#{year}\"\n Dir.mkdir path unless Dir.exist? path\n path += \"/#{vendor_prod_id}\"\n\n\n idx = NvdfsSimpleIndex.load path\n idx.add(severity, name)\n idx.save\n\n end",
"def push!(obj)\n @objs << obj\n end",
"def add_to_index(wiki, index, sha, files)\n end",
"def add_index_field(*) super end",
"def add_object o\n return if @objects.include?(o)\n @objects << o\n if o.is_a? Symbol\n @symbols << o\n end\n end",
"def add(item)\n raise \"Not a MinisearchDocument object\" unless item.kind_of?(Document)\n items << item\n item.id\n end",
"def fast_add(path, data='', on_fs=false)\n # TODO: verify that this will suffice\n index.add(path, data, on_fs)\n end",
"def add(regionEnd, obj)\n @map.push [regionEnd, obj]\n @sorted = false\n end",
"def op_add!(field, objects)\n operate_field! field, { __op: :Add, objects: objects }\n end",
"def store obj, msg\n Dir.chdir(working_dir) do\n dirname = File.dirname(obj.path)\n FileUtils.mkdir_p(dirname) unless File.directory?(dirname)\n File.open(obj.path, 'w'){ |f| f.write(obj.content) }\n add(obj.path)\n end\n commit_index(msg)\n end",
"def <<( obj )\n\n write( obj ) do |target, object|\n if object.respond_to?( :new? ) && object.new?\n @delayed_writes.push( object )\n else\n\n link = { 'rel' => rel_for_object( object ), 'href' => id_for_object( object ) }\n target.push( link ) unless target.include?( link )\n end\n end\n end",
"def add(object)\n @inventory << object\n\n object.container = @game_object_id\n\n if object.is_a? Player or object.is_a? Mobile\n object.update_display\n end\n end",
"def add(x)\r\n if (x.kind_of?(Hashable))\r\n pos = position(x)\r\n\r\n @array[pos].insert(x) # add it to the hash table, should I add x or hash?\r\n #return nil #do we need to put this in or is it set by default\r\n @items += 1\r\n else\r\n raise ArgumentError, \"Argument not of type Hashable\"\r\n end\r\n end",
"def insert(obj)\n obj.og_insert(self)\n end",
"def queue( object, tier_index )\n ensure_tiers( tier_index ) if @extend\n \n @length += 1\n @tiers[tier_index] << object\n end",
"def create(key, item)\n raise NotImplementedError, \"#{__method__} has not been implemented for this #{name} index\"\n end",
"def add(x)\n unless include?(x)\n @indices[x] = @content.size\n @content.push(x)\n end\n end",
"def add(course_object)\n self.items << course_object\n end",
"def add(obj, width)\n @objs << obj\n @width += width\n end",
"def add item\n self[index item] = item if check item\n# check item ? super : free key # delete key\n end",
"def add(item)\n self[to_identifier(item)] = item\n end",
"def add( object=nil, **fields )\n\t\tself.log.debug \"Adding %p\" % [ object || fields ]\n\t\tevent = @event_stack.value.last or return\n\n\t\tif object\n\t\t\tobject_fields = self.fields_from_object( object )\n\t\t\tfields = fields.merge( object_fields )\n\t\tend\n\n\t\tevent.merge( fields )\n\tend",
"def add_at_index(index, val)\n return if index > @list.size \n @list.insert(index, val)\n end",
"def add(path, data='', on_fs=false)\n self.stage { |idx| idx.add(path, data, on_fs) }\n end",
"def push(obj)\n @queue.put(obj)\n end",
"def update_and_add(index_search=:DontSearchForThis_195151c48a254db2949ed102c81ec579, update_hash, &block_search)\n self.clone.update_and_add!(index_search, update_hash, &block_search)\n end",
"def add(name, obj)\n if @events[name] && !@events[name].include?(obj)\n @events[name] << obj\n else\n @events[name] = [obj]\n end\n end",
"def add(item)\n @data[item] = true\n self\n end",
"def add\n end",
"def add\n end",
"def store_new(object)\n raise IdentityConflict if contains?(object)\n store(object)\n end",
"def add(k, v)\n\t\titem = Item.new(k, v)\n\t\t@h.add(item)\n\t\treturn\n\tend",
"def add_row(obj)\n obj = DataRow.new(obj) unless obj.is_a?(DataRow)\n raise(StandardError, \"wrong row size #{obj.cells_count}, should be #{columns_count})\") if obj.cells_count != columns_count\n obj.close\n @rows << obj\n self\n end",
"def add(path)\n blob = GitRb::Blob.new(path)\n FileUtils.mkdir_p(blob.directory)\n File.open(blob.object_path, 'w') { |f| f.write(blob.deflated_content) }\n GitRb::Index.new.add(blob)\n end",
"def add(object)\n begin\n target = Target.new(object, self)\n rescue\n error \"Error parsing target '#{object[Bee::Target::KEY]}': #{$!}\"\n end\n error \"Duplicate target definition: '#{target.name}'\" if\n @hash.has_key?(target.name)\n @hash[target.name] = [target]\n # record first target for default\n end",
"def write_document_to_index(document)\n\n end",
"def put_item(table_name, object)\n table = data[table_name]\n table[:data][object[table[:hash_key]]]\n table[:data][\"#{object[table[:hash_key]]}.#{object[table[:range_key]]}\"] = object.delete_if{|k, v| v.nil? || (v.respond_to?(:empty?) && v.empty?)}\n rescue\n raise data.inspect\n end",
"def add(data)\n create(data)\n end",
"def add(data)\n create(data)\n end",
"def createIndex(collection, indexObject)\n collection.indexes.create_one(indexObject)\n end",
"def add(o)\n really_added = false\n oh = o.hash\n unless @hash.key?(oh)\n really_added = true\n @hash[oh] = o\n @plans << o\n end\n really_added \n end",
"def register_index(key, index)\n @indexes[key] = index\n $LUCENE_LOGGER.debug{\"Registered index for #{index}\"}\n end",
"def add(obj, element)\n @selections << obj\n # call backs to update duration and such\n end",
"def add_object(iObject)\n @StatementInsertIntoStatsObjects.execute(iObject)\n\n return @StatementInsertIntoStatsObjects.insert_id\n end",
"def add_item item\n @items << item\n @@all_items << item\n end",
"def dup_or_calc( array, object, index )\n array[ index ] = object.class.new if ( array[ index ].nil? )\n array[ index ].add!( object )\n end",
"def add_object!(object, objectID = nil, request_options = {})\n res = add_object(object, objectID, request_options)\n wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)\n res\n end",
"def add_to_inventory(item)\n @inventory.push(item)\n update\n end",
"def <<(obj)\n self[length] = obj\n self\n end"
] | [
"0.7751373",
"0.73306346",
"0.70778215",
"0.70624447",
"0.6873763",
"0.6865473",
"0.6857407",
"0.6839746",
"0.68336",
"0.6792281",
"0.6666518",
"0.6590304",
"0.65871",
"0.6554562",
"0.65218407",
"0.6465241",
"0.643733",
"0.6417968",
"0.64040816",
"0.6394342",
"0.63657916",
"0.6278805",
"0.6275993",
"0.6263374",
"0.6236132",
"0.6212128",
"0.62020385",
"0.6199572",
"0.61897236",
"0.61841315",
"0.61661637",
"0.6157963",
"0.6151737",
"0.6141894",
"0.6104615",
"0.60916656",
"0.60852826",
"0.60821044",
"0.6080836",
"0.6075189",
"0.6070425",
"0.60651964",
"0.606433",
"0.6051088",
"0.6036897",
"0.60302395",
"0.6030033",
"0.60263926",
"0.6023981",
"0.60216695",
"0.60083777",
"0.60067844",
"0.59427226",
"0.59249777",
"0.59191465",
"0.5907132",
"0.58528",
"0.5845025",
"0.5826321",
"0.58210325",
"0.58168906",
"0.5816126",
"0.5813544",
"0.5808204",
"0.57957196",
"0.5790384",
"0.5787492",
"0.5777869",
"0.5775348",
"0.57631975",
"0.5762268",
"0.57598877",
"0.57589275",
"0.5750442",
"0.5722829",
"0.5715324",
"0.571435",
"0.5709596",
"0.5679913",
"0.56723595",
"0.56723595",
"0.5671992",
"0.56638956",
"0.5662207",
"0.56595033",
"0.5659426",
"0.5638107",
"0.56368023",
"0.5631724",
"0.5631724",
"0.5629669",
"0.5629125",
"0.5621871",
"0.56151575",
"0.55988765",
"0.55898976",
"0.55815846",
"0.556578",
"0.55641127",
"0.5550875"
] | 0.67861485 | 10 |
use this on an object if its name_key changes. also pass in an optional condition of whether to add it back in at all. | def update_membership(obj, &filter)
remove(obj)
add(obj) if !filter || filter.call(obj)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name\n self.update(name: \"Large Washer ##{self.id}\") unless self.name\n end",
"def change_item_name(new_name:, **)\n self.name = new_name # This will generate the event!\n end",
"def set_name\n self.update(name: \"Medium Washer ##{self.id}\") unless self.name\n end",
"def name=(str); dirty!; super; end",
"def add(obj)\n return self if self.has_key? name_of(obj)\n\n hook_wrap :add, obj do\n begin\n name = name_of(obj)\n insert_sorted(obj)\n hashed[name] = obj\n obj\n rescue Exception => e\n delete(name)\n raise e\n end\n end\n\n self\n end",
"def update_object(new_name, log)\n self.name = new_name\n save\n observation.log(:log_naming_updated,\n name: format_name, touch: log)\n true\n end",
"def method_added(name)\n result = basic_object_method_added(name)\n return result if self != Object\n AE::BasicObject.hide(name)\n result\n end",
"def add_ingredient_by_name(new_ingredient)\n #self.ingredients < Ingredient.find_ingredient_by_name(new_ingredient)\n end",
"def on_name_changed(new_name:, **)\n @name = new_name\n end",
"def track_attribute _name, _new_value\n unless self.send(_name).eql?(_new_value)\n self.modified_attributes << _name.to_sym\n end\n end",
"def add_to_hash(storage_hash, name, new_name)\r\n storage_hash[name] = new_name\r\nend",
"def add_new_name_to_tags(orig, tag_name)\n return_array = []\n \n # sort of deep clone\n orig.each {|x| return_array << x.clone}\n\n name_key_found = false\n\n return_array.each do |r|\n if r[:Key] == 'Name'\n r[:Value] = tag_name\n name_key_found = true\n end\n break if name_key_found\n end\n\n unless name_key_found\n return_array << { Key: 'Name', Value: tag_name}\n end\n\n return_array\nend",
"def change_name(object, symbol, old_name, new_name, activity_params)\n return if old_name == new_name || new_name.blank? || !object.update(name: new_name)\n create_activity(object, \"#{symbol}_name\", old_name, new_name, activity_params)\n end",
"def _UNDO_setName(iNewName)\n @Name = iNewName\n end",
"def child_pre_set_hook( key, object, parent_hash = nil )\n\n return object\n \n end",
"def update!(**args)\n @new_name = args[:new_name] if args.key?(:new_name)\n @prev_name = args[:prev_name] if args.key?(:prev_name)\n end",
"def method_added(name)\n result = basic_object_method_added(name)\n return result if self != Kernel\n AE::BasicObject.hide(name)\n result\n end",
"def append_name\n self.name = self.content\n end",
"def name!( ɴ )\n old_ɴ = namespace.__instances__[ self ] # previous name\n if ɴ then # puts \"NameMagic: Rudely naming with #{ɴ}.\" if DEBUG\n ɴ = namespace.send( :validate_name, # honor the hook\n namespace.name_set_hook.( ɴ, self, old_ɴ ) ).to_sym\n # puts \"NameMagic: Name adjusted to #{ɴ}.\" if DEBUG\n return false if old_ɴ == ɴ # already named as required\n pair = namespace.__instances__.rassoc( ɴ )\n namespace.__forget__( pair[0] ) if pair # rudely forget the collider\n namespace.const_set ɴ, self # write a constant\n namespace.__instances__[ self ] = ɴ # write to @instances\n namespace.__forget__ old_ɴ # forget the old name of self\n else\n self.name = nil # unnaming, no collider issues\n end\n end",
"def add_historical_name\n last_year = Date.today.year - 1\n if !@old_name.blank? && results_before_this_year? && !self.historical_names.any? { |name| name.year == last_year }\n self.historical_names.create(:name => @old_name, :year => last_year)\n end\n end",
"def add_historical_name\n last_year = Date.today.year - 1\n if !@old_name.blank? && results_before_this_year? && !self.historical_names.any? { |name| name.year == last_year }\n self.historical_names.create(:name => @old_name, :year => last_year)\n end\n end",
"def set_name\n while !Provider.where(name: self.name).blank? do\n self.name = \"#{self.name}_1\"\n end\n # hagan que busque los que tengan el mismo nombre que se intenta guardar\n # agregue \"_1\" al name si ya hay alguno con el nombre no \n # importa que ya tenga \"_1\" le agregarian otro, ej. \"steren_1_1\"\n # self.name entrega el nombre que esta tratandose \n # de asignar al objeto instanciado\n end",
"def name=(new_name)\n if new_name != self.name\n self.old_name = self.name\n self.write_attribute(:name, new_name)\n end\n end",
"def []= key, value\n\t\t\tsuper\n\t\t\t@orient.update set: {@name => self} if @name.present? if check_if_complete\n\t\tend",
"def name=(aString)\n if aString == nil\n # si le nom en param est nil alors supprimer le context du manager si il y est sinon rien faire\n self.manager.dictionary.delete(self) \n else\n # si le nom n'est pas nil alors ajouter self au manager\n self.manager.dictionary[self] = aString \n end \n end",
"def set_name(hash)\n self[name_var] = hash.delete(name_var) if name_var\n end",
"def collins_set_needs_rename!\n state = collins_osc_state\n state.merge!({\n 'running' => false,\n 'finished' => Time.now.to_i,\n 'current_state' => \"needs_rename\",\n 'next_state' => \"can_be_altered\"\n })\n\n self.collins_osc_state = state\n end",
"def extend_name!(obj)\n obj.set_name!((self.name.to_s + \"::\" + obj.name.to_s).to_sym)\n end",
"def add_name( name )\n if Option.name_ok?( name )\n if ! @names.include?( name )\n @names.push( name )\n end\n end\n end",
"def update_name(id, name)\n @names[id] = name if @names[id]\n end",
"def name_change?(name)\n name != self.category\n end",
"def rename(entry, new_name, &continue_on_exists_proc); end",
"def method_missing(name, *args)\n name_str = name.to_s\n if name_str.end_with?(EQUALS)\n # Handle edge case (self.send(:\"=\", 'foo') ? why would someone do this)\n if name_str != EQUALS\n self[name_str[0..-2].to_sym] = args.first\n else\n super\n end\n else\n self[name]\n end\n end",
"def name=(o); end",
"def rename_storage_object\n if self.permanent_key_was.present? && self.permanent_key.present?\n target_key = nil\n if self.permanent_key != self.permanent_key_was\n target_key = self.permanent_key\n elsif self.filename != self.filename_was\n target_key = self.class.permanent_key(institution_key: self.institution.key,\n item_id: self.item_id,\n filename: self.filename)\n end\n if target_key\n PersistentStore.instance.move_object(source_key: self.permanent_key_was,\n target_key: target_key)\n self.update_column(:permanent_key, target_key) # skip callbacks\n end\n elsif self.staging_key_was.present? && self.staging_key.present?\n target_key = nil\n if self.staging_key != self.staging_key_was\n target_key = self.staging_key\n elsif self.filename != self.filename_was\n target_key = self.class.staging_key(institution_key: self.institution.key,\n item_id: self.item_id,\n filename: self.filename)\n end\n if target_key\n PersistentStore.instance.move_object(source_key: self.staging_key_was,\n target_key: target_key)\n self.update_column(:staging_key, target_key) # skip callbacks\n end\n end\n end",
"def method_missing(attempted_method_name, *args, &block)\n\n if attempted_method_name == \"update_name\"\n update = {\"name\" => args.first}\n self.class.update(self.id, update)\n end\n end",
"def set_object(obj_name,obj)\n key = obj_name.to_s\n raise \"object '#{key}' already exists in context\" if @cache.keys.include?(key)\n @cache[key] = obj\n end",
"def rekey_as_needed; end",
"def add(name, obj)\n if @events[name] && !@events[name].include?(obj)\n @events[name] << obj\n else\n @events[name] = [obj]\n end\n end",
"def did_name_change?\n @name_changed = name_id_changed?\n true\n end",
"def field_revised?(name)\n new_record? ? false : revised_changes.has_key?(name.to_s)\n end",
"def name=(new_name)\n @name = new_name\n $game_party.quests.add_to_sort_array(:alphabet, @id) if $game_party && \n $game_party.quests\n end",
"def rename(entry, new_name, &continue_on_exists_proc)\n found_entry = get_entry(entry)\n check_entry_exists(new_name, continue_on_exists_proc, 'rename')\n @entry_set.delete(found_entry)\n found_entry.name = new_name\n @entry_set << found_entry\n end",
"def update!(**args)\n @name = args[:name] unless args[:name].nil?\n end",
"def set_name(name_in)\n @name = name_in.clone();\n end",
"def name=(name)\n\t\t@new_name = name\n\tend",
"def new_name(cond)\n\t\t\t\tloop.with_index do |_,ind|\n\t\t\t\t\tn=self.class.new(yield(self,ind))\n\t\t\t\t\treturn n if cond.call(n)\n\t\t\t\tend\n\t\t\tend",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n end",
"def add_want(someone)\n\t\t@stuff[someone.name] = someone.want\n\tend",
"def name=(name)\n unless name_taken?(name)\n @name = name \n @@taken_names << name\n end\n end",
"def applyName(x)\n if x.name == @value\n return true\n else\n return false\n end\n end",
"def add_object(name, object)\n if not(name.is_a?(Symbol))\n name = name.to_sym\n end\n if @game_objects[name] == nil\n @game_objects.store(name, object)\n end\n end",
"def add_model(k, v)\n key = k.to_s.camelize\n changed = false\n wpf_value = unless objects.contains_key(key) \n changed = true\n IronNails::Library::WpfValue.of(System::Object).new(v)\n else\n val = objects.get_value(key)\n unless v == val.value\n val.value = v\n changed = true\n end\n val \n end\n if changed\n logger.debug \"setting objects entry: #{key}\", IRONNAILS_FRAMEWORKNAME\n objects.set_entry(key, wpf_value)\n end\n end",
"def new_name; end",
"def new_name(new_name)\n @name = new_name\n end",
"def handle_simple(value)\n @keys << @key_name\n end",
"def handle_simple(value)\n @keys << @key_name\n end",
"def name_setter(new_name)\n @name = new_name\n end",
"def name= new_name\n @name = new_name\n end",
"def update!(**args)\n @new_name = args[:new_name] if args.key?(:new_name)\n @original_name = args[:original_name] if args.key?(:original_name)\n end",
"def name=( ɴ )\n old_ɴ = namespace.__instances__[ self ] # previous name\n if ɴ then # puts \"NameMagic: Naming with argument #{ɴ}.\" if DEBUG\n ɴ = namespace.send( :validate_name, # honor the hook\n namespace.name_set_hook.( ɴ, self, old_ɴ ) ).to_sym\n # puts \"NameMagic: Name adjusted to #{ɴ}.\" if DEBUG\n return if old_ɴ == ɴ # already named as required\n fail NameError, \"Name '#{ɴ}' already exists in #{namespace} namespace!\" if\n self.class.__instances__.rassoc( ɴ )\n namespace.const_set ɴ, self # write a constant\n namespace.__instances__[ self ] = ɴ # write to @instances\n namespace.__forget__ old_ɴ # forget the old name of self\n else # puts \"NameMagic: Unnaming #{old_ɴ || self}\" if DEBUG\n namespace.__instances__.update( self => nil ) # unname in @instances\n namespace.send :remove_const, old_ɴ if old_ɴ # remove namespace const.\n end\n end",
"def disambiguate_fields\n if name_changed? # New, Updated\n fields = self.class.specific.where(\"LOWER(name) = LOWER(?)\", self.name)\n fields.update_all(:disambiguate => fields.many?)\n end\n\n if name_was # Updated, Destroyed\n fields = self.class.specific.where(\"LOWER(name) = LOWER(?)\", self.name_was)\n fields.update_all(:disambiguate => fields.many?)\n end\n end",
"def change_tagname!(new_tagname)\n old_tagname = self.tagname\n if change_tagname?(new_tagname)\n # name change is ok - we use update_all because we assume our status is being updated up a level\n TagNomination.for_tag_set(owned_tag_set).where(:tagname => old_tagname).update_all(:tagname => new_tagname)\n return true\n end\n return false\n end",
"def tag_append_one(name)\n tag = Tag.find_or_create_by_name(name)\n tag.on(self) unless tags.include? tag\n end",
"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 child_post_set_hook( key, object, parent_hash = nil )\n \n return object\n \n end",
"def name=(val)\n self[:name] = val\n self[:key] = val.parameterize\n end",
"def if_needs_rekey?; end",
"def service_name(name)\n verify_subclass!\n key_name = name.to_sym\n raise DuplicateNameError, \"The service #{self.name} is trying to define a service_name of #{name} when it has already been defined by #{all_services[key_name].klass.name}\" if all_services.has_key?(key_name)\n\n # remove the old entry\n all_services.delete(service_description.name) if service_description.present?\n\n self.service_description ||= ServiceDescription.new\n service_description.update(key_name, self)\n\n # save off reference\n all_services[service_description.name] = service_description\n end",
"def by_name(name)\n fail InterfaceNotFound unless storage.include?(name)\n\n storage.rotate!(storage.index(name))\n\n update\n end",
"def collection_updated(object, result)\n key = object.key\n if result\n parent_add(key, object)\n object.subscribe(self)\n else\n object.unsubscribe(self)\n parent_delete(object)\n end\n end",
"def update_tag_name\n t = self.tag\n new_tag = Tag.find_by_name(self.name)\n if t != new_tag\n if new_tag.nil?\n t.update_attribute(:name, self.name)\n else\n new_tag.update_attribute(:tag_type, self.class.name)\n self.bypass_save_callbacks = true\n self.update_attribute(:tag_id, new_tag.id)\n # Downgrade 't' to a regular tag if no topic/subject points to it\n t.update_attribute(:tag_type, nil) if !Topic.exists?(:tag_id => t.id)\n end\n end\n end",
"def method_missing(method, *args, &block)\n attribute = method.to_s\n\n if attribute =~ /=$/ # Define property -- does not have to exist\n attribute = attribute.chop\n self.changed_attributes[attribute] = args[0]\n self.attributes[attribute] = args[0]\n else\n return super unless self.attributes.include?(attribute)\n self.attributes[attribute]\n end \n \n end",
"def method_missing(name, *args, &block)\n if name =~ /(.*)=$/ # We're assigning\n self[$1.to_sym] = args[0]\n elsif name =~ /(.*)\\?$/ # We're asking\n (self[$1.to_sym] ? true : false)\n else\n self[name]\n end\n end",
"def []=(name, obj)\n @lock.synchronize do\n # If the passed object is nil, we delete the entry if it exists.\n if obj.nil?\n @root_objects.delete(name)\n return nil\n end\n\n # We only allow derivatives of PEROBS::Object to be stored in the\n # store.\n unless obj.is_a?(ObjectBase)\n PEROBS.log.fatal 'Object must be of class PEROBS::Object but ' +\n \"is of class #{obj.class}\"\n end\n\n unless obj.store == self\n PEROBS.log.fatal 'The object does not belong to this store.'\n end\n\n # Store the name and mark the name list as modified.\n @root_objects[name] = obj._id\n end\n\n obj\n end",
"def object_name_changed\n logger.debug(\"kpi_id = #{session[:kpi_id].size}\") unless session[:kpi_id].nil?\n # Select left box\n unless params[:can_select_object_name].nil?\n @already_select_object_names = (session[:object_names].nil?)? Array.new : session[:object_names]\n unless session[:kpi_id].nil?\n # One more kpi can only select one object\n if session[:kpi_id].size > 1\n @already_select_object_names = Array.new\n session[:object_names] = nil\n end\n end\n params[:can_select_object_name].each{|object_name|@already_select_object_names.push(object_name)}\n @can_select_object_names = @all_object_names - @already_select_object_names\n session[:object_names] = @already_select_object_names\n end\n # Select right box\n unless params[:already_select_object_name].nil?\n @already_select_object_names = (session[:object_names].nil?)? Array.new : session[:object_names]\n params[:already_select_object_name].each{|object_name|@already_select_object_names.delete(object_name)}\n @can_select_object_names = @all_object_names - @already_select_object_names\n session[:object_names] = @already_select_object_names\n end\n # Set chart number\n set_chart_number\n end",
"def create_if_not_exists(hash, key, val, name: key.to_sym)\n return if hash.key?(key)\n\n self.class.send(:attr_accessor, name)\n send(\"#{name}=\", val)\n end",
"def assign_key(obj)\n \tsuper(obj)\n \tcase \n \t\twhen obj.is_a?(Event) then \t\t\t\"even:#{@max_key}\"\n \t\twhen obj.is_a?(::Database::Reference) then \t\"ref:#{@max_key}\"\n \tend\n end",
"def cache(named_key, object)\n @mutex.synchronize {\n self[named_key] = object\n } \n end",
"def name=(val)\n self['name'] = val\n end"
] | [
"0.58451056",
"0.5655675",
"0.56235176",
"0.5548807",
"0.55246174",
"0.5492181",
"0.5488547",
"0.54154384",
"0.5407909",
"0.54022133",
"0.53728545",
"0.5352485",
"0.5331546",
"0.5311049",
"0.5290392",
"0.528614",
"0.52859455",
"0.52735215",
"0.5268705",
"0.5265434",
"0.5265434",
"0.52552277",
"0.52544034",
"0.5243272",
"0.52331245",
"0.5220264",
"0.520296",
"0.51940995",
"0.5190505",
"0.51602274",
"0.5140899",
"0.51341707",
"0.5126661",
"0.509902",
"0.50787294",
"0.5062413",
"0.50509495",
"0.5042055",
"0.5027769",
"0.5026001",
"0.5012007",
"0.5006914",
"0.50045073",
"0.49981362",
"0.49923715",
"0.49784455",
"0.49766207",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972894",
"0.4972329",
"0.4963531",
"0.49576652",
"0.4955676",
"0.4949975",
"0.49482885",
"0.49414408",
"0.49401155",
"0.49401155",
"0.4931885",
"0.4931265",
"0.49291876",
"0.49227992",
"0.49098012",
"0.4908595",
"0.4904942",
"0.4904643",
"0.48991466",
"0.48924375",
"0.48914644",
"0.48656583",
"0.48645627",
"0.48642787",
"0.48582208",
"0.48474863",
"0.48472923",
"0.4846689",
"0.4844116",
"0.4832977",
"0.48288655",
"0.4827018",
"0.48210976"
] | 0.0 | -1 |
removes an object by pointer. works even if the name has changed | def remove(obj)
hashed.each do |k,v|
hashed.delete(k) if v == obj
end
list.reject! { |el| el == obj }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(o); removeObject o end",
"def delete(obj) ; end",
"def remove!\n zombie_check\n self.class.remove(@name)\n end",
"def delete(name); end",
"def delete(name); end",
"def delete(object); end",
"def remove_from(type, name)\n\n #Find if the object exists\n index = search(type, name)\n\n #Stops if exercise list is empty\n if index == -1\n return -1\n end\n\n #Removes an exercise object\n if type == \"exercise\"\n @exercise_list.delete_at(index)\n return 0\n #Removes a workout object\n elsif type == \"workout\"\n @workout_routines.delete_at(index)\n return 0\n #Error handling\n else\n return -1\n end\n end",
"def remove!; end",
"def remove_by_name(name)\n p = get_by_name(name)\n if (p != nil)\n return remove(p)\n end \n end",
"def remove name\n delete(name)\n end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def deregister_object(local_object)\n siblings = siblings_by_local_object_id.delete(local_object.droby_id)\n siblings.each do |peer_id, droby_id|\n siblings_by_peer[peer_id].delete(droby_id)\n end\n\n if local_object.respond_to?(:name)\n n = local_object.name\n models_by_name.delete(n) if local_object == models_by_name[n]\n end\n end",
"def remove(obj)\n @set.removeObject obj\n end",
"def unlinkItem _obj, _args\n \"_obj unlinkItem _args;\" \n end",
"def op_del(attrname = nil)\n attrname ||= pop\n push pop.dup\n peek.delete(attrname)\n end",
"def remove_by_name(name)\n fw = get_by_name(name)\n if (fw != nil)\n return remove(fw)\n end \n end",
"def remove(object)\n full_name = extract_full_name object\n post 'api/remove', { :id => full_name, :api_type => :json }\n end",
"def remove!(name)\n remove_instance_variable to_ivar(name)\n end",
"def removeItem _obj, _args\n \"_obj removeItem _args;\" \n end",
"def unset(object)\n if object.is_a?(Array)\n object.each do |obj|\n unset(obj)\n end\n return nil\n end\n\n classname = object.class.name\n\n if @args[:module]\n classname = classname.gsub(@args[:module].name + \"::\", \"\")\n end\n\n classname = classname.to_sym\n @objects[classname].delete(object.id.to_i)\n end",
"def remove_object g\n @objects.remove g\n @intent_map.delete g\n for m in @extent_map do\n extent_map[m].delete g\n end\n end",
"def remove(type); end",
"def obj_purge(obj,klass)\n obj_manipulate obj,klass do |man|\n man.in_session do \n parents = find_by_member(obj.name, :find_mode => :exact, :transaction => true)\n transaction do\n parents.each do |par|\n obj_remove par, par.class, obj\n end\n obj_delete obj, obj.class\n end\n end\n end\n end",
"def del(name)\n data.delete(name)\n end",
"def dissociate klass, ident\n @associated_objects[klass].delete?(ident) != nil\n end",
"def remove_entry(p)\n\t\t@person.delete(p)\n\tend",
"def delete_object(x, y)\n @generator_flag = false if @grid[y][x].object.class == MapAbxn::Generator\n @grid[y][x] = nil\n end",
"def remove_element(name)\n @element_list.delete_if{|e|\n e.name == name\n }\n end",
"def destroy_item(klass, name, type_name)\n begin\n object = klass.load(name)\n object.destroy\n ui.warn(\"Deleted #{type_name} #{name}\")\n rescue Net::HTTPServerException\n ui.warn(\"Could not find a #{type_name} named #{name} to delete!\")\n end\n end",
"def destroy_item(klass, name, type_name)\n begin\n object = klass.load(name)\n object.destroy\n ui.warn(\"Deleted #{type_name} #{name}\")\n rescue Net::HTTPServerException\n ui.warn(\"Could not find a #{type_name} named #{name} to delete!\")\n end\n end",
"def destroy_item(klass, name, type_name)\n begin\n object = klass.load(name)\n object.destroy\n ui.warn(\"Deleted #{type_name} #{name}\")\n rescue Net::HTTPServerException\n ui.warn(\"Could not find a #{type_name} named #{name} to delete!\")\n end\n end",
"def delete_label(name)\n label = get_object name\n\n raise 'The object is not a label' if label.object_type != :label\n\n object_store.remove name\n end",
"def delete(name)\n\n end",
"def delete_one(object)\n position = index(object)\n position ? delete_at(position) : nil\n end",
"def delete(element); end",
"def removeMagazine _obj, _args\n \"_obj removeMagazine _args;\" \n end",
"def delete(object)\n if object.is_a?(GameObject)\n object_id = object.game_object_id\n else\n object_id = object\n object = find_by_id(object_id)\n end\n\n @mutex.synchronize do\n game_object = @ghash.delete(object_id)\n end\n end",
"def removeNamedItem(name)\n getNamedItem(name).remove\n end",
"def destroy_item(klass, name, type_name)\n object = klass.load(name)\n object.destroy\n ui.warn(\"Deleted #{type_name} #{name}\")\n rescue Net::HTTPServerException\n ui.warn(\"Could not find a #{type_name} named #{name} to delete!\")\n end",
"def removeHandgunItem _obj, _args\n \"_obj removeHandgunItem _args;\" \n end",
"def remove_item(hash, item_name)\r\n hash.delete(item_name)\r\n hash\r\nend",
"def remove_object(gameobject)\n @monsters.delete gameobject\n @towers.delete_if { |a,b| b == gameobject }\n @bullets.delete gameobject\n end",
"def remove(obj, name)\n id = get_id(obj)\n if @finalizers[id]\n finalizer = @finalizers[id].delete name if @finalizers[id][name]\n @finalizers.delete id if @finalizers[id].empty?\n finalizer\n end\n end",
"def erase\r\n @name = nil.to_s\r\n end",
"def remove item #(item: pointer)\n freeitem item\n delete item\n end",
"def remove(name)\n gladiators.reject! { |g| g.name == name }\n end",
"def delete\n CMark.node_unlink(@pointer)\n end",
"def remove_item(olist, item)\n olist.delete(item) \n olist\nend",
"def unset(name)\n update(name, nil)\n end",
"def op_remove!(field, objects)\n operate_field! field, { __op: :Remove, objects: objects }\n end",
"def delete!(object)\n raise NotImplementedError\n end",
"def drop(object)\n\t\t\traise GreyGoo::Error, \"You don't have that object\" if !has?(object)\n\t\t\tcurrent_room.take(object)\n\t\t\tself.reload # because the object's parent has lost the object, not us\n\t\tend",
"def delete(object)\n key_name = attributes.key[0].name\n key_value = object.public_send(key_name)\n relation.delete(key_name => key_value)\n object\n end",
"def remove_item(item)\r\n items.delete(item)\r\n item.owner = nil\r\n end",
"def remove_item\n\n end",
"def delete_object(object)\n store = nil\n file = nil\n game_object_id = nil\n game_object = nil\n\n if not object.is_a? GameObject\n game_object_id = object\n\n open_store \"goids\" do |gd|\n file = gd[game_object_id]\n end\n\n if file.nil?\n log \"No file found for that goid (#{game_object_id})\"\n return nil\n end\n else\n game_object_id = object.game_object_id\n file = object.class.to_s\n end\n\n open_store(file, false) do |gd|\n gd.delete(game_object_id)\n end\n\n open_store(\"goids\", false) do |gd|\n gd.delete(game_object_id)\n end\n end",
"def delete_component(name)\n components.delete_if { |c| c.name == name.to_sym }\n end",
"def remove_item(list, name)\n list.delete(normalize_string(name))\n return list\nend",
"def del(*args); end",
"def delete_at(p0) end",
"def remove_item(list, item_name)\n list.delete(item_name.to_sym)\n list\nend",
"def deleteEditorObject _obj, _args\n \"_obj deleteEditorObject _args;\" \n end",
"def delete(obj)\n case obj\n when Rubabel::Bond\n delete_bond(obj)\n when Rubabel::Atom\n delete_atom(obj)\n else \n raise(ArgumentError, \"don't know how to delete objects of type: #{obj.class}\")\n end\n end",
"def deleteRepositoryObject(path)\n begin\n File.delete(path+\".obj\")\n rescue DefaultException => e\n puts \"Failed to delete repository object : #{path}\"\n end\n end",
"def remove_attr(name); end",
"def remove_attr(name); end",
"def remove(component)\n \t@children.delete(component)\n \tcomponent.parent = nil\n end",
"def remove_context_object(element)\n idx = case element.class\n when Fixnum then element\n when OpenURL::ContextObject then @context_objects.index(element)\n else raise ArgumentError, \"Invalid argument for element\"\n end\n @context_objects.delete_at(idx)\n \tend",
"def remove_component(component)\n\t\t@components.delete(component)\n\tend",
"def remove_item(list, item_name)\r\n list.delete(item_name)\r\n list\r\nend",
"def removeItemFromBackpack _obj, _args\n \"_obj removeItemFromBackpack _args;\" \n end",
"def remove!\n destroy\n end",
"def delete(o)\n @hash.delete(o)\n self\n end",
"def delete(o)\n @hash.delete(o)\n self\n end",
"def removeItemFromUniform _obj, _args\n \"_obj removeItemFromUniform _args;\" \n end",
"def obj_remove(obj,klass,member)\n obj_manipulate obj,klass do |man|\n man.checks do \n raise_if_member_is_not_valid_for klass, member\n end \n man.in_session do \n raise_if_obj_do_not_exist obj \n get_response_and_validate_for(obj,klass,\"remove\",member)\n end\n end\n end",
"def delete_element(element); end",
"def delete(attribute); end",
"def remove_item(list, item_name)\n list.delete(item_name)\n list\nend",
"def remove\n __flag__ :remove\n end",
"def remove(object)\n push(new_entry_for_object(object, :to_remove => true))\n end",
"def remove_item(list, item_name)\n list.delete(item_name)\nend",
"def remove_by_type_and_name(type, name)\n entity_id = get_id_by_type_and_name(type, name)\n if entity_id.nil?\n raise \"Id for entity with type '#{type}' and name '#{name}' can't be found\"\n else\n remove_by_type_and_id(type, entity_id)\n end\n end",
"def remove_pet_by_name(pet_shop, pet_name)\n\n pet_array = pet_shop[:pets]\n pet_to_delete = find_pet_by_name(pet_shop, pet_name)\n pet_array.delete(pet_to_delete)\n\nend",
"def delRef(typ,origAddr)\n if hasRef(typ,origAddr)\n $book.delRef(typ,origAddr)\n end\n end",
"def pop\n @obj.pop\n end",
"def remove(entity)\n remove_by_type_and_name(entity.properties[:type], entity.properties[:name])\n end",
"def destroys(object,*args,&block)\n opts = args.last.is_a?(Hash) ? args.pop.symbolize_keys : {}\n deletes_to(path_for(object,args),opts,&block)\n end",
"def remove_player p\n (@players ||= []).delete p.sym\n end",
"def remove *k\n\t\t\t# todo combine queries in a transaction\n\t\t\tActiveOrient::Base.logger.debug { \"delete: #{@name} --< #{k.map(&:to_or).join( ' :: ' )}\"}\n\t\t k.map{|l|\t@orient.update( {remove: { @name => l} } ) }\n\t#\t\t@orient.reload!\n\t#\t\t@orient.send @name \n\t\tend",
"def remove identifier\n @storage.delete(identifier)\n end",
"def removeAction _obj, _args\n \"_obj removeAction _args;\" \n end",
"def removeItemFromVest _obj, _args\n \"_obj removeItemFromVest _args;\" \n end",
"def delete(object)\n full_name = extract_full_name object\n post 'api/del', :id => full_name\n end",
"def remove_pet_by_name(pet_shop, name)\n pet_to_be_removed = find_pet_by_name(pet_shop, name)\n pet_shop[:pets].delete(pet_to_be_removed)\nend",
"def delete(obj)\n if obj.is_a?(Symbol)\n object_type = obj\n obj = @params[object_type]\n @params.delete(object_type)\n else\n object_data_delete(obj)\n end\n obj.unregister unless obj.nil?\n end",
"def remove_id(object_id)\n\t\ti = @docs.index { |doc| doc.object_id == object_id }\n\t\tdestroy_tab(i) if @docs[i].try_to_save()\n\t\t # remove_tab(i) #if not i.nil?\n\tend",
"def removeWeapon _obj, _args\n \"_obj removeWeapon _args;\" \n end"
] | [
"0.76384354",
"0.7224725",
"0.7088",
"0.7037573",
"0.7037573",
"0.6959646",
"0.69035685",
"0.6873145",
"0.67518795",
"0.6738451",
"0.6647451",
"0.6647451",
"0.6647451",
"0.6647451",
"0.6643777",
"0.66262174",
"0.6613068",
"0.66075796",
"0.6552178",
"0.65274876",
"0.6516173",
"0.6510932",
"0.64962775",
"0.6482772",
"0.6467489",
"0.643373",
"0.64326715",
"0.64080346",
"0.6395016",
"0.63844115",
"0.6359777",
"0.6356862",
"0.6356862",
"0.6356862",
"0.6347039",
"0.6315846",
"0.62724304",
"0.6268574",
"0.62670505",
"0.6257317",
"0.6256693",
"0.6246121",
"0.6235811",
"0.6234728",
"0.62258244",
"0.6223448",
"0.62222964",
"0.622152",
"0.6215706",
"0.6208246",
"0.6200196",
"0.6199356",
"0.6195372",
"0.61774355",
"0.61624706",
"0.6160911",
"0.6141029",
"0.61367744",
"0.6127891",
"0.61180943",
"0.6116525",
"0.6116386",
"0.6113167",
"0.611201",
"0.6104551",
"0.6093301",
"0.6090777",
"0.6085543",
"0.6085543",
"0.60829043",
"0.6077411",
"0.60756457",
"0.60743237",
"0.60729265",
"0.60686773",
"0.6065264",
"0.6065264",
"0.6054061",
"0.6014931",
"0.6013637",
"0.6013125",
"0.6012708",
"0.60029984",
"0.6002211",
"0.60003626",
"0.6000321",
"0.5992905",
"0.59867424",
"0.59854007",
"0.5983991",
"0.59829336",
"0.5976712",
"0.59712887",
"0.5967749",
"0.59635556",
"0.59634763",
"0.5957175",
"0.595541",
"0.5953424",
"0.59496737",
"0.59476376"
] | 0.0 | -1 |
Perform a task on every object in the index, and on every object that will be added. | def always(&blk)
each(&blk)
hook(:add, &blk)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_all\n helper.index_write do |index|\n index.add_all\n index.update_all\n end\n\n self\n end",
"def process tweet, *_\n @aggregator << tweet.to_hash\n if @aggregator.size == options.buffered_docs\n response = @indexer.index_array(@aggregator)\n raise \"Your motherfucking bulk request failed.\" if response.has_failures?\n warn(\"Success\")\n @aggregator = []\n end\n end",
"def update_index\n all.each do |n|\n n.update_index\n end\n end",
"def index(object)\n push(new_entry_for_object(object))\n end",
"def index(obj)\n if @index && !loaded?\n @index.call(obj)\n else\n super\n end\n end",
"def run_bulk; end",
"def add_to_index(records, **opt)\n fields = records.map(&:emma_metadata)\n $stderr.puts \"=== STEP #{__method__} | #{Emma::ThreadMethods.thread_name} | #{records.size} recs = #{records.map { |r| manifest_item_id(r) }} | #{fields.size} fields = #{fields.inspect.truncate(1024)}\" # TODO: testing - remove\n result = ingest_api.put_records(*fields)\n remaining, failure = process_ingest_errors(result, *records)\n\n opt[:success] = 'indexed' # TODO: I18n\n opt[:meth] = __method__\n opt[:initial] = { failure: failure }\n\n now = DateTime.now\n run_step(remaining, **opt) do |_id, rec|\n rec.update_columns(last_indexed: now)\n end\n end",
"def perform\n entries.each do |entry|\n @items << generate_item(entry)\n end\n add_ids\n end",
"def each(&block)\n @index.each(&block)\n end",
"def after_update\n super\n self.class.call_es { _index_document }\n end",
"def update_in_index\n __elasticsearch__.index_document\n\n index_dependent_models.map(&:update_in_index)\n end",
"def each_object( &action )\n @objs.each { |o| action.call( o ) }\n end",
"def on_add(&block)\n @index.each do |index, values|\n values.each do |v|\n block.call(v)\n end\n end\n @onAddBlock = block\n end",
"def bulk_import\n client = ElasticsearchClient.client\n\n find_in_batches.with_index do |entries, _i|\n client.bulk(\n index: es.index_name,\n type: '_doc',\n body: entries.map { |entry| { index: { _id: entry.id, data: entry.as_indexed_json } } },\n refresh: true, # NOTE: 定期的にrefreshしないとEsが重くなる\n )\n end\n end",
"def index_all\n puts \"Indexing everything\"\n MojoDNA::Searchable::RemoteSearchable::searcher.push( [:index_all, self.inspect.to_s, nil] )\n end",
"def index(model)\n model.index\n ElasticMapper.index.refresh\nend",
"def add( resource )\n entries.merge!( resource.index_dump )\n mark_modified\n end",
"def update\n @objects.map(&:update);\n end",
"def on_add_with_index(&block)\n @index.each do |index, values|\n values.each do |v|\n block.call(index, v)\n end\n end\n @onAddBlockWithIndex = block\n end",
"def update_chewy_indices(object)\n object.run_chewy_callbacks\n end",
"def run\n super\n\n x = Ear::Client::Corpwatch::CorpwatchService.new\n corps = x.search @object.name\n\n # Attach to the first object\n @object.physical_locations << create_object(PhysicalLocation, {\n :address => corps.first.address, \n :state => corps.first.state, \n :country => corps.first.country })\n\n # Save off our raw data\n #@task_run.save_raw_result corps.join(\" \")\n\nend",
"def refresh\n super do |modified|\n return unless modified\n @indexer.generate_index #TODO: update_index?\n end\n end",
"def run_all\n perform\n end",
"def run_all\n perform\n end",
"def perform(args)\n Elasticsearch::Persistence.client.indices.refresh index: \"frontend*\"\n ## here you are saying Indicator.find\n ## and it is not being able to find the job.\n ## because it is using that document type.\n obj = args[1].constantize.find(args[0])\n obj.run_callbacks(:find)\n obj.do_background_job(args[2]) if obj.respond_to? \"do_background_job\"\n end",
"def cloud_search_reindex(*args)\n self.cloud_search_batch_documents do\n self.find_each(*args) do |record|\n record.add_to_cloud_search\n end\n end\n end",
"def git_add_all\n index.add_all\n index.write\n end",
"def git_add_all\n index.add_all\n index.write\n end",
"def after_index(indexable = nil,batch_connection = nil)\n\n end",
"def update_all\n delete if blacklight_items.count > 0\n self.exports.collect { |pid| add_to_solr(pid) }\n commit\n end",
"def index!(*objects)\n index(*objects)\n end",
"def add_to_index posts\n indexDir = java.io.File.new(@index_dir);\n writer = IndexWriter.new(indexDir, StandardAnalyzer.new, !File.exists?(indexDir.absolute_path))\n posts.each do |post|\n writer.updateDocument(Term.new(\"id\",post[:id]),create_lucene_document(post))\n @last_id = post[:id]\n @log.debug \"added post ##{post[:id]}\"\n end \n writer.optimize\n writer.close\n @log.info \"added #{posts.size} documents to index\"\n end",
"def perform(operation, model)\n case operation\n when 'index' then model.__elasticsearch__.index_document\n when 'update' then model.__elasticsearch__.update_document ignore: 404\n when 'delete' then model.__elasticsearch__.delete_document ignore: 404\n end\n end",
"def reindex!\n self.index = {}\n data.each do |inventory_object|\n store_index_for(inventory_object)\n end\n end",
"def perform\n track do\n reset!\n\n Restforce::DB::Registry.each do |mapping|\n run(\"CLEANING RECORDS\", Cleaner, mapping)\n run(\"ATTACHING RECORDS\", Attacher, mapping)\n run(\"PROPAGATING RECORDS\", Initializer, mapping)\n run(\"COLLECTING CHANGES\", Collector, mapping)\n end\n\n # NOTE: We can only perform the synchronization after all record\n # changes have been aggregated, so this second loop is necessary.\n Restforce::DB::Registry.each do |mapping|\n run(\"UPDATING ASSOCIATIONS\", Associator, mapping)\n run(\"APPLYING CHANGES\", Synchronizer, mapping)\n end\n end\n end",
"def update_all_objects!\n load_all(true).each do |game_object|\n game_object = yield game_object\n store_object(game_object)\n end\n end",
"def after_create\n super\n self.class.call_es { _index_document }\n end",
"def replace_all_objects(objects, request_options = {})\n safe = request_options[:safe] || request_options['safe'] || false\n request_options.delete(:safe)\n request_options.delete('safe')\n\n tmp_index = @client.init_index(@name + '_tmp_' + rand(10000000).to_s)\n\n responses = []\n\n scope = ['settings', 'synonyms', 'rules']\n res = @client.copy_index(@name, tmp_index.name, scope, request_options)\n responses << res\n\n if safe\n wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)\n end\n\n batch = []\n batch_size = 1000\n count = 0\n\n objects.each do |object|\n batch << object\n count += 1\n if count == batch_size\n res = tmp_index.add_objects(batch, request_options)\n responses << res\n batch = []\n count = 0\n end\n end\n\n if batch.any?\n res = tmp_index.add_objects(batch, request_options)\n responses << res\n end\n\n if safe\n responses.each do |res|\n tmp_index.wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)\n end\n end\n\n res = @client.move_index(tmp_index.name, @name, request_options)\n responses << res\n\n if safe\n wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)\n end\n\n responses\n end",
"def queue_all( objects, tier_index = nil )\n objects.each do |object|\n if tier_index.nil? then\n calculated_tier_index = yield( object )\n queue( object, calculated_tier_index )\n else\n queue( object, tier_index )\n end\n end\n end",
"def run_all_indexers\n run_all_indexers_orig\n $pui.run_index_round\n end",
"def update_ion_indices\n ion = self.class.ion\n\n\n # Clear out previous indexes...\n ion.index_types.each { |i_type| i_type.deindex(self) }\n\n Ion.redis.multi\n # And add new ones\n ion.indices.each { |index| index.index(self) }\n Ion.redis.exec\n end",
"def run\n super\n\n # Attach to the corpwatch service & search\n x = Ear::Client::Corpwatch::CorpwatchService.new\n corps = x.search @object.name\n\n corps.each do |corp|\n # Create a new organization object & attach a record\n o = create_object Organization, { \n :name => corp.name, \n }\n o.physical_locations << create_object(PhysicalLocation, {\n :address => corps.first.address, \n :state => corps.first.state,\n :country => corps.first.country }\n )\n end\n \n #@task_run.save_raw_result corps.to_s\n\n # Queue a detailed search\n TaskManager.instance.queue_task_run(\"hoovers_company_detail\",o, {})\nend",
"def on(name)\n indexes = Indexes.new(connection: connection).on(name)\n\n yield\n\n indexes.each(&method(:try_index_create))\n end",
"def run_all\n run_on_changes\n end",
"def update_index\n all.nodes.each do |n|\n n.reindex!\n end\n end",
"def rebuild_pgindex!\n self.all.each { |model| model.rebuild_pgindex! }\n end",
"def perform\n # This will allow us to switch backend data structure for\n # searching pretty easily.\n perform_by_mysql\n end",
"def bulk(actions)\n raise NotImplemented, \"You must implement this yourself\"\n # bulk([\n # '{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"1\" } }',\n # '{ \"field1\" : \"value1\" }'\n #])\n end",
"def process_entry(entry)\n if entry.attempts_count < max_attempts_count\n if entry.to_remove\n session.remove_by_id(entry.object_class_name, entry.object_id)\n else\n session.index(entry.object)\n end\n end\n rescue => e\n if defined?(::Rails)\n ::Rails.logger.error \"Exception raised while indexing: #{e.class}: #{e}\"\n end\n entry.run_at = Time.now + retry_interval\n entry.attempts_count += 1\n push(entry)\n end",
"def after_stream *args\n super(*args)\n @indexer.index_array(@aggregator) unless @aggregator.empty?\n @indexer.refresh_indices\n end",
"def bulk_update_document index, data\n Parallel.each( data.each_slice(4), in_threads: ENV['NUMBER_OF_THREADS'].to_i ) do |slice|\n # Hardcoded for slice of 4 elements, of which we need to combine 2\n enriched_slice = slice.map do |document|\n { doc: document, serialization: document.to_json }\n end\n\n nested_slice = []\n\n if enriched_slice.any? { |s| s[:serialization].length > 50_000_000 }\n log.debug(\"Splitting bulk update document into separate requests because one document more than 50Mb\")\n enriched_slice.each_slice(2) do |tuple|\n nested_slice << tuple\n end\n else\n nested_slice = [enriched_slice]\n end\n\n nested_slice.each do |enriched_postable_slice|\n begin\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/_bulk\")\n req = Net::HTTP::Post.new(uri)\n body = \"\"\n enriched_postable_slice.each do |enriched_document|\n body += enriched_document[:serialization] + \"\\n\"\n end\n req.body = body\n\n req[\"Content-Type\"] = \"application/x-ndjson\"\n\n run(uri, req)\n rescue SocketError => e\n log.warn(e)\n tries = 1\n while ! up\n log.info \"Waiting for elastic search\"\n sleep tries\n tries +=1\n end\n log.debug \"Retrying request\"\n run(uri, req)\n rescue StandardError => e\n log.warn( \"Failed to upload #{enriched_postable_slice.length} documents\" )\n\n ids = enriched_postable_slice.map do |enriched_document|\n enriched_document && enriched_document[:doc][:index] && enriched_document[:doc][:index][:_id]\n end\n\n log.warn( e )\n log.warn( \"Failed to upload documents #{ids.join(\", \")} with total length #{body.length}\" )\n log.warn( \"Failed documents #{ids.join(\", \")} are not ginormous\" ) if body.length < 100_000_000\n end\n end\n end\n end",
"def indexAllItems\n begin\n Thread.current[:name] = \"index thread\" # label all stdout from this thread\n batch = emptyBatch({})\n\n # The resolver and catalog stuff below is to prevent BioMed files from loading external DTDs\n # (which is not only slow but also unreliable)\n classPath = \"/apps/eschol/erep/xtf/WEB-INF/lib/saxonb-8.9.jar:\" +\n \"/apps/eschol/erep/xtf/control/xsl/jing.jar:\" +\n \"/apps/eschol/erep/xtf/normalization/resolver.jar\"\n Nailgun.run(classPath, 0, \"-Dxml.catalog.files=/apps/eschol/erep/xtf/normalization/catalog.xml\") { |nailgun|\n loop do\n # Grab an item from the input queue\n Thread.current[:name] = \"index thread\" # label all stdout from this thread\n itemID = $indexQueue.pop\n itemID or break\n\n # Extract data and index it (in batches)\n begin\n Thread.current[:name] = \"index thread: #{itemID}\" # label all stdout from this thread\n indexItem(itemID, batch, nailgun)\n rescue Exception => e\n puts \"Error indexing item #{itemID}\"\n raise\n end\n\n # To avoid Saxon's Java process from growing gigantic, restart it once in a while.\n nailgun.callCount == 1000 and nailgun.restart\n end\n }\n\n # Finish off the last batch.\n batch[:items].empty? or $batchQueue << batch\n rescue Exception => e\n if $preindexMode\n raise e\n else\n puts \"Exception in indexAllItems: #{e} #{e.backtrace}\"\n end\n ensure\n $batchQueue << nil # marker for end-of-queue\n end\nend",
"def perform\n @propagate_exceptions = false # propagation off by default\n\n return perform_top_level if not self.nested\n\n instance_eval(&self.block)\n index.build \n\n true\n end",
"def perform(name, id)\n\n\t\tcase name.to_s\n\t\t \twhen \"index\"\n\t\t \t\tputs \"indexing new document #{id}sidekiq ---------------------------\"\n\t\t \t\tbegin\n\t\t\t\t\trecord = Post.find(id)\n\t\t\t\t\trecord.__elasticsearch__.index_document\n\t\t\t\t\tputs \"indexed new document sidekiq #{id}---------------------------\"\n\t\t \t\trescue ActiveRecord::RecordNotFound\n\t\t \t\t\tputs \"record #{id} not found\"\n\t\t\t\tend\t\n\t\t \twhen \"delete\"\n\t\t \t\tputs \"deleting index of document number #{id}--------------------------------\"\n\t\t \t\tclient = Post.__elasticsearch__.client\n\t\t\t\tclient.delete index: Post.index_name, type: Post.model_name.to_s.downcase, id: id\n\t\t\t\tputs \"deleted index #{id}\"\n\t\tend\t\t\n \tend",
"def reindex!\n doc = {:id => neo_node_id }\n self.class.index_updaters.each_value do |updater|\n updater.call(self, doc)\n end\n lucene_index << doc\n end",
"def index!\n go = true\n while go\n if page_state() == :complete\n markers = page_info()\n volume = Volume.init(markers[:volnum], self.journal, markers[:year])\n issue = Issue.init(markers[:issnum], volume, markers[:pages])\n if config[:bulk_insert]\n Article.bulk_insert_with_check(articles(issue.issue_id), 1, [:title, :issue_id]) # specify an issue_id in the articles() method if using bulk insert\n else\n articles().each { |article| Article.init(article[:title], issue, article) }\n end\n if done? \n go = false\n else \n self.page = prev_page()\n end\n end\n end\n self.journal.complete!\n end",
"def perform\n rv = instance_eval(&self.block)\n\n self.index.build\n if not self.nested\n commit\n @database.notify\n end\n\n rv\n end",
"def index!(*objects)\n session.index!(*objects)\n end",
"def populate_background_index!(name)\n # make an index with a new client (in this thread, to avoid query check race after)\n name.freeze\n index = $client.dup.index(name)\n docs = index.docs(\"widget\")\n\n # do some busy work in background thread to generate bulk-indexing tasks we\n # can query at the caller. return the thread ref so caller can join on it\n Thread.new do\n 100.times.each do |i|\n docs.bulk do |d|\n (1..500).each do |j|\n d.index \\\n :foo => \"foo_#{i}_#{j}\",\n :bar => \"bar_#{i}_#{j}\",\n :baz => \"baz_#{i}_#{j}\"\n end\n end\n index.refresh\n end\n end\nend",
"def perform\n # Get unprocessed tweets\n options = { is_processed: false }\n tweets = RawTweet.where(options)\n unless tweets.nil?\n tweets.each do |tweet|\n if valid?(tweet.full_text)\n save_event(prep_event(tweet))\n end\n update_tweet(tweet.id)\n end\n end\n rescue NoMethodError => e\n puts e\n end",
"def index(*objects)\n objects.flatten.each do |object|\n client.index(object)\n end\n end",
"def reindex!\n find(:all).each { |r| r.update_index(true) }\n end",
"def index\n @statsupdaters = Statsupdater.all\n DailyupdaterJob.perform_later\n end",
"def index\n @@semaphore.synchronize {\n inner_index()\n }\n end",
"def index(model, instance = nil)\n return true if skip? instance\n\n self.class.enqueue(\n FlyingSphinx::IndexRequest.new(model.delta_index_names, true),\n delayed_job_priority\n )\n\n self.class.enqueue_without_duplicates_check(\n FlyingSphinx::FlagAsDeletedJob.new(\n model.core_index_names, instance.sphinx_document_id\n ),\n delayed_job_priority\n ) if instance\n\n true\n end",
"def index_item_set(all_items, o={})\n puts \"Indexing #{all_items.size} items...\" ; cur_docs = 0\n #Searcher.load_features() if !$clf\n all_items.in_groups_of(FileCollector::FILES_IN_BATCH) do |batch|\n items = batch.find_all{|d|d}\n\n #read contents\n if o[:download]\n $idx.read_files(items.find_all{|d|d.itype =~ /file/ && !d.content})\n items.each{|d| $idx.read_webpage(d) if d.itype =~ /webpage|concept/ && d.uri =~ /^http/}\n end\n #run indexing\n items.each{|d|$idx.index_item(d)}\n cur_docs += batch.size\n puts \"#{cur_docs} / #{all_items.size} finished\"\n end\n end",
"def index_write\n rugged_repository.index.reload\n yield(rugged_repository.index)\n rugged_repository.index.write\n end",
"def perform\n histories << SearchTermHistory.create\n touch # updated_at does not update automatically...\n end",
"def add_to_index(wiki, index, sha, files)\n end",
"def on_object_metadata_updated(event)\n return unless resource? event[:object]\n Hyrax.index_adapter.save(resource: event[:object])\n end",
"def indexAllItems\n Thread.current[:name] = \"index thread\" # label all stdout from this thread\n batch = emptyBatch({})\n loop do\n # Grab an item from the input queue\n Thread.current[:name] = \"index thread\" # label all stdout from this thread\n itemID, timestamp, prefilteredData = $indexQueue.pop\n itemID or break\n\n # Extract data and index it (in batches)\n begin\n Thread.current[:name] = \"index thread: #{itemID}\" # label all stdout from this thread\n indexItem(itemID, timestamp, prefilteredData, batch)\n rescue Exception => e\n puts \"Error indexing item #{itemID}\"\n raise\n end\n end\n\n # Finish off the last batch.\n batch[:items].empty? or $batchQueue << batch\n $batchQueue << nil # marker for end-of-queue\nend",
"def each(&block_)\n @indexes.each(&block_)\n end",
"def update_index\n index_files = []\n index_files << upload(\"specs.4.8.gz\", specs_index)\n log \"Uploaded all specs index\"\n index_files << upload(\"latest_specs.4.8.gz\", latest_index)\n log \"Uploaded latest specs index\"\n index_files << upload(\"prerelease_specs.4.8.gz\", prerelease_index)\n log \"Uploaded prerelease specs index\"\n\n index_files.each do |file|\n tuf_repo.replace_file(file, 'targets/unclaimed', 'targets')\n end\n\n # For now assume all files are unclaimed\n pending_files = tuf_pending_store.pending\n pending_files.each do |file|\n puts \"Adding file: #{file.path}\"\n tuf_repo.add_file(file, 'targets/unclaimed', 'targets')\n end\n tuf_repo.publish!\n tuf_pending_store.clear(pending_files)\n end",
"def add(tasks)\n tasks.each do |task|\n iter = @model.append()\n self.set(iter, task)\n end\n @tasks += tasks\n end",
"def perform\n index\n true\n end",
"def indexItem(itemID, batch, nailgun)\n\n # Grab the main metadata file\n metaPath = arkToFile(itemID, \"meta/base.meta.xml\")\n if !File.exist?(metaPath) || File.size(metaPath) < 50\n puts \"Warning: skipping #{itemID} due to missing or truncated meta.xml\"\n $nSkipped += 1\n return\n end\n rawMeta = fileToXML(metaPath)\n rawMetaXML = rawMeta.to_xml(indent: 3)\n rawMeta.remove_namespaces!\n rawMeta = rawMeta.root\n\n isPending = metaPath.include?(\"/next/\")\n\n existingItem = Item[itemID]\n\n normalize = nil\n if rawMeta.name =~ /^DISS_submission/ ||\n (rawMeta.name == \"mets\" && rawMeta.attr(\"PROFILE\") == \"http://www.loc.gov/mets/profiles/00000026.html\")\n normalize = \"ETD\"\n elsif rawMeta.name == \"mets\"\n normalize = \"BioMed\"\n elsif rawMeta.name == \"Publisher\"\n normalize = \"Springer\"\n end\n\n Thread.current[:name] = \"index thread: #{itemID} #{sprintf(\"%-8s\", normalize ? normalize : \"UCIngest\")}\"\n\n if normalize\n dbItem, attrs, authors, contribs, units, issue, section, suppSummaryTypes =\n processWithNormalizer(normalize, itemID, metaPath, nailgun, isPending)\n else\n dbItem, attrs, authors, contribs, units, issue, section, suppSummaryTypes =\n parseUCIngest(itemID, rawMeta, \"UCIngest\", isPending)\n end\n\n text = $noCloudSearchMode ? \"\" : grabText(itemID, dbItem.content_type)\n \n # Create JSON for the full text index\n authsAndContribs = authors.map { |auth| auth[:name][0,1024] } + contribs.map { |c| c[:name][0,1024] }\n idxItem = {\n type: \"add\", # in CloudSearch land this means \"add or update\"\n id: itemID,\n fields: {\n title: dbItem[:title] ? cleanTitle(dbItem[:title]) : \"\",\n authors: authsAndContribs.length > 1000 ? authsAndContribs[0,1000] : authsAndContribs,\n abstract: attrs[:abstract] || \"\",\n type_of_work: dbItem[:genre],\n disciplines: attrs[:disciplines] ? attrs[:disciplines] : [\"\"], # only the numeric parts\n peer_reviewed: attrs[:is_peer_reviewed] ? 1 : 0,\n pub_date: dbItem[:published].to_date.iso8601 + \"T00:00:00Z\",\n pub_year: dbItem[:published].year,\n rights: rightsURLToCode(dbItem[:rights]),\n sort_author: (authors[0] || {name:\"\"})[:name].gsub(/[^\\w ]/, '')[0,1024].downcase,\n keywords: attrs[:keywords] ? attrs[:keywords] : [\"\"],\n is_info: 0\n }\n }\n\n # Determine campus(es), department(s), and journal(s) by tracing the unit connnections.\n firstCampus = addIdxUnits(idxItem, units)\n\n # Use the first campus and various other attributes to make an OA policy association\n dbItem[:oa_policy] = oaPolicyAssoc(firstCampus, units, dbItem, attrs[:pub_status])\n\n # Summary of supplemental file types\n suppSummaryTypes.empty? or idxItem[:fields][:supp_file_types] = suppSummaryTypes.to_a\n\n # Limit text based on size of other fields (so, 1000 authors will mean less text).\n # We have to stay under the overall limit for a CloudSearch record. This problem is\n # a little tricky, since conversion to JSON introduces additional characters, and\n # it's hard to predict how many. So we just use a binary search.\n idxItem[:fields][:text] = text\n if JSON.generate(idxItem).bytesize > MAX_TEXT_SIZE\n idxItem[:fields][:text] = nil\n baseSize = JSON.generate(idxItem).bytesize\n toCut = (0..text.size).bsearch { |cut|\n JSON.generate({text: text[0, text.size - cut]}).bytesize + baseSize < MAX_TEXT_SIZE\n }\n (toCut==0 || toCut.nil?) and raise(\"Internal error: have to cut something, but toCut=#{toCut.inspect}\")\n #puts \"Note: Keeping only #{text.size - toCut} of #{text.size} text chars.\"\n idxItem[:fields][:text] = text[0, text.size - toCut]\n end\n\n # Make sure withdrawn items get deleted from the index. Also make sure pending items\n # aren't in the index.\n if attrs[:suppress_content] || dbItem[:status] == \"pending\"\n idxItem = {\n type: \"delete\",\n id: itemID\n }\n end\n\n dbAuthors = authors.each_with_index.map { |data, idx|\n ItemAuthor.new { |auth|\n auth[:item_id] = itemID\n auth[:attrs] = JSON.generate(data)\n auth[:ordering] = idx\n }\n }\n\n roleCounts = Hash.new { |h,k| h[k] = 0 }\n dbContribs = contribs.each_with_index.map { |data, _idx|\n ItemContrib.new { |contrib|\n contrib[:item_id] = itemID\n contrib[:role] = data[:role]\n data.delete(:role)\n contrib[:attrs] = JSON.generate(data)\n contrib[:ordering] = (roleCounts[contrib[:role]] += 1)\n }\n }\n\n # For convenient spelunking, record the archival metadata in the db\n dbArchiveMeta = collectArchiveMeta(itemID, rawMetaXML)\n\n # Calculate digests of the index data and database records\n idxData = JSON.generate(idxItem)\n idxDigest = Digest::MD5.base64digest(idxData)\n dbCombined = {\n dbItem: dbItem.to_hash,\n dbAuthors: dbAuthors.map { |authRecord| authRecord.to_hash },\n dbIssue: issue ? issue.to_hash : nil,\n dbSection: section ? section.to_hash : nil,\n units: units,\n archiveMeta: dbArchiveMeta.to_hash\n }\n dbContribs.empty? or dbCombined[:dbContribs] = dbContribs.map { |record| record.to_hash }\n dataDigest = Digest::MD5.base64digest(JSON.generate(dbCombined))\n\n # Add time-varying things into the database item now that we've generated a stable digest.\n timestamp = $preindexMode ? nil : DateTime.now\n dbItem[:last_indexed] = timestamp\n dbItem[:index_digest] = $noCloudSearchMode ? (existingItem && existingItem[:index_digest]) : idxDigest\n dbItem[:data_digest] = dataDigest\n\n dbDataBlock = { dbItem: dbItem, dbAuthors: dbAuthors, dbContribs: dbContribs,\n dbIssue: issue, dbSection: section, units: units,\n dbArchiveMeta: dbArchiveMeta }\n\n # Single-item debug\n if $testMode\n fooData = dbCombined.clone\n fooData.delete(:archiveMeta)\n pp fooData\n fooData = idxItem.clone\n fooData[:fields] and fooData[:fields][:text] and fooData[:fields].delete(:text)\n pp fooData\n exit 1\n end\n\n # If nothing has changed, skip the work of updating this record.\n if existingItem && !$forceMode && ($preindexMode || existingItem[:index_digest] == idxDigest)\n\n # If only the database portion changed, we can safely skip the CloudSearch re-indxing\n if existingItem[:data_digest] != dataDigest\n puts \"#{$forceMode ? \"Forced\" : \"Changed\"} item. (database change only, search data unchanged)\"\n $dbMutex.synchronize {\n DB.transaction { updateDbItem(dbDataBlock) }\n }\n $nProcessed += 1\n return\n end\n\n # Nothing changed; just update the timestamp.\n puts \"Unchanged item.\"\n existingItem.last_indexed = timestamp\n existingItem.save\n $nUnchanged += 1\n return\n end\n\n puts \"#{existingItem ? ($forceMode ? 'Forced' : 'Changed') : 'New'} item.#{attrs[:suppress_content] ? \" (suppressed content)\" : \"\"}\"\n\n if $noCloudSearchMode\n $dbMutex.synchronize {\n DB.transaction { updateDbItem(dbDataBlock) }\n }\n $nProcessed += 1\n return\n end\n\n # Make doubly sure the logic above didn't generate a record that's too big.\n if idxData.bytesize >= 1024*1024\n puts \"idxData=\\n#{idxData}\\n\\nInternal error: generated record that's too big.\"\n exit 1\n end\n\n # If this item won't fit in the current batch, send the current batch off and clear it.\n if batch[:idxDataSize] + idxData.bytesize > MAX_BATCH_SIZE || batch[:items].length > MAX_BATCH_ITEMS\n #puts \"Prepared batch: nItems=#{batch[:items].length} size=#{batch[:idxDataSize]} \"\n batch[:items].empty? or $batchQueue << batch.clone\n emptyBatch(batch)\n end\n\n # Now add this item to the batch\n batch[:items].empty? or batch[:idxData] << \",\\n\" # Separator between records\n batch[:idxData] << idxData\n batch[:idxDataSize] += idxData.bytesize\n batch[:items] << dbDataBlock\n #puts \"current batch size: #{batch[:idxDataSize]}\"\nend",
"def index_data(*models)\n if models.nil? || models.empty?\n only_index = @indexed_models\n else\n only_index = models.collect{|m| m.to_s}\n end \n \n Mebla.log(\"Indexing #{only_index.join(\", \")}\", :debug)\n \n # Build up a bulk query to save processing and time\n bulk_query = \"\"\n # Keep track of indexed documents\n indexed_count = {}\n \n # Create the index\n if create_index\n # Start collecting documents\n only_index.each do |model|\n Mebla.log(\"Indexing: #{model}\")\n # Get the class\n to_index = model.camelize.constantize\n \n # Get the records \n entries = []\n unless to_index.embedded?\n if to_index.sub_class?\n entries = to_index.any_in(:_type => [to_index.name])\n else \n entries = to_index.any_in(:_type => [nil, to_index.name])\n end\n else\n parent = to_index.embedded_parent\n access_method = to_index.embedded_as\n \n parent.all.each do |parent_record|\n if to_index.sub_class?\n entries += parent_record.send(access_method.to_sym).any_in(:_type => [to_index.name])\n else\n entries += parent_record.send(access_method.to_sym).any_in(:_type => [nil, to_index.name])\n end\n end\n end\n \n # Save the number of entries to be indexed\n indexed_count[model] = entries.count \n \n # Build the queries for this model \n entries.each do |document|\n attrs = {} #document.attributes.dup # make sure we dont modify the document it self\n attrs[:id] = document.attributes[\"_id\"] # the id is already added in the meta data of the action part of the query\n \n # only index search fields and methods\n document.class.search_fields.each do |field|\n if document.attributes.keys.include?(field.to_s)\n attrs[field] = document.attributes[field.to_s] # attribute\n else\n attrs[field] = document.send(field) # method\n end\n end\n \n # index relational fields\n document.class.search_relations.each do |relation, fields| \n items = document.send(relation.to_sym) # get the relation document\n \n next if items.nil?\n \n # N relation side\n if items.is_a?(Array) || items.is_a?(Mongoid::Relations::Targets::Enumerable)\n next if items.empty?\n attrs[relation] = []\n items.each do |item|\n if fields.is_a?(Array) # given multiple fields to index\n fields_values = {}\n fields.each do |field|\n if item.attributes.keys.include?(field.to_s)\n fields_values.merge!({ field => item.attributes[field.to_s] }) # attribute\n else\n fields_values.merge!({ field => item.send(field) }) # method\n end\n end\n attrs[relation] << fields_values\n else # only index one field in the relation\n if item.attributes.keys.include?(fields.to_s)\n attrs[relation] << { fields => item.attributes[fields.to_s] } # attribute\n else\n attrs[relation] << { fields => item.send(fields) } # method\n end\n end\n end\n # 1 relation side\n else\n attrs[relation] = {}\n if fields.is_a?(Array) # given multiple fields to index\n fields_values = {}\n fields.each do |field|\n if items.attributes.keys.include?(field.to_s)\n fields_values.merge!({ field => items.attributes[field.to_s] }) # attribute\n else\n fields_values.merge!({ field => items.send(field) }) # method\n end\n end\n attrs[relation].merge!(fields_values)\n else # only index one field in the relation\n if items.attributes.keys.include?(fields.to_s)\n attrs[relation].merge!({ fields => items.attributes[fields.to_s] }) # attribute\n else\n attrs[relation].merge!({ fields => items.send(fields) }) # method\n end\n end\n end\n end \n \n # If embedded get the parent id\n if document.embedded?\n parent_id = document.send(document.class.embedded_parent_foreign_key.to_sym).id.to_s \n attrs[(document.class.embedded_parent_foreign_key + \"_id\").to_sym] = parent_id\n attrs[:_parent] = parent_id\n \n # Build add to the bulk query\n bulk_query << build_bulk_query(@slingshot_index_name, to_index.slingshot_type_name, document.id.to_s, attrs, parent_id)\n else\n # Build add to the bulk query\n bulk_query << build_bulk_query(@slingshot_index_name, to_index.slingshot_type_name, document.id.to_s, attrs)\n end\n end\n end\n else\n raise Mebla::Errors::MeblaIndexException.new(\"Could not create #{@slingshot_index_name}!!!\")\n end \n \n Mebla.log(\"Bulk indexing:\\n#{bulk_query}\", :debug) \n \n # Send the query\n response = Slingshot::Configuration.client.post \"#{Mebla::Configuration.instance.url}/_bulk\", bulk_query\n \n # Only refresh the index if no error ocurred\n unless response =~ /error/ \n # Log results\n Mebla.log(\"Indexed #{only_index.count} model(s) to #{self.slingshot_index_name}: #{response}\")\n Mebla.log(\"Indexing Report:\")\n indexed_count.each do |model_name, count|\n Mebla.log(\"Indexed #{model_name}: #{count} document(s)\")\n end\n \n # Refresh the index\n refresh_index\n else\n raise Mebla::Errors::MeblaIndexException.new(\"Indexing #{only_index.join(\", \")} failed with the following response:\\n #{response}\")\n end\n rescue RestClient::Exception => error\n raise Mebla::Errors::MeblaIndexException.new(\"Indexing #{only_index.join(\", \")} failed with the following error: #{error.message}\")\n end",
"def index()\n INDEXES.find { |i| (self + i).exist? }&.yield_self { |i| self + i }\n end",
"def perform\n track do\n runner.tick!\n @changes = Hash.new { |h, k| h[k] = Accumulator.new }\n\n @registry.each do |mapping|\n mapping.for_worker(self) do\n task(\"PROPAGATING RECORDS\", mapping) { propagate mapping }\n task(\"CLEANING RECORDS\", mapping) { clean mapping }\n task(\"COLLECTING CHANGES\", mapping) { collect mapping }\n task(\"UPDATING ASSOCIATIONS\", mapping) { associate mapping }\n end\n end\n\n # NOTE: We can only perform the synchronization after all record\n # changes have been aggregated, so this second loop is necessary.\n @registry.each do |mapping|\n mapping.for_worker(self) do\n task(\"APPLYING CHANGES\", mapping) { synchronize mapping }\n end\n end\n end\n end",
"def index\n load_event\n load_lists\n end",
"def update_index(*args)\n\n # This fixes bug https://github.com/sciencehistory/chf-sufia/issues/428 .\n # It updates the display_label property for each inscription associated with this work\n # before said display_label is indexed into SOLR's 'inscription_tesim' field.\n # That field, in turn, is what is shown on the individual work display page\n # as the inscription[s].\n self.inscription.map(&:compose_label)\n # end fix\n\n super.tap do\n if self.changes.keys.include?(\"representative_id\") ||\n self.previous_changes.keys.include?(\"representative_id\") ||\n (self.changes.blank? && self.previous_changes.blank?)\n GenericWork.where(GenericWork.reflections[:representative_id].solr_key => self.id).each do |parent_work|\n parent_work.update_index\n end\n end\n end\n end",
"def update_aggregates\n es_client.indices.refresh index: index_name\n self.update_attributes(\n num_users: sample_users.length,\n num_tweets: es_client.count(index: index_name)['count'],\n num_retweets: count_retweets,\n hashtags: MetadataHarvester.new(:hashtags, all_tweets).harvest,\n top_urls: MetadataHarvester.new(:urls, all_tweets).harvest,\n top_words: MetadataHarvester.new(:words, all_tweets).harvest,\n top_mentions: MetadataHarvester.new(:mentions, all_tweets).harvest,\n top_sources: MetadataHarvester.new(:sources, all_tweets).harvest,\n top_retweets: MetadataHarvester.new(:retweets, all_tweets).harvest\n )\n end",
"def update_all\n #require 'benchmark'\n #updated = 0\n #Benchmark.bm {|t|\n #t.report(\"Tick update\") do\n @game_objects.each do |go|\n go.update\n # updated += 1\n end\n #end\n #}\n #log \"Updated #{updated} objects\", Logger::Medium\n\n @calendar.tick\n end",
"def run_all()\n end",
"def index\n @ends = End.all\n #UpdateCodeJob.perform_later\n end",
"def add(key, object)\n if not @monitor.has_key?(key)\n @monitor[key] = @block.call(object)\n @monitor[key].on_update { |value| collection_updated(object, value) }\n collection_updated(object, @monitor[key].cur) # FIXME: First notification should be automatic\n end\n end",
"def load_all!\n Log.info \"Loading #{self} list\"\n old_objs = @objs_list || {}\n @objs_list = {}\n each_api_item do |api_hsh|\n params = api_hsh_to_params(api_hsh)\n if obj = old_objs[params[:id]] then obj.update! params\n else obj = self.new(params) end\n register obj\n end\n Log.info \"Loaded list of #{@objs_list.length} #{self}s\"\n @objs_list\n end",
"def on_object_membership_updated(event)\n resource = event.to_h.fetch(:object) { Hyrax.query_service.find_by(id: event[:object_id]) }\n return unless resource?(resource)\n\n Hyrax.index_adapter.save(resource: resource)\n rescue Valkyrie::Persistence::ObjectNotFoundError => err\n Hyrax.logger.error(\"Tried to index for an #{event.id} event with \" \\\n \"payload #{event.payload}, but failed due to error:\\n\"\\\n \"\\t#{err.message}\")\n end",
"def added_tasks(tasks)\n\t\tsuper if defined? super\n\t\tPlanModificationHooks.added_objects(self, tasks)\n\t end",
"def collection\n unless @collection\n @collection = @connection.use(@database_name)[\"sunspot_index_queue_entries\"]\n\n @collection.indexes.create_one(:record_class_name => 1, :record_id => 1)\n @collection.indexes.create_one(:priority => -1, :record_class_name => 1, :run_at => 1, :lock => 1)\n end\n\n @collection\n end",
"def update_tank_indexes\n if tanker_indexable?\n tanker_config.index.add_document(\n it_doc_id, tanker_index_data, tanker_index_options\n )\n else\n delete_tank_indexes\n end\n end",
"def collect entity\n touch entity, true\n end",
"def add_to_my_list(task)\n @my_list << task\n end",
"def update_index\n SolrService.add(to_solr, softCommit: true)\n end",
"def perform\n\n # Get all twitter accounts if any\n accounts = TwitterAccount.exists? ? TwitterAccount.least_checked(LIMIT) : []\n\n accounts.each do |account|\n account_name = account.twitter_name\n\n if Event.exists?(username: account_name)\n recent_tweet_id = Event.maximum('tweet_id')\n options = {\n since_id: recent_tweet_id\n }\n else\n options = {\n count: 20\n }\n end\n\n fetch_job(account_name, options)\n update_account(account.id)\n end\n\n end",
"def each(&b)\n @index.each(&b)\n end",
"def sync()\n #This is a stub, used for indexing\n end",
"def index_array arr\n bulk = client.prepare_bulk\n arr.each do |doc|\n request = IndexRequest.new(@index).type(@type).create(true).source(doc.indexable_json)\n bulk.add(request)\n end\n warn(\"About to bulk index #{arr.size} documents, starting with #{arr.first.inspect}\")\n bulk.execute.action_get\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 perform\n return if cancelled?\n\n objects = [*1..200]\n batch = Sidekiq::Batch.new\n batch.on(:complete, 'BatchWorker')\n total objects.count\n batch.jobs do\n objects.each_with_index do |object, index|\n at(index + 1, \"Processing object #{object}\")\n PrintWorker.perform_async(object, index)\n end\n end\n end",
"def add_queued(documents)\n noun = documents.size > 1 ? \"documents\" : \"document\"\n logger.info \"Queueing #{documents.size} #{noun} to add to #{index_name}\"\n\n document_hashes = documents.map { |d| d.elasticsearch_export }\n queue.queue_many(document_hashes)\n end"
] | [
"0.637425",
"0.6295339",
"0.6145428",
"0.6056693",
"0.5921263",
"0.5916757",
"0.59163386",
"0.58987886",
"0.583899",
"0.5810647",
"0.57923144",
"0.57892627",
"0.5765518",
"0.57614255",
"0.57206905",
"0.5717567",
"0.57149637",
"0.57055455",
"0.57003844",
"0.56529224",
"0.5633463",
"0.5596781",
"0.55860096",
"0.55860096",
"0.5553036",
"0.55490875",
"0.5512502",
"0.5494566",
"0.5492066",
"0.5489585",
"0.54870117",
"0.54720455",
"0.54716015",
"0.5439953",
"0.54399097",
"0.543465",
"0.54299766",
"0.5421196",
"0.54173464",
"0.540936",
"0.5407696",
"0.54040176",
"0.5379421",
"0.5373355",
"0.5372917",
"0.5371804",
"0.53712106",
"0.5361221",
"0.5355145",
"0.53199184",
"0.53180766",
"0.531746",
"0.5311717",
"0.5306008",
"0.52998894",
"0.5289807",
"0.5285151",
"0.52827096",
"0.5280663",
"0.5272672",
"0.5266521",
"0.52656025",
"0.52534425",
"0.524594",
"0.524589",
"0.52422345",
"0.524086",
"0.5237177",
"0.5236951",
"0.5228908",
"0.5226477",
"0.52212584",
"0.5217435",
"0.51925164",
"0.518822",
"0.51845235",
"0.51558834",
"0.5154824",
"0.51543474",
"0.5141722",
"0.51362926",
"0.51313937",
"0.5130563",
"0.5117779",
"0.5107512",
"0.5100995",
"0.5097077",
"0.50906456",
"0.50856954",
"0.5084453",
"0.50750893",
"0.5073253",
"0.5071811",
"0.50679505",
"0.5066758",
"0.50640297",
"0.505872",
"0.50571257",
"0.50559026",
"0.5048051",
"0.5047474"
] | 0.0 | -1 |
TODO: binary search, but let's not preoptimize | def insert_sorted(obj)
raise IndexError, <<-msg.squish if include? obj
Tried to insert #{obj.inspect} into #{self.inspect},
which is a duplicate of #{self[name_of(obj)].inspect}.
msg
name = name_of(obj)
inserted = false
list.each_with_index do |e, i|
if name_of(e) > name
list.insert i, obj
inserted = true
break
end
end
list << obj unless inserted
list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binary_search(ary, value); end",
"def binsearch(ary, x)\n left = 0\n right = ary.length - 1\n while left < right\n middle = (left + right) / 2\n Tanj.array :ary, index: [:left..:right, :middle]\n if ary[middle] == x\n Tanj.message \"found it!\"\n return middle\n elsif ary[middle] < x\n Tanj.message \"too small\"\n left = middle + 1\n elsif ary[middle] > x\n Tanj.message \"too large\"\n right = middle - 1\n else\n Tanj.message \"this should be unreachable!\"\n end\n end\n Tanj.message \"didn't find it\"\n return nil\nend",
"def binary_search(arr, target)\n return nil if arr.empty?\n probe_index = arr.size / 2\n probe_ele = arr[probe_index]\n\n case probe_ele <=> target\n when 1\n left_arr = arr.take(probe_index) \n return binary_search(left_arr,target)\n when 0 \n return probe_index\n when -1\n compensated_index = (probe_index + 1)\n right_arr = arr.drop(compensated_index)\n return nil if binary_search(right_arr,target).nil?\n return binary_search(right_arr,target) + compensated_index\n end\nend",
"def bin_search(x, a, b)\r\n mid = (a + b) / 2\r\n sq = mid ** 2\r\n \r\n if a == b || sq == x\r\n mid\r\n elsif sq > x\r\n bin_search(x, a, mid - 1)\r\n else\r\n (mid + 1) ** 2 > x ? mid : bin_search(x, mid + 1, b)\r\n end\r\nend",
"def bsearch(array, target)\nend",
"def bsearch(array, target)\n # compare target value to middle element\n #if target value is == to middle elements value\n #return the position and end\n # if target value is less than middle value seach lower half of array\n # same goes for greater than (search upper half)\n # when it searches lower or upper half it keeps the same logic as the beginning\n # nil if not found; can't find anything in an empty array\n return nil if array.empty?\n\n index = array.length / 2\n # spaceship operator magic!\n case target <=> array[index]\n when -1 #search left side\n bsearch(array.take(index), target)\n when 0\n index\n when 1 #search right side\n answer = bsearch(array.drop(index + 1), target)\n answer.nil? ? nil : index + 1 + answer\n end\nend",
"def bsearch(nums, target)\n return nil if nums.empty?\n\n probe_index = nums.length / 2\n case target <=> nums[probe_index]\n when -1\n bsearch(nums.take(probe_index), target)\n when 0\n probe_index\n when 1\n\n sub_answer = bsearch(nums.drop(probe_index + 1), target)\n (sub_answer.nil?) ? nil : (probe_index + 1) + sub_answer\n end\n\nend",
"def binary_search(target, array)\r\n\t#Your code here\r\n\tindex = array.length / 2\r\n\tlo = 0\r\n\thi = array.length - 1\r\n\twhile array[index] != target && array.include?(target)\r\n\t\tif array[index] > target\r\n\t\t\thi = index - 1\r\n\t\t index = (lo + hi) / 2\r\n\t\telsif array[index] < target\r\n\t\t\tlo = index + 1\r\n\t\t\tindex = (lo + hi) / 2\r\n\t\tend\r\n\tend\r\n\tif array[index] == target\r\n\t\treturn index\r\n\telse\r\n\t\treturn -1\r\n\tend \r\nend",
"def bsearch(array, target)\n return nil if !array.include?(target)\n arr = array.sort\n\n mid = arr.length / 2\n\n\n if arr[mid] == target\n return mid\n elsif arr[mid] < target\n mid + bsearch(arr[mid..-1], target)\n else\n bsearch(arr[0..mid-1], target)\n end\nend",
"def do_search(target_value, array)\n min = 0\n max = array.length - 1\n\n binary_search(target_value, array, min, max)\nend",
"def bin_search(arr, key)\n low = 0\n high = arr.length - 1\n while high >= low do\n mid = low + (high - low) / 2\n if arr[mid] > key\n high = mid - 1\n elsif arr[mid] < key\n low = mid + 1\n else\n return mid\n end\n end\n return 0\nend",
"def binary_search(array, target)\n lower_bound = 0\n upper_bound array.length - 1\n while lower_bound <= upper_boud do\n midpoint = (upper_bound + lower_bound) / 2\n value_at_midpoint = array[midpoint]\n if target == value_at_midpoint\n return midpoint\n elsif target < value_at_midpoint\n upper_bound = midpoint - 1\n elsif target > value_at_midpoint\n lower_bound = midpoint + 1\n end\n end\n return nil\nend",
"def binary_search(length, prime)\r\n\r\nend",
"def rec_bin_search(array, target)\n return nil if array.length == 0\n\n midpoint = array.length / 2\n\n return midpoint if array[midpoint] == target\n\n if target < array[midpoint]\n rec_bin_search(array.take(midpoint), target)\n else\n top = rec_bin_search(array.drop(midpoint + 1), target)\n top == nil ? nil : top + (midpoint + 1)\n end\nend",
"def bsearch(arr, target)\n return nil if arr.length == 1 && arr[0] != target\n mid_i = arr.length / 2\n return mid_i if arr[mid_i] == target\n\n low_arr = arr[0...mid_i]\n high_arr = arr[mid_i+1..-1]\n\n if arr[mid_i] > target\n bsearch(low_arr, target) \n elsif bsearch(high_arr, target) != nil\n low_arr.length + 1 + bsearch(high_arr, target)\n end\n\nend",
"def binary_search(arr, val, strategy='rec')\n if strategy != 'rec'\n search(arr, val)\n else\n rec_search(arr, val, 0, arr.size - 1)\n end\nend",
"def bsearch(arr,target)\n# p arr\nreturn nil if arr.length==1 && target != arr[0]\nmid =arr.length/2 # 3,1,1,0\n# if arr.length==1 && arr[0] != target\n# return nil\n# end\n\n\nif target==arr[mid]\n\nreturn mid\nelsif target<arr[mid]\n left_index = 0\n right_index = mid-1\n return bsearch(arr[left_index..right_index],target)\n# return bsearch(arr.take(mid),target)\nelse\n left_index = mid+1\n right_index = arr.length-1\n sub_position=bsearch(arr[left_index..right_index],target)\n # sub_position=bsearch(arr.drop(mid+1),target)\n return sub_position.nil? ? nil : (mid+1)+sub_position \n\nend\nend",
"def bsearch(array, target)\n return nil if array.empty?\n\n mid_idx = array.length / 2\n mid_ele = array[mid_idx]\n\n return mid_idx if target == mid_ele\n\n if target < mid_ele\n sub_arr = array[0...mid_idx]\n return bsearch(sub_arr, target)\n else\n sub_arr = array[mid_idx + 1..-1]\n next_search = bsearch(sub_arr, target)\n return nil if next_search == nil\n return mid_idx + 1 + next_search\n end\nend",
"def binary_search(numbers, element)\n min = 0\n max = numbers.size - 1\n\n index = nil\n\n while index.nil? do\n middle_element_index = (min + max) / 2 # Every iteration (N / 2) = O(log n)\n middle_element = numbers[middle_element_index] \n \n if element < middle_element\n max = middle_element_index\n elsif element > middle_element\n min = middle_element_index\n elsif element == middle_element\n index = middle_element_index\n end\n end\n\n index\nend",
"def binary_search(name)\n #1 we save index of leftmost item in array called lower\n #index of rightmost item stored at upper\n lower = 0\n upper = entries.length - 1\n\n #2 loop while our lower index is less than or equal to our upper index\n while lower <= upper\n #3 find the middle index by taking sum of\n #lower and upper and dividing by two\n #retrieve name of entry at middle index and store it in mid_name\n mid = (lower + upper) / 2\n mid_name = entries[mid].name\n\n #4 compare name we are searching for to name of middle index mid_name\n if name == mid_name #found name we are looking for\n return entries[mid] #return entry ad index mid\n elsif name < mid_name #set upper to mid - 1 b/c name must be in lower half of array\n upper = mid - 1\n elsif name > mid_name #alphabetically after mid_name then we set lower\n lower = mid + 1 #lower is set to mid + 1 b/c name must be in the upper half of array\n end\n end\n\n #5 if we divide and conque until no match is found then return nil\n return nil\n end",
"def bsearch(array, target)\n mid_point = array.length / 2\n\n return mid_point if target == array[mid_point]\n return nil if array.length == 1\n\n left_hand = array[0...mid_point]\n right_hand = array[mid_point..-1]\n\n if target < array[mid_point]\n bsearch(left_hand, target)\n else\n result = bsearch(right_hand, target)\n return nil if result.nil?\n mid_point + result\n end\n\nend",
"def bsearch(arr,target)\r\n return nil if arr.length == 0 \r\n midIdx = arr.length/2\r\n mid = arr[midIdx] \r\n if mid > target #left half\r\n bsearch(arr[0...midIdx],target)\r\n elsif mid < target #right half\r\n\r\n idx = bsearch(arr[midIdx+1..-1],target)\r\n if idx \r\n idx + arr[0..midIdx].length\r\n else\r\n return nil\r\n end\r\n \r\n else\r\n return midIdx\r\n end\r\n\r\nend",
"def binary_search(arr,tar)\n return nil if arr.length < 1\n mid_idx = arr.length / 2\n if arr[mid_idx] == tar\n return mid_idx\n elsif arr[mid_idx] > tar\n binary_search(arr[0...mid_idx],tar)\n elsif arr[mid_idx] < tar\n subanswer = binary_search(arr[mid_idx+1..-1],tar)\n subanswer.nil? ? nil : (mid_idx+1) + subanswer\n end\nend",
"def binary_searcher(array, value)\n array.bsearch { |integer| value <=> integer } || false\n\nend",
"def binary_search_internal(value)\n return [false, 0] if @inner.size == 0\n left = 0\n right = @inner.size - 1\n return [false, 0] if value < @inner[left]\n return [false, right + 1] if value > @inner[right]\n while left <= right\n middle = (left + right) / 2\n if @inner[middle] == value\n return [true, middle]\n elsif value < @inner[middle]\n right = middle - 1\n else\n left = middle + 1\n end\n end\n return [false, left]\n end",
"def binary_search(array, length, value_to_find)\n # take the length and divide in half,\n # start_index = 0\n # end_index = length - 1\n # midpoint = length / 2\n # until start_index > end_index\n #\n # end\n\nend",
"def bsearch(arr, target)\n if arr.length == 1 \n if arr[0] == target\n return 0\n else\n return nil\n end\n end\n arr.sort!\n middle = arr.length / 2\n left = arr[0...middle]\n right = arr[middle + 1..-1]\n if arr[middle] == target\n return middle\n elsif arr[middle] < target\n if bsearch(right, target).nil?\n return nil\n # else\n return left.length + 1 + bsearch(right, target)\n end\n else \n bsearch(left, target)\n end\nend",
"def binary_search(a, key)\n low = 0\n high = a.length - 1\n\n while low <= high\n mid = low + ((high - low) / 2)\n\n return mid if a[mid] == key\n\n if key < a[mid]\n high = mid - 1\n else\n low = mid + 1\n end\n end\n\n return -1\nend",
"def ubiquitous_binary_search(a,key) # a is the array and key is the value we want to search\n lo= 0\n hi = a.length-1\n \n while(hi-lo>1)\n mid = lo + (hi-lo)/2\n \n if a[mid]<=key\n lo=mid\n else\n hi=mid\n end\n end\n \n if (a[lo]== key)\n return lo\n elsif (a[hi]== key)\n return hi\n else\n return \"value not found\"\n end\nend",
"def binary_search(array, target)\n lower_bound = 0\n upper_bound = array.length - 1\n while lower_bound <= upper_bound\n midpoint = (lower_bound + upper_bound) / 2\n value_at_midpoint = array[midpoint]\n if target = value_at_midpoint\n return midpoint\n elsif target > value_at_midpoint\n lower_bound = midpoint + 1\n elsif target < value_at_midpoint\n upper_bound = midpoint - 1\n end\n end\n return nil\nend",
"def binary_search(collection, value)\n low = 0\n high = collection.length\n if low >= high\n return \"not found\"\n end\n\n mid = (high / 2).ceil\n\n if collection[mid] == value\n return collection[mid]\n elsif collection[mid] < value\n binary_search(collection[(mid+1)...high], value)\n else\n binary_search(collection[low...mid], value)\n end\nend",
"def bsearch(arr, target)\n return nil if arr.empty?\n mid = arr.length / 2\n return mid if arr[mid] == target\n\n if target < arr[mid]\n bsearch(arr[0...mid], target)\n else\n result = bsearch(arr[mid + 1..-1], target)\n result.nil? ? nil : mid + 1 + result\n end\nend",
"def bsearch(arr, num)\n return nil if !arr.include?(num)\n\n mid_idx = arr.length / 2\n if arr[mid_idx] == num\n return mid_idx\n elsif arr[mid_idx] > num\n lower_half = arr[0...mid_idx]\n bsearch(lower_half, num)\n else\n upper_half = arr[(mid_idx + 1)..-1]\n bsearch(upper_half, num)\n end\n\nend",
"def use_binary_search(list, item)\r\n low = 0\r\n high = list.length - 1\r\n while low <= high\r\n mid = (low + high)\r\n guess = list[mid]\r\n if guess == item\r\n return mid\r\n end\r\n if guess > item\r\n high = mid - 1\r\n else\r\n low = mid + 1\r\n end\r\n end\r\n return nil\r\nend",
"def binary_search(arr, target)\n return nil if !arr.include?(target)\n middle_ele = arr[arr.length / 2]\n middle_idx = arr.length / 2\n if target == middle_ele\n return middle_idx\n elsif target > middle_ele\n binary_search(arr[middle_idx+1..-1], target) + arr[0..middle_idx].length\n else\n binary_search(arr[0...middle_idx], target)\n end\nend",
"def bsearch arr, target \n return nil if arr.length == 1 && !arr.include?(target)\n\n mid_idx = arr.length / 2\n\n return mid_idx if arr[mid_idx] == target \n \n left = arr.take(mid_idx)\n right = arr.drop(mid_idx)\n\n if arr[mid_idx] > target \n bsearch(left, target)\n else \n result = bsearch(right,target)\n if result.nil? \n return nil \n else \n result + mid_idx\n end\n end\nend",
"def bsearch(array, target)\n return nil if array.length == 1 && target != array[0]\n idx = array.length / 2\n mid_ele = array[idx]\n\n if target == mid_ele\n return idx\n elsif target < mid_ele\n return bsearch(array[0...idx], target)\n else\n if bsearch(array[idx+1..-1], target).nil?\n return nil\n else\n return idx + 1 + bsearch(array[idx+1..-1], target)\n end\n end\nend",
"def bsearch(array, value)\n return nil if array.empty?\n # return nil if !array.include?(value)\n\n # debugger\n indeces = array.dup.freeze #[1, 2, 3]\n \n middle = (array.length) / 2\n left = array[(0...middle)]\n right = array[(middle..-1)]\n\n # debugger\n if array[middle] == value\n return indeces.index(value) \n elsif value < array[middle]\n bsearch(left, value)\n else\n middle + bsearch(right, value)\n end\n #somewhere bsearch(array[(0..-2)]\nend",
"def binary_search(a, key)\n# At every step, consider the array between low and high indices\n# Define initial low and high indices \n low = 0\n high = a.length - 1\n\n\n# If low value is less or equal to high value, calculate the mid index.\n while low <= high\n mid = low + ((high - low) / 2)\n\n# If the element at the mid index is the key, return mid.\n if a[mid] == key\n return mid\n end\n\n# If the element at mid is greater than the key, then change the index high to mid - 1.\n# The index at low remains the same.\n if key < a[mid]\n high = mid - 1\n\n# If the element at mid is less than the key, then change low to mid + 1. The index at high remains the same.\n else\n low = mid + 1\n end\n end\n\n# Through interations, the low indice will be larger than the high indice if the key doesn’t exist, so -1 is returned.\n return -1\nend",
"def binary_search(a, key)\n return binary_search_rec(a, key, 0, a.length - 1)\nend",
"def binary_search(array, length, value_to_find)\n high = length\n low = 0\n length.times do\n guess = (low + high) / 2\n return true if array[guess] == value_to_find\n return false if high - low <= 1\n array[guess] < value_to_find ? low = guess : high = guess\n end\nend",
"def binary_search(array, key)\n low, high = 0, array.length - 1\n while low <= high\n mid = (low + high) >> 1\n case key <=> array[mid] # if key < array[mid] then return -1 if key = array[mid] then 0 else return 1\n\t when 1\n low = mid + 1\n when -1\n high = mid - 1\n else\n return mid\n end\n end\nend",
"def bsearch(arr, target)\n i = 0\n j = arr.length - 1\n while i <= j\n m = (i + j) / 2\n if target < arr[m]\n j = m - 1\n elsif target > arr[m]\n i = m + 1\n elsif target == arr[m]\n return m\n end\n end\n -1\nend",
"def binary_search_iterative(array, target)\n# declare variables for low and high positions\nlow_index = 0\nhigh_index = array.length - 1\nmid_index = (high_index + low_index) / 2\n\n# while the low is less than the high\nwhile low_index <= high_index do\n\n return mid_index if target == array[mid_index]\n\n puts \"#{low_index} #{mid_index} #{high_index}\"\n\n if low_index == mid_index\n return high_index\n elsif target > array[mid_index]\n # move lower bound up to mid, recalculate new mid\n low_index = mid_index\n # set the high halfway between\n mid_index = (low_index + high_index) / 2\n elsif target < array[mid_index]\n # move upper bound to mid, recalculate new mid\n high_index = mid_index\n mid_index = (low_index + high_index) / 2\n end\n end\nend",
"def bi_search(search_array, search_value, low = 0, high = nil)\n high ||= search_array.length - 1\n middle = ((low + high) / 2).ceil\n if low > high\n return -1\n elsif search_value == search_array[middle]\n return middle\n elsif search_value < search_array[middle]\n high = middle - 1\n elsif search_value > search_array[middle]\n low = middle + 1\n end\n bi_search(search_array, search_value, low = low, high = high)\nend",
"def bin_search(target,array)\n lo = 0\n hi = array.length - 1\n mid = (lo+hi)/2\n while lo <= hi\n if array[mid] > target\n hi = mid-1\n mid = (lo+hi)/2\n elsif array[mid] < target\n lo = mid+1\n mid = (lo+hi)/2\n else\n return mid\n end\n end\n return -1\nend",
"def binary_search(arr, key)\n low = 0\n high = arr.length - 1\n\n while low <= high\n mid = low + (high - low) / 2\n\n return mid if arr[mid] == key\n\n arr[mid] > key ? high = mid - 1 : low = mid + 1\n end\n\n return -1\nend",
"def bsearch(arr, target)\n return nil if arr.length < 1\n # return nil if target > arr.max || target < arr.min\n compare_index = arr.length / 2\n match = target <=> arr[compare_index]\n case match\n when -1\n bsearch(arr.take(compare_index), target)\n when 0\n compare_index\n else\n result = bsearch(arr.drop(compare_index+1), target)\n return nil if result.nil?\n result + compare_index + 1\n end\nend",
"def binary_search(input)\n midpoint = input.length/2\n mid_minus_one = midpoint - 1\n\n if input[0] < input[-1] || input.length <= 1\n return input[0]\n\n elsif input[midpoint] < input[mid_minus_one]\n return input[midpoint]\n\n # if value at midpoint is less than value at end of array, then the\n # rotation point is on left side\n elsif input[midpoint] < input[-1]\n # call binary_search with left 1/2 of array\n binary_search(input[0..midpoint])\n\n # rotation point is on right side\n elsif input[midpoint] > input[-1]\n # call binary_search with right 1/2 of array\n binary_search(input[midpoint..-1])\n end\n\nend",
"def find_element(elem, elems)\n puts \"iterate #{elems}\"\n if (elems.size == 1)\n if elems[0] == elem\n return true\n else\n return false\n end\n end\n\n mid_point = elems.size/2\n puts \"mid point #{elems[mid_point]}\"\n\n # right hand is sorted\n if elems[mid_point] < elems[mid_point+1] && elems[mid_point] < elem\n # perform binary search just on the right\n result = find_element(elem, elems[mid_point+1..elems.size-1])\n elsif elems[mid_point] > elems[mid_point-1] && elems[mid_point] > elem\n # perform binary search just on the left\n result = find_element(elem, elems[0..mid_point])\n else\n # we cannot tell so perform on both\n puts \"perform on both\"\n result = find_element(elem, elems[elems.size/2+1..elems.size-1])\n unless result\n result = find_element(elem, elems[0..elems.size/2])\n end\n end\n\n # normal binary search on sorted\n # if elems[mid_point] > elem\n # result = find_element(elem, elems[0..elems.size/2-1])\n # else\n # result = find_element(elem, elems[elems.size/2..elems.size-1])\n # end\n puts \"\"\n\n result\nend",
"def bsearch(arr, target)\n if arr.length < 1 # empty array, returns nil\n return nil\n end\n \n # multiple elements, grab middle and compare\n middle_index = arr.length / 2\n middle_element = arr[middle_index]\n case target <=> middle_element\n when -1 # target smaller, check left half\n new_arr = arr[0...middle_index]\n bsearch(new_arr, target)\n when 1\n new_arr = arr[middle_index+1..-1]\n answer = bsearch(new_arr, target)\n return nil if answer.nil?\n answer + middle_index + 1\n when 0\n return middle_index\n end\nend",
"def binary_search(binary, size, search_key, low, middle, high)\n while (low <= high)\n middle=(low+high)/2;\n print_row(binary, size, low, middle, high);\n if (search_key == binary[middle])\n return middle;\n elsif (search_key <= binary[middle])\n high=middle-1\n else \n low=middle+1\n end\n end\nend",
"def binary_search(array, target)\n return nil if array.count == 0\n\n median = array.length / 2\n left = array[0...median]\n right = array[median + 1..-1]\n\n return median if array[median] == target\n if target < array[median]\n return binary_search(left, target)\n else\n sub_answer = binary_search(right, target)\n (sub_answer.nil?) ? nil : (sub_anser + median + 1)\n end\n\nend",
"def binary_search(array, target)\n return nil if array.empty?\n\n middle_idx = array.length/2\n\n case target <=> array[middle_idx]\n\n when -1\n binary_search(array.take(middle_idx), target)\n when 0\n return middle_idx\n when 1\n binary_search(array[middle_idx..-1], target)\n end\n\nend",
"def binary_search(arr, target, idx_puls = 0)\n mid = arr.length / 2\n return mid + idx_puls if arr[mid] == target\n return nil if arr.length == 1\n\n if arr[mid] < target\n binary_search(arr[(mid + 1)..-1], target, mid + 1)\n else\n binary_search(arr[0...mid], target, idx_puls)\n end\n\nend",
"def binary_search(array, length, value_to_find)\n puts \"NOT IMPLEMENTED\"\nend",
"def bsearch(arr, target)\n return -1 if arr.empty?\n left = 0\n right = arr.length - 1\n bsearch_helper(arr, target, left, right)\nend",
"def bsearch(array, target)\n\n return nil unless array.include?(target)\n\n middle = (array.length - 1) / 2\n return middle if target == array[middle]\n\n if target < array[middle]\n bsearch(array[0...middle], target)\n elsif target > array[middle]\n middle + 1 + bsearch(array[(middle + 1)..-1], target)\n end\nend",
"def binary_search(array, target)\n temp = array.sort\n middle = temp.length / 2\n first = 0\n last = temp.length - 1\n while first < last\n if temp[middle] == target\n return middle\n elsif temp[middle] < target\n first = middle + 1\n middle = (first + last) / 2\n else\n last = middle - 1\n middle = (first + last) / 2\n end\n end\n return -1\nend",
"def binary_search(array, key, low=0, high=array.size-1) \n return -1 if low > high \n mid = (low + high) / 2 \n return mid if array[mid]==key \n if array[mid] > key \n high = mid - 1 \n else \n low = mid + 1 \n end \n binary_search(array, key, low, high) \nend",
"def bsearch(arr, target)\n return nil if arr.length < 1\n\n middle_idx = arr.length / 2\n return_idx = 0\n\n return middle_idx if arr[middle_idx] == target\n\n if target < arr[middle_idx]\n index = bsearch(arr[0...middle_idx], target)\n index.nil? ? (return nil) : return_idx += index\n else\n index = bsearch(arr[middle_idx + 1..-1], target)\n index.nil? ? (return nil) : (return_idx = (middle_idx + index + 1))\n end\n\n return_idx\nend",
"def fast\n ARRAY.bsearch { |num| num > 80_000_000 }\nend",
"def bsearch(array, target)\n return nil if array.length == 1 && array.first != target\n return 0 if array.length == 1\n\n guess = array.length / 2\n left = array.take(guess)\n right = array.drop(guess)\n\n if target < array[guess]\n bsearch(left, target)\n else\n right_search = bsearch(right, target)\n right_search.nil? ? nil : guess + right_search\n end\nend",
"def binary_search(name)\n # We save the position of the first item in the array\n # using the 'lower' variable, and the position of the\n # last item in the array in the 'upper' variable.\n lower = 0\n upper = entries.length - 1\n\n # Here we loop over the array while 'lower' is less \n # than or equal to the 'upper' variable.\n while lower <= upper\n # We set the varible 'mid' to be the index in the\n # middle of the array. Ruby automatically truncates\n # any decimal numbers. ie: 2.5 becomes 2 .\n mid = (lower + upper) / 2\n # We then set the 'mid_name' variable to the name\n # attribute of the entry in the middle of the array.\n mid_name = entries[mid].name\n # Next, we see if the 'mid_name' variable is the same\n # as the 'name' variable we passed in. If it is the\n # same we return the entry.\n if name == mid_name\n return entries[mid]\n # If it isn't the same we then check if 'name' is less\n # than 'mid_name' (Ruby automatically uses lexicographial\n # order). If so we set 'upper' to be one index less than\n # the 'mid' index.\n elsif name < mid_name\n upper = mid - 1\n # If 'name' isn't less than 'mid_name', we check if it is \n # greater than 'mid_name' (I believe we could just use an\n # else statement here). If so we set 'lower' to be one index\n # higher than 'mid'.\n elsif name > mid_name\n lower = mid + 1\n end\n end\n # If we divide and conquer to the point where no match is found\n # we then return nil.\n return nil\n\n end",
"def bsearch(sorted_array, target)\n return nil if sorted_array.empty?\n \n i_mid = (sorted_array.length-1) / 2\n mid = sorted_array[i_mid]\n \n if target == mid\n i = i_mid\n elsif target < mid\n i = bsearch(sorted_array[0...i_mid], target)\n else\n i = bsearch(sorted_array[i_mid + 1..-1], target)\n i += mid + 1 if i\n end\n \n i\nend",
"def bsearch(array, target)\n middle_idx = array.length / 2\n middle = array[middle_idx]\n\n return middle_idx if target == middle\n return nil if array.length == 1\n if target < middle\n return bsearch(array[0...middle_idx], target)\n elsif target > middle\n b_searched = bsearch(array[middle_idx..-1], target)\n if b_searched == nil\n return nil\n else\n return middle_idx + b_searched\n end\n end\nend",
"def binary_search(array, length, value_to_find)\n raise NotImplementedError\nend",
"def bsearch(arr, target)\r\n return false if arr.length == 0\r\n\r\n mid = arr.length/2\r\n\r\n return mid if arr[mid] == target\r\n if arr[mid] > target\r\n found = bsearch(arr[mid+1..-1], target)\r\n found + mid + 1 unless found == false\r\n else\r\n bsearch(arr[0...mid], target)\r\n end\r\n false\r\nend",
"def binary_search(binaryMatrix,start,last,n,row)\n\tif start > last\n\t\treturn -1\n\tend\n\tmid = start + (last-start)/2\n\tif binaryMatrix.get(row,mid) == 1\n\t\tif binaryMatrix.get(row,mid-1) == 0 || mid == 0\n\t\t\treturn mid\n\t\telse\n\t\t\tbinary_search(binaryMatrix,start,mid-1,n,row)\n\t\tend\t\n\telsif binaryMatrix.get(row,mid) == 0\n\t\tbinary_search(binaryMatrix,mid+1,last,n,row)\n\tend\nend",
"def binary_search(array, value)\n return nil if array.length == 1 && array[0] != value\n midpoint = array.length/2\n return midpoint if array[midpoint] == value\n if array[midpoint] < value\n midpoint + binary_search(array[midpoint..array.length], value) if binary_search(array[midpoint..array.length], value)\n else\n binary_search(array[0...midpoint], value)\n end\nend",
"def binary_search(key,array)\n\tlow = 0\n\thigh = array.sort.length - 1\n\treturn -1 if low>high\n\tmid = (low+high)/2\n\treturn mid if array[mid]==key\n\t\tif array[mid]>key\n\t\t\thigh=mid-1\n\t\t\tmid=(low+high)/2\n\t\telse\n\t\t\tlow=mid+1\n\t\t\tmid=(low+high)/2\n\t\tend\nend",
"def bsearch(arr, target)\n return nil if arr.empty?\n mid_idx = arr.length / 2\n pivot = arr[mid_idx]\n return mid_idx if pivot == target\n if pivot > target\n bsearch(arr[0...mid_idx], target)\n else\n result = bsearch(arr[mid_idx + 1..-1], target)\n if result == nil\n nil\n else\n mid_idx + 1 + result\n end\n end\nend",
"def binary_search(arry, target)\n return \"Empty Array\" if arry.size < 1\n lower_limit = 0\n upper_limit = arry.size - 1\n search_string = binary_search_with_limits(arry, target, lower_limit, upper_limit)\nend",
"def binary_search_rec(a, key, low, high)\n# At every step, consider the array between low and high indices\n# When low is greater than high, the key doesn’t exist and -1 is returned.\n if low > high\n return -1\n end\n\n\n# Calculate the mid index.\n mid = low + ((high - low) / 2)\n\n# If the element at the mid index is the key, return mid.\n if a[mid] == key\n return mid\n\n# If the element at mid is greater than the key, then change the index high to mid - 1.\n# The index at low remains the same.\n elsif key < a[mid]\n return binary_search_rec(a, key, low, mid - 1)\n else\n# If the element at mid is less than the key, then change low to mid + 1. The index at high remains the same.\n return binary_search_rec(a, key, mid + 1, high)\n end\nend",
"def search(a,val)\n\tpivot = find_pivot(a,0,a.size-1)\n\tif pivot == -1\n\t\treturn -1\n\telsif a[pivot] == val\n\t\treturn pivot\n\tend\n\tif a[0] <= val\n\t\treturn binary(a,0,pivot-1,val)\n\telse\n\t\treturn binary(a,pivot+1,a.size-1,val)\n\tend\nend",
"def binary_search(name)\n # we save the index of the left most item in the array in a var named lower.\n # and the index of the rightmost item in the array in upper.\n lower = 0\n upper = entries.length - 1\n\n # we loop while our lower index is less than or equal to the upper index.\n while lower <= upper\n # we find the middle index by taking the sum of lower and upper and dividing it by two.\n # then we retrieve the name of the entry at the middle index and store it in mid_name.\n mid = (lower + upper) / 2\n mid_name = entries[mid].name\n\n # we compare the name that we are search for, name to the name of the middle index, mid_name.\n # note - search is case sensitive.\n if name == mid_name\n return entries[mid]\n elsif name < mid_name\n upper = mid - 1\n elsif name > mid_name\n lower = mid + 1\n end\n end\n\n #if we divide and conquer to the point where there is no match, we return nil.\n return nil\n end",
"def bsearch(array, target)\n return nil if array.empty?\n\n n = array.size / 2\n bottom = array[0...n]\n mid = array[n]\n top = array[n + 1..-1]\n\n if target < mid\n bsearch(bottom, target)\n elsif target > mid\n top_search = bsearch(top, target)\n top_search.nil? ? nil : top_search + bottom.size + 1\n else\n mid == target ? n : nil\n end\nend",
"def binary_search(array, value, from=0, to=nil)\n to = array.count - 1 unless to\n mid = (from + to) / 2\n \n if value < array[mid]\n return binary_search(array, value, from, mid - 1)\n elsif value > array[mid]\n return binary_search(array, value, mid + 1, to)\n else\n return mid\n end\nend",
"def bin_search(d, arr)\n middle = arr.length / 2\n i = 0\n j = arr.length - 1\n \n while i < j\n if arr[middle] == d\n return true\n elsif arr[middle] < d\n i = middle + 1\n middle = i + j / 2\n else\n j = middle - 1\n middle = i + j / 2\n end\n end\n return false\nend",
"def binary_search(name)\n # Save the index of the leftmost item in the array in a variable named lower and the index of\n # the righmost in the variable upper\n lower = 0\n upper = entries.length - 1\n\n # We loop while our lower index is less than or equal to our upper index\n while lower <= upper\n # We find the middle index then retrieve the name and store it in the variable mid_name\n mid = (lower + upper) / 2\n mid_name = entries[mid].name\n\n # Compare the name we are searching for with mid_name and iterate until we find the correct name\n if name == mid_name\n return entries[mid]\n elsif name < mid_name\n upper = mid -1\n elsif name > mid_name\n lower = mid + 1\n end\n end\n \n # If no match is found we return nil\n return nil\n end",
"def binary_search(arr, element)\n low = 0\n high = arr.length - 1\n\n while low <= high\n mid = (low + high) / 2\n guess = arr[mid]\n\n if guess > element\n high = mid - 1\n elsif guess < element\n low = mid + 1\n else\n return mid\n end\n end\n\n nil\nend",
"def binary_search(arr, item)\n #assign parts of the array by beginning and end\n\n #Envoy of the beginning\n left = 0\n #Envoy of the End\n right = arr.length - 1\n\n # while the item is not found\n # (since you are converging from the changing range, high to low)\n while left <= right\n #set a mid point to be used in the middle of any range created by high & low\n mid = (left + right) / 2\n\n if arr[mid] == item\n return mid\n end\n\n if arr[mid] > item\n right = mid - 1\n else\n left = mid + 1\n end\n end\n\n return nil\n\nend",
"def binarySearch(a, value)\n # Precondition: lst must be sorted asc (smaller first).\n\n # Searching boundaries (all vector)\n p = 0 # left limit (inclusive)\n r = a.length - 1 # right limit (inclusive)\n\n # Optimization\n # Asses that value may actually be in the array: Array range is a[0]..a[-1]\n # Array must be not empty\n if r < 0 or value < a[p] or value > a[r] then\n return nil # nil inplace of -1 to match ruby std\n end\n\n while p <= r do\n q = (p+r)/2\n if a[q] == value\n return q\n end\n if a[q] > value\n # then value is in a[p]...a[q]\n r = q-1\n else\n # then value is in a[q]...a[r]\n p = q+1\n end\n end\n\n return nil # nil inplace of -1 to match ruby std\nend",
"def binary_search(students, ssn)\n students.sort #must sort for binary search\n students.index(students.bsearch {|student| ssn <=> student.ssn}) || -1\nend",
"def b_search(arr, target)\n return false if arr.empty?\n mid = arr / 2\n if arr[mid] == target\n true\n elsif arr[mid] < target\n b_search(arr[mid..-1], target)\n else\n b_search(arr[0...mid], target)\n end\nend",
"def binary_search(arr, ele)\n min = 0;\n max = arr.size - 1;\n\n while min <= max \n \n middle = ( (min + max) / 2).floor\n \n if ele == arr[middle]\n return middle\n elsif ele < arr[middle]\n max = middle - 1\n elsif ele > arr[middle]\n min = middle + 1\n end\n\n end\n\n return -1 \nend",
"def bsearch(arr, target)\n return nil if arr.length <= 1\n\n mid = arr.length / 2\n case target <=> arr[mid]\n when -1\n bsearch(arr[0..mid], target)\n when 0\n mid\n when 1\n bsearch(arr[mid..-1], target)\n end\nend",
"def binary_search(target, collection, min_index = 0, max_index = collection.size - 1)\n return nil if collection.empty?\n loop do\n return nil if max_index < min_index\n index_to_check = mid_point(min_index, max_index)\n return index_to_check if collection[index_to_check] == target\n min_index = index_to_check + 1 if collection[index_to_check] < target\n max_index = index_to_check - 1 if collection[index_to_check] > target\n end\nend",
"def binary_search(array, key, start_position)\n left = start_position\n right = array.size - 1\n\n while left < right\n mid = (left + right) / 2\n\n if array[mid] < key\n left = mid + 1\n else\n right = mid\n end\n end\n\n (left == right && array[left] == key) ? left : -1\nend",
"def binary_search(opts={})\n # I have a lot of stuff to do for scouts\n # but instead i'm doing this\n # hizzah!\n count = 0\n \n until opts[:find].empty?\n new_search = []\n count += 1\n \n zipped = opts[:find].zip opts[:repo].between(opts[:find])\n zipped.each do |(n, list)|\n list << n[1]\n p = n[0]\n f = 1 # ??? why are these vars so NAMELESS\n \n list.each do |item|\n UI::debug \"narrowing #{f}:#{list.size} #{short item}\"\n \n if opts[:node_map].include? item\n if f <= 2\n opts[:on_find].call(p, item)\n else\n UI::debug \"narrowed branch search to #{short p}:#{short item}\"\n new_search << [p, item]\n end\n break\n end\n \n p, f = item, f*2\n end\n end\n \n opts[:find] = new_search\n end\n \n [opts[:find], count]\n end",
"def bsearch(arr, target)\n return nil if arr.length == 0\n mid = arr.length/2\n\n if target < mid\n bsearch(arr.take(mid), target)\n elsif target == arr[mid]\n return true\n else\n search_res = bsearch(arr.drop(mid + 1), target)\n search_res.nil? ? false : true\n end\nend",
"def binary_search(arr, target)\n\n floor = -1\n ceiling = arr.length\n\n while floor + 1 < ceiling # Has to be plus one or else it will keep looping. NB: Guess index always rounds down.\n\n guess_index = (floor + ceiling)/2\n # puts \"Guess_index\", guess_index\n guess_value = arr[guess_index]\n\n if guess_value == target\n return true\n elsif guess_value < target\n floor = guess_index\n else\n ceiling = guess_index\n end\n\n end\n\n return false\n\nend",
"def binary_search(array, value)\n \n # First, we establish the lower and upper bounds of where the value we are\n # searching for can be. At the beginning, the lower bound is the first value\n # of the array and the upper bound is the last value of the array.\n lower_bound = 0\n upper_bound = array.length - 1\n\n # Now we start searching for the value inside the array between the lower and upper bounds.\n # In each iteration of the loop, we check the middle value between the lower and upper bounds\n # against the value we are searching for. If the middle value matches the value we are searching\n # for then we stop, otherwise we update the lower and upper bounds of our search accordingly(Should\n # we search to the right or the left of the mid point in the next iteration to find the value we are\n # looking for).\n #\n # If the value at the mid point matches with the value we are looking for, we are done and we return\n # the mid point(index of the value we are looking for).\n #\n # If the value is lower than the value at the mid point, we should to search to the left side of the mid point\n # in the next iteration. So we set the upper bound to the left of mid point.\n #\n # If the value is higher than the value at the mid point, we should to search to the right side of the mid point\n # in the next iteration. So we set the lower bound to the right of mid point.\n\n while lower_bound <= upper_bound\n\n # Find the mid point between the upper and lower bounds\n mid_point = (lower_bound + upper_bound) / 2\n\n # Look up the value at the mid point\n value_at_mid_point = array[mid_point]\n\n # Check the value at the mid point against the value we are looking for:\n\n if value == value_at_mid_point\n return mid_point\n elsif value < value_at_mid_point\n upper_bound = mid_point - 1\n elsif value > value_at_mid_point\n lower_bound = mid_point + 1\n end\n end\n\n # If the value is not found, return nil indicating the value we are searching for\n # doesn't exist inside the array.\n return nil\nend",
"def binary_search(array,item,min,max) #We want this to return the array index of item\n midpoint = min + ( (max - min) / 2 )\n return midpoint if array[midpoint] == item\n\n if max - min == 1 || max - min == 0\n if array[midpoint] == item\n return midpoint\n elsif array[midpoint +1] == item\n return midpoint + 1\n else\n return nil\n end\n end\n\n if array[midpoint] > item\n binary_search(array,item,min,midpoint)\n else array[midpoint] < item\n binary_search(array,item,midpoint,max)\n end\n\nend",
"def binary_search(array, target)\n return nil if array.length == 1 && array[0] != target\n mid = array.length / 2\n\n if target == array[mid]\n return mid\n elsif target < array[mid]\n return binary_search(array[0...mid], target)\n else\n found = binary_search(array[mid+1..-1], target)\n return found.nil? ? nil : mid + 1 + found\n end\nend",
"def global_linear_search (object, array)\nputs \"nil\" if array.empty? == true\nputs \"nil\" if array.include?(object) == false\n\t\ni=0\nresults = []\nwhile i < array.length\nresults << i if array[i] == object\ni +=1\nend\nresults\nend",
"def binary_search(array, length, value_to_find)\n mid_point = length/2\n mid = array[mid_point]\n counter = 0\n\n until mid == value_to_find || counter > length\n if mid > value_to_find\n mid_point = mid_point/2\n else \n mid_point = (length - mid_point)/2 + mid_point\n end\n\n mid = array[mid_point]\n counter += 1\n end\n\n mid == value_to_find\nend",
"def binary_search(arr, target)\n binary_search_helper(arr, target, 0, arr.length - 1)\nend",
"def bsearch(array, target)\n return nil if array.empty?\n\n middle_idx = array.length / 2\n if array[middle_idx] == target\n return middle_idx\n elsif array[middle_idx] > target\n bsearch(array[0...middle_idx], target)\n else\n result = bsearch(array[(middle_idx+1)..-1], target)\n if result.is_a?(Fixnum)\n result + middle_idx + 1\n else\n nil\n end\n end\nend",
"def bs(array, target)\n start = 0\n endp = array.length \n \n while start <= endp\n mid = start + (endp - start)/2\n \n if array[mid] == target\n return mid\n end\n\n if array[mid] < target \n start = mid + 1 \n else\n endp = mid - 1\n end\n end\n return 'Not found' \nend",
"def binary_search(target, array)\n length = array.length\n center = length / 2\n first = 0\n last = length - 1\n\n while first <= last\n if array[center] == target\n return array.index(target)\n elsif array[center] < target\n first = center + 1\n center = (first + last) / 2\n else\n last = center - 1\n center = (first + last) / 2\n end\n end\n\n return -1\nend"
] | [
"0.7601672",
"0.7488068",
"0.7453648",
"0.7381466",
"0.7360346",
"0.7343364",
"0.73351985",
"0.7304209",
"0.7291085",
"0.7281542",
"0.7275073",
"0.72715867",
"0.72685564",
"0.7256332",
"0.72517395",
"0.7227592",
"0.7223801",
"0.7218236",
"0.7212643",
"0.7205586",
"0.7197354",
"0.71962094",
"0.7185642",
"0.7183786",
"0.71792734",
"0.71783864",
"0.7168329",
"0.7165684",
"0.71518266",
"0.7149341",
"0.71485156",
"0.71433836",
"0.7141024",
"0.7138643",
"0.7135018",
"0.7125196",
"0.71245086",
"0.7121574",
"0.71092224",
"0.7104174",
"0.7104174",
"0.7094504",
"0.7087783",
"0.70864105",
"0.7080845",
"0.7077545",
"0.7073647",
"0.7071398",
"0.70694506",
"0.70649564",
"0.7064503",
"0.70578176",
"0.7051449",
"0.70504904",
"0.704871",
"0.7047524",
"0.7042981",
"0.7041677",
"0.7040868",
"0.7040308",
"0.7036926",
"0.7031344",
"0.70290416",
"0.7026182",
"0.7021087",
"0.7019616",
"0.7017133",
"0.701493",
"0.70138866",
"0.70137566",
"0.7012215",
"0.70055914",
"0.6998555",
"0.6997987",
"0.6993862",
"0.6991722",
"0.69879556",
"0.6986337",
"0.6979741",
"0.6964207",
"0.696089",
"0.6958722",
"0.6956246",
"0.695318",
"0.6953163",
"0.6950535",
"0.69498533",
"0.69445056",
"0.69427884",
"0.69425774",
"0.6942294",
"0.6939547",
"0.6937129",
"0.69314086",
"0.6929941",
"0.6926114",
"0.6923104",
"0.6914235",
"0.6912962",
"0.6912637",
"0.69123816"
] | 0.0 | -1 |
Return bool indicating if spec file satisfies any file in gem | def has_file_satisfied_by?(spec_file)
file_paths.any? { |gem_file| RPM::Spec.file_satisfies?(spec_file, gem_file) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_file_satisfied_by?(spec_file)\n file_paths.any? { |gem_file| RPM::Spec.file_satisfies?(spec_file, gem_file) }\n end",
"def gemspec?\n !gemspecs.empty?\n end",
"def gem?\n #return true if Dir[File.join(location, '*.gemspec')].first\n pkgname = File.basename(location)\n gemsdir = File.dirname(location)\n specdir = File.join(File.dirname(gemsdir), 'specifications')\n Dir[File.join(specdir, \"#{pkgname}.gemspec\")].first\n end",
"def has_specs?\n FileList[spec_pattern].any?\n end",
"def ok?\n @specs.all? do |spec|\n spec.runtime_dependencies.all? do |dep|\n @specs.find { |s| s.satisfies_requirement? dep }\n end\n end\n end",
"def installed?\n case @spec\n when Gem::Resolver::VendorSpecification then\n true\n else\n this_spec = full_spec\n\n Gem::Specification.any? do |s|\n s == this_spec\n end\n end\n end",
"def ok?\n @specs.all? { |spec|\n\tspec.dependencies.all? { |dep|\n\t @specs.find { |s| s.satisfies_requirement?(dep) }\n\t}\n }\n end",
"def valid_gemspec?\n gemspec_helper.valid?\n end",
"def valid_gemspec?\n gemspec_helper.valid?\n end",
"def valid_gemspec?\n gemspec_helper.valid?\n end",
"def contains_requirable_file? file\n root = full_gem_path\n suffixes = Gem.suffixes\n\n require_paths.any? do |lib|\n base = \"#{root}/#{lib}/#{file}\"\n suffixes.any? { |suf| File.file? \"#{base}#{suf}\" }\n end\n end",
"def installed?\n results = target_files.map {|f| is_my_file?(f) }\n return false if results.include? false\n return true\n end",
"def gem_listed?(gem)\n lockfile_specs.map(&:name).include? gem\n end",
"def gem_path?(file); end",
"def installed?(name, req = Gem::Requirement.default)\n Gem::Specification.any? { |s| s.name =~ name and req =~ s.version }\n end",
"def integrated\n File.exist?(gemfile)\n end",
"def current_spec_is?(spec)\n return false unless file_name_spec_set?\n spec = [spec] unless spec.is_a? Array\n spec = spec.flatten\n spec = spec.map do |spec|\n Noop::Utils.convert_to_spec spec\n end\n spec.any? do |spec|\n file_name_spec == spec\n end\n end",
"def gem_exists?(gem_name)\n begin\n output = `gem specification --local #{gem_name} 2> /dev/null`\n return output =~ /^\\-\\-\\- \\!ruby\\/object\\:Gem\\:\\:Specification/\n rescue\n # we get here if gem exits with an error code\n return false\n end\n end",
"def matches_spec? spec\n name == spec.name and requirement.satisfied_by? spec.version\n end",
"def valid_gemspec?; end",
"def gem_should_be_checked?(gem_name)\n gem_name.index('barkest_') == 0\n end",
"def matches_spec?(spec)\n return false unless name === spec.name\n return true if requirement.none?\n\n requirement.satisfied_by?(spec.version)\n end",
"def valid?\n gemfile? && gemfile_lock? && gem?(\"thin\") &&\n gem?(\"rake\") && config_ru?\n end",
"def contains_requirable_file?(file)\n if @ignored\n return false\n elsif missing_extensions?\n @ignored = true\n\n if Gem::Platform::RUBY == platform || Gem::Platform.local === platform\n warn \"Ignoring #{full_name} because its extensions are not built. \" +\n \"Try: gem pristine #{name} --version #{version}\"\n end\n\n return false\n end\n\n have_file? file, Gem.suffixes\n end",
"def apply?(fname, options={})\n return true if options[:gem]\n return true if options[:from] && (\n ::Gem::Specification.find{ |s| options[:from].to_s == s.name }\n )\n return false\n end",
"def have_gem? name\n Gem::Specification.find_by_name name.to_s\n rescue Gem::LoadError\n false\n end",
"def rspec?\n @rspec ||= @gems.include?(:rspec)\n end",
"def complete?\n specs.find {|s| !s.complete?} ? false : true\n end",
"def matches_spec?(spec)\n @dependency.matches_spec? spec\n end",
"def has_spec_tests?(cookbook_path)\n File.directory?(File.join(cookbook_path, 'spec'))\n end",
"def satisfied_by?(spec)\n return false unless requirement\n spec = ArtifactNamespace.to_hash(spec)\n hash = to_spec_hash\n hash.delete(:version)\n version = spec.delete(:version)\n hash == spec && requirement.satisfied_by?(version)\n end",
"def bundled?\n Gem.loaded_specs.key?(self.class.from_gem)\n end",
"def gemspec?; end",
"def missing_gem_file?(gem_file)\n files.none? { |spec_file| self.class.file_satisfies?(spec_file, gem_file) }\n end",
"def relevant_file?(file)\n file.end_with?('_spec.rb')\n end",
"def gemfile_exists? \n File.exists? \"Gemfile\"\nend",
"def gemfile_exists? \n File.exists? \"Gemfile\"\nend",
"def gem_installed?(gem_name)\n found_gem = false\n begin\n found_gem = Gem::Specification.find_by_name(gem_name)\n rescue Gem::LoadError\n return false \n else\n return true \n end\nend",
"def gem_installed?(gem_name)\n list = `gem list #{gem_name}`\n list.split(\"\\n\").any? { |line| line.include?(gem_name) }\nend",
"def check_file(fn)\n File.foreach(fn) do |line|\n return $1 if line =~ /^\\s*require_relative\\s*['\"](.*spec_helper)['\"]/\n end\n nil\nend",
"def missing_extensions?\n return false if extensions.empty?\n return false if default_gem?\n return false if File.exist? gem_build_complete_path\n\n true\n end",
"def gem_available?(name)\n Gem::Specification.find_by_name(name)\nrescue Gem::LoadError\n false\nend",
"def activated?\n loaded = Gem.loaded_specs[name]\n loaded && loaded.version == version\n end",
"def bundler_installed?\n\t`(gem spec bundler -v > /dev/null 2>&1)`\n end",
"def bundler_installed?\n\t`(gem spec bundler -v > /dev/null 2>&1)`\n end",
"def bundler_installed?\n\t`(gem spec bundler -v > /dev/null 2>&1)`\n end",
"def installable_platform?\n Gem::Platform.match_spec? spec\n end",
"def gem_installed?(gem_name)\n !Gem::Specification.find_by_name(gem_name).nil?\n rescue Gem::LoadError\n false\n end",
"def matching_file(spec, path) # :doc:\n glob = \"#{@lib_dirs[spec.object_id]}/#{path}#{SUFFIX_PATTERN}\"\n return true unless Dir[glob].select { |f| File.file?(f) }.empty?\n end",
"def has_all_requirements_for?(gem_dep)\n reqs = self.requirements_for_gem gem_dep.name\n # create a spec requirement dependency for each expanded subrequirement,\n # verify we can find a match for that\n gem_dep.requirement.to_s.split(',').all? { |greq|\n Gem2Rpm::Helpers.expand_requirement([greq.split]).all? { |ereq|\n tereq = Requirement.new :name => \"#{requirement_prefix}(#{gem_dep.name})\",\n :condition => ereq.first,\n :version => ereq.last.to_s\n reqs.any? { |req| req.matches?(tereq)}\n }\n }\n end",
"def meets_requirements?\n if dirname = Micro.installed_gem_dirnames(name).last\n Gem::Version.from_gem_dirname(dirname) >= @version_requirements.version\n end\n end",
"def match?(spec, allow_prerelease = false)\n @dependency.match? spec, nil, allow_prerelease\n end",
"def gem?\n @gem\n end",
"def conficts_when_loaded_with?(list_of_specs) # :nodoc:\n result = list_of_specs.any? do |spec|\n spec.dependencies.any? {|dep| dep.runtime? && (dep.name == name) && !satisfies_requirement?(dep) }\n end\n result\n end",
"def has_conflicts?\n return true unless Gem.env_requirement(name).satisfied_by?(version)\n self.dependencies.any? do |dep|\n if dep.runtime?\n spec = Gem.loaded_specs[dep.name]\n spec and not spec.satisfies_requirement? dep\n else\n false\n end\n end\n end",
"def spec_stubs?\n @config.files.copy.any? { |f, _| f.start_with?(STUBS_FOLDER) } \\\n || @config.files.compile.any? { |f, _| f.start_with?(STUBS_FOLDER) }\n end",
"def has_tests?\n FileList[test_pattern].any?\n end",
"def requirement_satisfied_by?(requirement, activated, spec)\n version = spec.version\n return false unless requirement.requirement.satisfied_by?(version)\n return false unless valid_possibility_version_for_root_name?(requirement, activated, spec)\n return false unless spec_is_platform_compatible?(activated, requirement, spec)\n true\n end",
"def for_spec?(spec)\n @dependency.name == spec.name\n end",
"def for_spec?(spec)\n @dependency.name == spec.name\n end",
"def gem_dep_matches?(what, version, *deps)\n # always match if we have no chef_version at all\n return true unless deps.length > 0\n\n # match if we match any of the chef_version lines\n deps.any? { |dep| dep.match?(what, version) }\n end",
"def would_require? path\n require_paths.each do |rp|\n return true if File.exist?(File.join(rp, \"#{path}.rb\"))\n end\n false\n end",
"def validate_gemspec; end",
"def gem_available?(name)\n Gem::Specification.find_by_name(name)\nrescue Gem::LoadError\n false\nrescue\n Gem.available?(name) #for backwards compatibility\nend",
"def determinate_with?(new_spec)\n if !new_spec.complete? && new_spec.glob?\n specs.reverse.each do |spec|\n return true if spec.complete?\n return false if spec.glob?\n end\n end\n true\n end",
"def installed?(gem_name)\n !run('list', '|', 'grep', \"' #{gem_name} '\").empty?\n end",
"def check_gem(gem, gem_path)\n result = `#{gem_path} query --local | grep #{ gem }`\n if result == \"\"\n installed = false\n else\n installed = true\n end #if\n \n installed\n end",
"def was_required?(file)\n rex = Regexp.new(\"/#{Regexp.quote(file)}\\.(so|o|sl|rb)?\")\n $LOADED_FEATURES.find { |f| f =~ rex }\nend",
"def has_gem?(str)\n name, version = parse_gem_line(str)\n begin\n gem(name, version || '>=0')\n true\n rescue Gem::LoadError\n false\n end\n end",
"def valid?\n gemfile? && gemfile_lock? && gem?(\"rake\") &&\n (gem?(\"thin\") || gem?(\"puma\")) && config_ru? &&\n rakefile? && task?(\"db:migrate\") && task?(\"db:setup\")\n end",
"def dep_check\n $gems_required.each do |current_gem|\n begin\n if current_gem.include? \",\"\n tokens = current_gem.split(\",\")\n gem tokens[0], tokens[1]\n else\n gem current_gem\n end\n rescue Gem::LoadError\n if current_gem.include? \",\"\n $gems_missing_version << current_gem\n else\n $gems_missing << current_gem\n end\n end\n end\n if $gems_missing.length == 0 && $gems_missing_version.length == 0\n return true\n else\n return false\n end\nend",
"def exists?\n Dir.glob(@resource.value(:name) +\"*.rpm\").empty?\n end",
"def all_files_included?\n file_paths = files.map { |f| File.join(package_path, f[:path]) }\n \n package_files = if defined? package_id\n Dir.glob(File.join(package_path, package_id, \"**\", \"*\"))\n else\n Dir.glob(File.join(package_path, 'files', '**', '*'))\n end\n package_files = package_files.select { |f| File.file? f }\n\n package_files.each do |p|\n errors.add :coverage, \"#{p} is in the package but is not covered by the\" +\n \" representation(s)\" unless file_paths.include?(p) \n end\n \n return errors.on(:coverage).nil?\n\n end",
"def spec_included?(spec)\n filter_is_matched? options[:filter_specs], spec\n end",
"def test_file?(path)\n @tests_files.include?(path)\n end",
"def installed?\n File.exists?(@path)\n end",
"def focused_spec_exists?\n `grep -r 'focus: true' spec/`.length > 1\nend",
"def install_required?\n return true unless File.exist?(@install_flag)\n\n # The file exists, so open it and read the timestamp values.\n # If they match, return false. Otherwise return true.\n File.open(@install_flag, 'rb') do |f|\n ft1, ft2 = f.read(8).unpack('L*')\n return !(ft1 == @t1 && ft2 == @t2)\n end\n end",
"def files_match?\n @fixture.files == @local.files\n end",
"def gem_only_available?()\n return !determine_common_folder() && is_dtk_common_core_gem_installed?\nend",
"def gem_if_necessary(gem)\n grep = args = nil\n if gem =~ /(.*)-(\\d+\\.\\d+\\.\\d+)$/\n gem, version = $1, $2\n grep = \"^#{gem}.*#{version}\"\n args = \" --version #{version}\"\n else\n grep = \"^#{gem}\"\n end\n if fails?(\"gem list #{gem} | grep '#{grep}'\")\n banner \"#{gem}...\"\n run \"gem install #{gem} #{args} --no-rdoc --no-ri\"\n return true\n end\n false\n end",
"def has_unit_tests? # :nodoc:\n not test_files.empty?\n end",
"def contents_detected?\n true if find_first_match(:matching => /Gitlab/, :in_file => \"Rakefile\")\n end",
"def gemspecs\n return [] if directory.empty? || directory == '*'\n @gemspecs ||= Dir[File.join(directory, '**/*.gemspec')].select do |gs|\n config.allow? gs\n end\n end",
"def inferred?\n p = abs_path\n p && p.all? { | x | File.exist? x }\n end",
"def completed?\n child_files = self.bundled_files\n child_file_types = child_files.map {|file| file['file_type']}\n if child_file_types.size < BUNDLE_REQUIREMENTS[self.bundle_type].size || ( (child_file_types.size == BUNDLE_REQUIREMENTS[self.bundle_type].size) &&\n (child_file_types & BUNDLE_REQUIREMENTS[self.bundle_type] != child_file_types))\n return false\n end\n if child_file_types.size > BUNDLE_REQUIREMENTS[self.bundle_type].size\n return false\n end\n # make sure all files have at least uploaded to the server\n self.study_files.each do |study_file|\n if !study_file.uploaded?\n return false\n end\n end\n true\n end",
"def need_inspec_core_bin?(gem_version)\n return true if gem_version.nil? # latest version\n Gem::Requirement.new('>= 4').satisfied_by?(Gem::Version.new(gem_version))\n end",
"def bundled?(filename); end",
"def rspec?\n $PROGRAM_NAME.end_with?(RSPEC_PROGRAM_NAME)\n end",
"def requirement_satisfied_by?(requirement, activated, spec)\n true\n end",
"def installed?\n File.exist?(swiftlint_path)\n end",
"def validate_gemspec\n Juwelier::Commands::ValidateGemspec.build_for(self).run\n end",
"def check_spec_files_exists(spec, accessor, platform_name, options = {})\n result = []\n patterns = spec.send(accessor)[platform_name]\n patterns.map do |pattern|\n pattern = Pathname.pwd + pattern\n if pattern.directory? && options[:glob]\n pattern += options[:glob]\n end\n result << \"#{platform_name}: [#{accessor} = '#{pattern}'] -> did not match any file\" if pattern.glob.empty?\n end\n result\n end",
"def external_frame?(f)\n !!(f =~ %r{bundle/gems})\n end",
"def validate_gemspec\n Jeweler::Commands::ValidateGemspec.build_for(self).run\n end",
"def version_specified_gem?(node); end",
"def try_gem_path file\n @gem_paths.each do |gem_path|\n if file.start_with? gem_path and not gem_path.empty?\n file.sub! File.join(gem_path, 'gems'), ''\n file.sub! %r{/[^/]*/}, ''\n return true\n end\n end\n return false\n end",
"def installed_gemspec(path)\n #return true if Dir[File.join(path, '*.gemspec')].first\n pkgname = ::File.basename(path)\n gemsdir = ::File.dirname(path)\n specdir = ::File.join(File.dirname(gemsdir), 'specifications')\n gemspec = ::File.join(specdir, \"#{pkgname}.gemspec\")\n ::File.exist?(gemspec) ? gemspec : nil\n end",
"def gem_available?(gemname)\n\t# gem_available_new_rubygems?(gemname) or gem_available_old_rubygems?(gemname)\n\tif defined?(Gem::Specification) and defined?(Gem::Specification.find_by_name)\n\t\tgem_available_new_rubygems?(gemname)\n\telse\n\t\tgem_available_old_rubygems?(gemname)\n\tend\nend",
"def loaded?( gem_name )\n \n gem_require_name = gem_name.to_s.gsub( '/', '-' )\n \n return @loaded_gems.has_key?( gem_require_name.to_sym )\n \n end"
] | [
"0.79255515",
"0.77250177",
"0.7615491",
"0.7449048",
"0.7422652",
"0.73918724",
"0.73804665",
"0.73491824",
"0.73491824",
"0.73491824",
"0.7323001",
"0.7234387",
"0.71082455",
"0.70332307",
"0.69598573",
"0.69517666",
"0.6900563",
"0.68946946",
"0.68860674",
"0.68841285",
"0.6873977",
"0.68700075",
"0.68673384",
"0.6862408",
"0.68570554",
"0.6805829",
"0.6797818",
"0.67920035",
"0.67242724",
"0.668454",
"0.6679279",
"0.66569585",
"0.66329515",
"0.66308874",
"0.66292846",
"0.6623212",
"0.6623212",
"0.66128165",
"0.6610204",
"0.66049993",
"0.6578746",
"0.65777683",
"0.655386",
"0.65490514",
"0.65490514",
"0.65490514",
"0.65226245",
"0.6514635",
"0.65128505",
"0.650072",
"0.64705646",
"0.6436719",
"0.6433866",
"0.642201",
"0.64125115",
"0.6395359",
"0.63834804",
"0.63775754",
"0.63741535",
"0.63741535",
"0.63476014",
"0.6332821",
"0.6329817",
"0.63155437",
"0.631155",
"0.63102597",
"0.6305025",
"0.6290453",
"0.62762403",
"0.62579787",
"0.6238224",
"0.6234352",
"0.62250155",
"0.61977386",
"0.6165147",
"0.61494243",
"0.61448574",
"0.6134179",
"0.6130517",
"0.61240816",
"0.61185074",
"0.6085766",
"0.6079944",
"0.60783273",
"0.6073412",
"0.6073284",
"0.6072753",
"0.60722935",
"0.6065942",
"0.6061946",
"0.6054041",
"0.60501456",
"0.6046411",
"0.60447294",
"0.6039481",
"0.60389966",
"0.60346746",
"0.6034153",
"0.60336286",
"0.6007558"
] | 0.78640854 | 1 |
Download the local gem and return it as a string | def download_gem
self.class.download_gem @name, @version
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_gem\n self.class.download_gem @name, @version\n end",
"def gem_path\n @path || downloaded_gem_path\n end",
"def package_url\n \"https://github.com/arduino/arduino-cli/releases/download/#{@desired_version}/#{package_file}\"\n end",
"def downloaded_gem_path\n self.class.downloaded_gem_path @name, @version\n end",
"def fetch_gem(name, version)\n http_get(host + \"/gems/#{name}-#{version}.gem\").body\n end",
"def gem_path\n @path || downloaded_gem_path\n end",
"def download_gem(name, version)\n cached = GemCache.get(name, version)\n return cached unless cached.nil?\n\n client.url = \"https://rubygems.org/gems/#{name}-#{version}.gem\"\n client.follow_location = true\n client.http_get\n gemf = client.body_str\n\n GemCache.set(name, version, gemf)\n gemf\n end",
"def downloaded_gem_path\n self.class.downloaded_gem_path @name, @version\n end",
"def download(path)\n Gem.ensure_gem_subdirectories path\n\n if @spec.respond_to? :sources\n exception = nil\n path = @spec.sources.find do |source|\n begin\n source.download full_spec, path\n rescue exception\n end\n end\n return path if path\n raise exception if exception\n\n elsif @spec.respond_to? :source\n source = @spec.source\n source.download full_spec, path\n\n else\n source = Gem.sources.first\n source.download full_spec, path\n end\n end",
"def downloaded_gem_path(name, version)\n # ensure gem is downloaded\n download_gem name, version\n GemCache.path_for(name, version)\n end",
"def download_prog(repo_hash)\n if (repo_hash[:source] == \"github\")\n clone_repo(repo_hash)\n elsif (repo_hash[:source] == \"rubygems\")\n puts \"Unpacking gem #{repo_hash[:name]}...\"\n system \"gem unpack #{repo_hash[:name]} --version #{repo_hash[:version]}\"\n else\n raise \"Unexpected source of repo #{repo_hash[:name]}: #{repo_hash[:source]}\"\n end\nend",
"def download_and_extract_package\n @fetcher.get_package_file(@package_name, @version)\n Gem::Package::TarReader.new( Zlib::GzipReader.open @fetcher.temp_package_file_path ) do |tar|\n tar.each do |entry|\n next unless entry.file? and entry.full_name.match(\"DESCRIPTION\")\n @package_desc = entry.read\n end\n end\n FileUtils.rm_rf @fetcher.temp_package_file_path\n end",
"def download name\n @checked += 1\n gem_name = \"#{name}.gem\"\n\n if gem_exists? gem_name then\n @gem_queue.push name\n\n info \"#{gem_name} exists\"\n\n return\n end\n\n uri = @base_uri + \"#{name}.gem\"\n\n source_etag = nil\n dest_etag = nil\n\n @http.request uri do |source_res|\n break unless etag = source_res['ETag']\n source_etag = etag.delete '\"'\n\n dest_etag = @swift.write_object @gems_container, gem_name do |io|\n source_res.read_body do |chunk|\n io.write chunk\n end\n end\n end\n\n if dest_etag == source_etag then\n @gem_queue.push name\n\n info \"#{gem_name} downloaded\"\n\n @downloaded += 1\n else\n @gem_name_queue.push name\n @swift.delete_object @gems_container, gem_name\n\n info \"#{gem_name} download failed\"\n @failed += 1\n end\n end",
"def download_package\n path = download_path\n remote_file path do\n source URL\n action :create\n only_if { !::File.exist?(PATH) }\n end\n end",
"def download(spec, dir=Dir.pwd)\n fetcher = Gem::RemoteFetcher.fetcher\n fetcher.download spec, uri.to_s, dir\n end",
"def try_local(gem_name)\n if ENV['USE_LOCAL_GEMS']\n gem gem_name, path: \"../#{gem_name}\"\n else\n gem gem_name, github: \"omniscrapper/#{gem_name}\"\n end\nend",
"def retrieve_latest(name)\n client.url = \"https://rubygems.org/api/v1/gems/#{name}.json\"\n client.http_get\n spec = client.body_str\n gem = parse spec\n gem\n end",
"def load_library\n\t\t#wget some url\n\tend",
"def file_from_repo(github_user, repo, sha, filename, to = filename)\n download(\"http://github.com/#{github_user}/#{repo}/raw/#{sha}/#{filename}\", to)\nend",
"def file_from_repo(github_user, repo, sha, filename, to = filename)\n download(\"http://github.com/#{github_user}/#{repo}/raw/#{sha}/#{filename}\", to)\nend",
"def download\n # Turned off ssl verification\n # This should be acceptable because it won't happen on a user's machine, just CI\n\n # define a progress-bar printer\n chunk_size = 1024 * 1024 * 1024\n total_size = 0\n dots = 0\n dot_printer = lambda do |size|\n total_size += size\n needed_dots = (total_size / chunk_size).to_i\n unprinted_dots = needed_dots - dots\n @output.print(\".\" * unprinted_dots) if unprinted_dots.positive?\n dots = needed_dots\n end\n\n URI.open(package_url, ssl_verify_mode: 0, progress_proc: dot_printer) do |url|\n File.open(package_file, 'wb') { |file| file.write(url.read) }\n end\n rescue Net::OpenTimeout, Net::ReadTimeout, OpenURI::HTTPError, URI::InvalidURIError => e\n @output.puts \"\\nArduino force-install failed downloading #{package_url}: #{e}\"\n end",
"def fetch type, version, extension=\"tar.gz\"\n core_url = \"#{@base}/#{type}-#{version}.#{extension}\"\n tmp = Galaxy::Temp.mk_auto_file \"galaxy-download\"\n @log.info \"Fetching #{core_url} into #{tmp}\"\n if @base =~ /^http:/\n begin\n output = Galaxy::HostUtils.system(\"curl -D - #{core_url} -o #{tmp} -s\")\n rescue Galaxy::HostUtils::CommandFailedError => e\n raise \"Failed to download archive #{core_url}: #{e}\"\n end\n status = output.first\n (protocol, response_code, response_message) = status.split\n unless response_code == '200'\n raise \"Failed to download archive #{core_url}: #{status}\"\n end\n else\n open(core_url) do |io|\n File.open(tmp, \"w\") { |f| f.write(io.read) }\n end\n end\n return tmp\n end",
"def retrieve_version(name, version)\n path = downloaded_gem_path name, version\n parse :gem => path\n end",
"def download\n open(download_url, \"rb\")\n end",
"def download_file(f)\n run(\"curl -O http://github.com/meskyanichi/rails-templates/raw/master/files/#{f}\")\nend",
"def local_path\n fetch_path(DevTools.gem_root)\n end",
"def downloaded_path\n @downloaded_path ||= File.join(install_path, file_name(url))\n return @downloaded_path\n end",
"def download(full_spec, path) # :nodoc:\n end",
"def gem_to_gemfile(gem)\n gem_str = <<~GEM\n #{gem.comment ? \"# #{gem.comment}\" : ''}\n #{(gem.commented_out ? '#' : '')}gem '#{gem.name}'#{gem_version_str(gem)}#{gem_options(gem)}\n GEM\n\n gem_str.strip\nend",
"def path; Gem.ruby; end",
"def file_from_repo(github_user, repo, sha, filename, to = filename)\n download(\"http://github.com/#{github_user}/#{repo}/raw/#{sha}/#{filename}\", to)\n end",
"def download_source\n unless @download_source\n if new_resource.package_url\n res = chase_redirect(new_resource.package_url)\n else\n params = URI.encode_www_form(full: 1,\n plat: node['platform_family'][0..2])\n res = chase_redirect(\"https://www.dropbox.com/download?#{params}\")\n end\n end\n @download_source ||= res\n end",
"def download(spec, path)\n nil\n end",
"def download_url(url)\n ethon = ethon_easy_requester\n ethon.url = uri_escape(url)\n ethon.perform\n check_and_raise_failure(ethon)\n {\n file_contents: ethon.response_body,\n link_url: last_location_header(ethon)\n }\n end",
"def download\n \n @tmpfile = fetch_remote(location)\n \n @fetched_at = Time.new\n \n return @tmpfile\n \n end",
"def download(url)\n Net::HTTP.get_response(url)\n end",
"def _download_module(name)\n command = \"puppet module install #{name} \"\n command += @modulepath + Silence\n\n puts \"Calling '#{command}'\" if @options[:debug]\n system(command)\n end",
"def main\n last_good_root = from_file($cache_dir + '/root.txt') ||\n from_file('config/root.txt') ||\n raise(\"Can't find root.txt\")\n\n repository = Gem::TUF::Repository.new(\n root: JSON.parse(last_good_root),\n bucket: FileCachingBucket.new(HttpBucket.new($host))\n )\n\n gem_name = ARGV.shift\n\n specs = repository.target('latest_specs.4.8.gz')\n raise \"could not find latest_specs.4.8.gz\" unless specs\n specs = unmarshal_gz specs\n gem = specs.detect {|x| x[0] == gem_name } || raise(\"Can't find gem #{gem}\")\n\n gem_with_version = \"#{gem[0]}-#{gem[1]}\"\n gem_path = \"gems/#{gem_with_version}.gem\"\n gemspec_path = \"quick/Marshal.4.8/#{gem_with_version}.gemspec.rz\"\n\n repository.target(gemspec_path)\n repository.target(gem_path)\n\n puts \"Downloaded #{gem_path} and #{gemspec_path}\"\nend",
"def get_file(url)\n get(url).body\n end",
"def tarball\n Dir[\"#{dest}/#{SCOPE}-#{gemspec.name}-#{gemspec.version}.tgz\"].first\n end",
"def download_resource(loader, src_url)\n # play nice with remote web servers\n sleep(rand / 100) if src_url =~ /^[[:alpha:]]+:/\n begin\n loader.spec_invoke(:data_source, src_url, nil)\n rescue Exception => e\n # FIXME: log\n $stderr.puts \"[NOKOGIRI] Cannot download resource : #{e.message}\"\n $stderr.puts e.backtrace[0,2].join(\"\\n\")\n nil\n end\n end",
"def gem(name, options={})\n puts \"vendoring gem #{name}\"\n if options[:git]\n in_root(\"vendor/gems\") do\n Git.clone(options[:git], options[:branch])\n end\n elsif options[:svn]\n in_root(\"vendor/gems\") do\n Svn.checkout(options[:svn], options[:branch])\n end\n else \n # TODO: Gem dependencies. Split output on \\n, iterate lines looking for Downloaded...\n in_root(\"vendor/gems\") do\n # Filename may be different than gem name\n filename = (`gem fetch #{name}`).chomp.gsub(/Downloaded /, '')\n\n `gem unpack #{filename}.gem`\n File.delete(\"#{filename}.gem\")\n end\n end\n end",
"def local_or_remote_gem(name, options = Hash.new)\n local_path = File.expand_path(\"../vendor/#{name}\", __FILE__)\n if File.exist?(local_path)\n gem name, options.merge(:path => local_path).delete_if { |key, _| [:git, :branch].include?(key) }\n else\n gem name, options\n end\nend",
"def absolute_gem_binary\n ::File.expand_path(gem_binary, path)\n end",
"def project_file\n if fetcher && fetcher.is_a?(NetFetcher)\n log.deprecated(log_key) do\n \"project_file (DSL). This is a property of the NetFetcher and will \" \\\n \"not be publically exposed in the next major release. In general, \" \\\n \"you should not be using this method in your software definitions \" \\\n \"as it is an internal implementation detail of the NetFetcher. If \" \\\n \"you disagree with this statement, you should open an issue on the \" \\\n \"Omnibus repository on GitHub an explain your use case. For now, \" \\\n \"I will return the path to the downloaded file on disk, but please \" \\\n \"rethink the problem you are trying to solve :).\"\n end\n\n fetcher.downloaded_file\n else\n log.warn(log_key) do\n \"Cannot retrieve a `project_file' for software `#{name}'. This \" \\\n \"attribute is actually an internal representation that is unique \" \\\n \"to the NetFetcher class and requires the use of a `source' \" \\\n \"attribute that is declared using a `:url' key. For backwards-\" \\\n \"compatability, I will return `nil', but this is most likely not \" \\\n \"your desired behavior.\"\n end\n\n nil\n end\n end",
"def download_installer\n puts pe_installer_url\n unless `curl #{pe_installer_url} -o ./file_cache/installers/#{installer_filename}`\n fail \"Error downloading the PE installer\"\n end\n gzip_installer if PRE_RELEASE\nend",
"def retrieve_bundle\n VCR.use_cassette('bundle_download') do\n bundle_resource = RestClient::Request.execute(method: :get,\n url: 'https://cypress.healthit.gov/measure_bundles/fixture-bundle-2020.zip',\n user: ENV.fetch('VSAC_USERNAME', nil),\n password: ENV.fetch('VSAC_PASSWORD', nil),\n raw_response: true,\n headers: { accept: :zip })\n\n return bundle_resource.file\n end\n end",
"def retrieve\n raise RetrieverError.new(\"download retriever is unavailable\") unless available?\n ::FileUtils.remove_entry_secure @repo_dir if File.exists?(@repo_dir)\n ::FileUtils.remove_entry_secure workdir if File.exists?(workdir)\n ::FileUtils.mkdir_p @repo_dir\n ::FileUtils.mkdir_p workdir\n file = ::File.join(workdir, \"package\")\n\n # TEAL FIX: we have to always-download the tarball before we can\n # determine if contents have changed, but afterward we can compare the\n # previous download against the latest downloaded and short-circuit the\n # remaining flow for the no-difference case.\n @logger.operation(:downloading) do\n credential_command = if @repository.first_credential && @repository.second_credential\n ['-u', \"#{@repository.first_credential}:#{@repository.second_credential}\"]\n else\n []\n end\n @output = ::RightScale::RightPopen::SafeOutputBuffer.new\n @cmd = [\n 'curl',\n '--silent', '--show-error', '--location', '--fail',\n '--location-trusted', '-o', file, credential_command,\n @repository.url\n ].flatten\n begin\n ::RightScale::RightPopen.popen3_sync(\n @cmd,\n :target => self,\n :pid_handler => :pid_download,\n :timeout_handler => :timeout_download,\n :size_limit_handler => :size_limit_download,\n :exit_handler => :exit_download,\n :stderr_handler => :output_download,\n :stdout_handler => :output_download,\n :inherit_io => true, # avoid killing any rails connection\n :watch_directory => workdir,\n :size_limit_bytes => @max_bytes,\n :timeout_seconds => @max_seconds)\n rescue Exception => e\n @logger.note_phase(:abort, :running_command, 'curl', e)\n raise\n end\n end\n\n note_tag(file)\n\n @logger.operation(:unpacking) do\n path = @repository.to_url.path\n if path =~ /\\.gz$/\n extraction = \"xzf\"\n elsif path =~ /\\.bz2$/\n extraction = \"xjf\"\n else\n extraction = \"xf\"\n end\n Dir.chdir(@repo_dir) do\n @output = ::RightScale::RightPopen::SafeOutputBuffer.new\n @cmd = ['tar', extraction, file]\n begin\n ::RightScale::RightPopen.popen3_sync(\n @cmd,\n :target => self,\n :pid_handler => :pid_download,\n :timeout_handler => :timeout_download,\n :size_limit_handler => :size_limit_download,\n :exit_handler => :exit_download,\n :stderr_handler => :output_download,\n :stdout_handler => :output_download,\n :inherit_io => true, # avoid killing any rails connection\n :watch_directory => @repo_dir,\n :size_limit_bytes => @max_bytes,\n :timeout_seconds => @max_seconds)\n rescue Exception => e\n @logger.note_phase(:abort, :running_command, @cmd.first, e)\n raise\n end\n end\n end\n true\n end",
"def download_asset(prog_id)\n return download_data(\"http://www.channel4.com/programmes/asset/#{prog_id}\")\n end",
"def gem(name, version)\n version = version.to_s\n\n begin\n json = open(\"https://rubygems.org/api/v1/versions/#{name}.json\") {|f| f.read}\n gems = JSON.parse(json)\n\n gem = gems.detect do |g|\n g[\"number\"] == version && g[\"platform\"] == \"ruby\"\n end\n\n if gem && gem[\"sha\"]\n # Rubygems.org was _supposed_ to provide base64 encoded SHA-256 hashes,\n # but as of now the hashes are base16 encoded...\n base16 = gem[\"sha\"]\n base32 = exec(\"nix-hash --type sha256 --to-base32 #{base16.shellescape}\")\n assert_length!(base32, 52)\n assert_format!(base32, /^[a-z0-9]+$/)\n\n base32\n end\n rescue Exception => ex\n #puts ex.message\n #puts ex.backtrace\n nil\n end\n end",
"def asset_url\n URI(\"https://github.com/#{repo}/releases/download/#{release}/\" <<\n app_name)\n end",
"def download_build(file)\n temp = Tempfile.new(['gadgets', \"#{file}.rb\"])\n temp.write(url_request(url_of_file(File.join('lib', 'one_gadget', 'builds', \"#{file}.rb\"))))\n temp.tap(&:close)\n end",
"def remote_repository\n \"http://www.aQute.biz/repo\"\n end",
"def download(url)\n STDERR.print \"loading #{url}\"\n response = Faraday.get(url)\n STDERR.puts ' (done)'\n response.body\n end",
"def get_file(url); end",
"def remote_path\n pv = node['platform_version']\n file = if Gem::Version.new(pv) >= Gem::Version.new('10.9')\n 'X2GoClient_latest_macosx_10_9.dmg'\n else\n 'X2GoClient_latest_macosx.dmg'\n end\n \"http://code.x2go.org/releases/#{file}\"\n end",
"def fetch_artifact_zip(download_path, url)\n # rubocop:disable Security/Open\n open(download_path, 'wb') do |file|\n file.print URI.open(url, 'Authorization' => \"token #{ENV['PERSONAL_TOKEN']}\").read\n end\n # rubocop:enable Security/Open\nend",
"def get_latest_release(project, bin)\n api_url = \"https://api.github.com/repos/#{project}/releases/latest\"\n data = URI.parse(api_url).read\n obj = JSON.parse(data)\n version = obj[\"name\"]\n sha_url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}.sha256\"\n sha = URI.parse(sha_url).read\n url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}\"\n sha256 = sha.split(\" \").first\n\n return url, sha256, version\nend",
"def download_original ; path_download_file(:original).download end",
"def local_gem(*args)\n load_local_gem(args[0]) || gem(*args)\n end",
"def get_packages!(path)\n response = Api::Request.new do |request|\n request[:sign] = false\n request[:method] = :GET\n request[:path] = \"/shared/packages/#{path}\"\n end.execute!\n\n Object::File.open(path, 'wb') do |file|\n file.write(response)\n end\n\n path\n end",
"def downloaded_file\n filename = source[:cached_name] if source[:cached_name]\n filename ||= File.basename(source[:url], \"?*\")\n File.join(Config.cache_dir, filename)\n end",
"def get_ai_repo_url(options)\n repo_ver = get_ai_repo_version(options)\n repo_url = \"pkg:/entire@0.5.11-\"+repo_ver\n return repo_url\nend",
"def fetch\n if cached_location.exist?\n @local_path = cached_location\n debug \"#{extended_name} is cached\"\n else\n raise \"No download URL specified for #{extended_name}\" if download_url.nil?\n blah \"Fetching #{extended_name}\"\n downloader = Drupid.makeDownloader self.download_url.to_s,\n self.cached_location.dirname.to_s,\n self.cached_location.basename.to_s,\n self.download_specs\n downloader.fetch\n downloader.stage\n @local_path = downloader.staged_path\n end\n end",
"def download_resource(url, path)\n FileUtils.mkdir_p File.dirname(path)\n the_uri = URI.parse(URI.escape(url))\n if the_uri\n data = html_get the_uri\n File.open(path, 'wb') { |f| f.write(data) } if data\n end\n end",
"def source(url)\n Gem.sources.clear if @default_sources\n\n @default_sources = false\n\n Gem.sources << url\n end",
"def download(path)\n downloader.get do |req|\n req.url path\n end.body\n end",
"def fetch_file(url)\n url =~ %r{/([^/]*)\\.(tar\\.gz|tar\\.bz2|tgz|zip|tbz)$}\n name = $1\n ext = $2\n filename = \"#{name}.#{ext}\"\n archive = File.join(env.path, \"archives\", filename)\n\n rbvm_md5 = config_md5[filename]\n\n if File.exists?(archive)\n archive_md5 = Digest::MD5.file(archive)\n if rbvm_md5\n if archive_md5.to_s == rbvm_md5\n log(\"Using existing archive for #{filename}.\", \"info\")\n fetch = false\n else\n log(\"Existing archive has bad MD5, backup and download again.\", \"error\")\n FileUtils.mv(archive, File.join(env.path, \"archives\", \"#{filename}-#{Time.now.strftime(\"%Y%m%d%H%M%S\")}.orig\"))\n archive_md5 = nil\n fetch = true\n end\n else\n log(\"Unknown archive: #{archive}\", \"warn\")\n fetch = false\n end\n else\n fetch = true\n end\n\n if fetch\n catch_error(\"Failed to fetch: #{url}\") do\n log(\"#{name} - #fetching\", 'info')\n exec_cmd(\"curl\", \"-s\", \"-S\", \"-L\", \"--create-dirs\", \"-C\", \"-\", \"-o\", archive, url)\n end\n end\n\n return archive\n end",
"def from_rubygems(name, version)\n download_gem name, version\n from_gem downloaded_gem_path(name, version)\n end",
"def download_iso\n IsoRepo.get(iso_url)\n end",
"def source_package_file\n pkg_file = nil\n pkg_dir = self.source_package_dir\n @source_urls.each do |url|\n poss_pkg_file = File.join(pkg_dir, File.basename(url[0]))\n if File::exists?(poss_pkg_file)\n pkg_file = poss_pkg_file\n break\n end\n end\n pkg_file\n end",
"def source_package_file\n pkg_file = nil\n pkg_dir = self.source_package_dir\n @source_urls.each do |url|\n poss_pkg_file = File.join(pkg_dir, File.basename(url[0]))\n if File::exists?(poss_pkg_file)\n pkg_file = poss_pkg_file\n break\n end\n end\n pkg_file\n end",
"def pkg_fetch\n return if File::exists? @srcdir\n\n sysprint \"#{@name} fetch: #{@fetch_url}\"\n\n # Try to guess by package URL extension\n if @fetch_url.match(/\\.git$/i)\n git_clone(@fetch_url, @srcdir)\n return\n end\n\n # Else use the URL to select fetch method\n protocol = @fetch_url.split(':')[0]\n\n if protocol.length == 0\n syserr \"Invalid package source URL #{@fetch_url}\"\n raise\n end\n\n case protocol\n when /^http$/i, /^https$/i, /^ftp$/i\n curl_fetch(@fetch_url, @srcdir)\n when /git/i\n git_clone(@fetch_url, @srcdir)\n else\n syserr \"Unhandled URL type: #{protocol}\"\n raise\n end\n end",
"def get_gh_file_content(filename)\n uri = \"https://raw.githubusercontent.com/fastruby/rails-template/main/config_files/#{filename}\"\n Net::HTTP.get(URI(uri))\nend",
"def source # :nodoc:\n Gem::Source::Installed.new\n end",
"def get_file(path, options={})\n remove_file path\n resource = File.join(prefs[:remote_host], prefs[:remote_branch], 'files', path)\n replace_file path, download_resource(resource, options)\nend",
"def get_repo(project)\n return 'https://github.com/NuCivic/' + project\n end",
"def dmg_package_source\n if %i(direct repo).include?(new_resource.source)\n return package_metadata[:url]\n end\n path = new_resource.source.to_s\n (path.start_with?('/') ? 'file://' : '') + path\n end",
"def download_source_of_pod(pod_name)\n return if sandbox.local?(pod_name) || sandbox.predownloaded?(pod_name)\n\n pod_downloader = create_pod_downloader(pod_name)\n pod_downloader.download!\n end",
"def source_path\n @source_path ||= source || begin\n u = URI.parse(URL)\n opts = { use_ssl: u.scheme == 'https',\n ca_file: Chef::Config[:ssl_ca_file] }\n body = Net::HTTP.start(u.host, u.port, opts) { |h| h.get(u) }.body\n regex = Regexp.new('https://downloads\\.plex\\.tv/' \\\n 'plex-home-theater/.*/' \\\n 'PlexHomeTheater.*-macosx-x86_64.zip')\n body.match(regex).to_s\n end\n end",
"def install_gem; end",
"def download_file url\n check_session\n result = api_client.execute(:uri => url)\n if result.status == 200\n return result.body\n else\n puts \"An error occurred: #{result.data['error']['message']}\"\n return nil\n end\n end",
"def get_artifact(job_name,filename)\n @artifact = job.find_artifact(job_name)\n response = make_http_request(Net::HTTP::Get.new(@artifact))\n if response.code == \"200\"\n File.write(File.expand_path(filename), response.body)\n else\n raise \"Couldn't get the artifact\"\n end\n end",
"def download_file(url)\n\t\t\tf = Tempfile.new(File.basename(url))\n\t\t\tpath = f.path\n\t\t\turl = URI.parse(url)\n\t\t\tNet::HTTP.start( url.host) { |http|\n\t\t\t\tresp = http.get(url.path)\n\t\t\t\tf.write(resp.body)\n\t\t\t}\n\t\t\tf.close\n\t\t\treturn path\n\t\tend",
"def download(url)\n base.get(url, @file_path)\n end",
"def download_to_string(params = {})\n sio = StringIO.new()\n download_to_io(sio, params)\n return sio.string\n end",
"def resource(gem_name, path)\n if not loaded? gem_name\n raise PluginNotLoaded.new(\"Plugin #{gem_name} not loaded when getting resource #{path}\")\n end\n\n file = File.join(@gems[gem_name], \"resources\", path)\n\n if File.exist? file\n return file\n else\n return nil\n end\n end",
"def fetch_spec(name_tuple)\n fetcher = Gem::RemoteFetcher.fetcher\n\n spec_file_name = name_tuple.spec_name\n\n source_uri = enforce_trailing_slash(uri) + \"#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}\"\n\n cache_dir = cache_dir source_uri\n\n local_spec = File.join cache_dir, spec_file_name\n\n if File.exist? local_spec\n spec = Gem.read_binary local_spec\n spec = Marshal.load(spec) rescue nil\n return spec if spec\n end\n\n source_uri.path << '.rz'\n\n spec = fetcher.fetch_path source_uri\n spec = Gem::Util.inflate spec\n\n if update_cache?\n require \"fileutils\"\n FileUtils.mkdir_p cache_dir\n\n File.open local_spec, 'wb' do |io|\n io.write spec\n end\n end\n\n # TODO: Investigate setting Gem::Specification#loaded_from to a URI\n Marshal.load spec\n end",
"def latest_version(name)\n return JSON.parse(open(\"http://rubygems.org/api/v1/gems/#{name}.json\").read)['version']\n end",
"def yardoc_file_for_gem(gem, ver_require = T.unsafe(nil), for_writing = T.unsafe(nil)); end",
"def fetch_spec(spec)\n spec = spec - [nil, 'ruby', '']\n spec_file_name = \"#{spec.join '-'}.gemspec.rz\"\n\n uri = URI.parse(\"#{@remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}\")\n\n spec_rz = (uri.scheme == \"file\") ? Gem.read_binary(uri.path) : fetch(uri)\n Marshal.load Gem.inflate(spec_rz)\n end",
"def bundle_download(app_name, fname, bundle_name=nil)\n\t\tdata = get(\"/apps/#{app_name}/bundles/#{bundle_name || 'latest'}\")\n\t\tFile.open(fname, \"wb\") { |f| f.write data }\n\tend",
"def package_download_url\n package_filename_url_safe = Info.release_version.gsub(\"+\", \"%2B\")\n \"https://#{Info.release_bucket}.#{Info.release_bucket_s3_endpoint}/ubuntu-focal/#{Info.package}_#{package_filename_url_safe}_amd64.deb\"\n end",
"def gem_install_command\n \"sudo gem install #{gem_name} -s http://gems.github.com\"\n end",
"def file_name\n \"#{full_name}.gem\"\n end",
"def fetch(path)\n begin\n (Curl::Easy.perform(base_url + path) do |curl|\n # This configures Curl::Easy to follow redirects\n curl.follow_location = true\n end).body_str\n rescue Curl::Err::HostResolutionError\n Merb.logger.error(\"Could not connect to \" + base_url + path)\n return \"\"\n end\n end",
"def download(url, filename)\n require 'open-uri'\n if File.exists?(\"lib/\" + filename)\n puts \"'#{filename}' is already downloaded... skipped\"\n else\n puts \"'#{filename}' downloading...\"\n File.open(\"lib/\" + filename, \"wb\") do |saved_file|\n open(url + filename, \"rb\") { |read_file| saved_file.write(read_file.read) }\n end\n end\nend",
"def url\n @client.get_download_link(@path)\n end",
"def download_path\n ::File.join(Chef::Config[:file_cache_path], ::File.basename(URL))\n end",
"def get_local_image(uri)\n # local?\n return uri unless uri[0,4] == 'http'\n\n ext = uri.split('.').last\n\n img_folder = './tmp/dl_img'\n Dir.mkdir(img_folder) unless Dir.exist?(img_folder)\n\n local_file = \"#{img_folder}/#{Digest::MD5.hexdigest(uri)}.#{ext}\"\n\n # wget is reliable downloader\n `wget -O #{local_file} #{uri}` unless File.exists?(local_file)\n\n local_file\n end"
] | [
"0.7534541",
"0.67299455",
"0.67081475",
"0.6692183",
"0.6659706",
"0.6656821",
"0.6645297",
"0.6597834",
"0.6492952",
"0.6471331",
"0.6405053",
"0.62191784",
"0.62173826",
"0.6206112",
"0.6204636",
"0.6111781",
"0.6081143",
"0.60659784",
"0.60081154",
"0.60081154",
"0.60064304",
"0.59869856",
"0.59376943",
"0.5902366",
"0.5893884",
"0.5892876",
"0.5890429",
"0.58682096",
"0.5859932",
"0.58474094",
"0.5834838",
"0.58338726",
"0.58021265",
"0.579411",
"0.57624424",
"0.57538474",
"0.5724507",
"0.5719381",
"0.57079023",
"0.5703284",
"0.5696623",
"0.5694715",
"0.56919914",
"0.56889397",
"0.56833357",
"0.5677072",
"0.5656899",
"0.56533355",
"0.56515694",
"0.5637722",
"0.5611607",
"0.5610939",
"0.5610236",
"0.5608676",
"0.56004506",
"0.56001407",
"0.5596606",
"0.5587695",
"0.5585627",
"0.5579736",
"0.5563075",
"0.5556431",
"0.55556184",
"0.55544126",
"0.553972",
"0.55366385",
"0.5531087",
"0.5527751",
"0.55122745",
"0.55077195",
"0.5504559",
"0.5504559",
"0.5495764",
"0.5495594",
"0.54941446",
"0.54933065",
"0.5484477",
"0.5481951",
"0.54815096",
"0.5477449",
"0.54760563",
"0.5458783",
"0.545668",
"0.54566383",
"0.5453366",
"0.5450812",
"0.5447932",
"0.5446923",
"0.5439821",
"0.54345894",
"0.54328364",
"0.5431566",
"0.54271764",
"0.542555",
"0.54169554",
"0.5416128",
"0.5411991",
"0.5405868",
"0.53828967",
"0.538236"
] | 0.74488395 | 1 |
Return path to downloaded gem | def downloaded_gem_path
self.class.downloaded_gem_path @name, @version
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gem_path\n @path || downloaded_gem_path\n end",
"def downloaded_gem_path\n self.class.downloaded_gem_path @name, @version\n end",
"def gem_path\n @path || downloaded_gem_path\n end",
"def downloaded_gem_path(name, version)\n # ensure gem is downloaded\n download_gem name, version\n GemCache.path_for(name, version)\n end",
"def package_path(extension='.gem')\n File.join(package_dir, package_basename(extension))\n end",
"def downloaded_path\n @downloaded_path ||= File.join(install_path, file_name(url))\n return @downloaded_path\n end",
"def gem_path\n File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))\n end",
"def full_gem_path\n # TODO: This is a heavily used method by gems, so we'll need\n # to aleast just alias it to #gem_dir rather than remove it.\n @full_gem_path ||= find_full_gem_path\n end",
"def full_gem_path\n # TODO: This is a heavily used method by gems, so we'll need\n # to aleast just alias it to #gem_dir rather than remove it.\n @full_gem_path ||= find_full_gem_path\n end",
"def download_gem\n self.class.download_gem @name, @version\n end",
"def gem_path\n `gem environment gemdir`.chomp\nend",
"def download_gem\n self.class.download_gem @name, @version\n end",
"def gem_build_complete_path # :nodoc:\n File.join extension_dir, 'gem.build_complete'\n end",
"def gem_dir\n directory = File.join(File.dirname(__FILE__), \"..\")\n File.expand_path(directory, File.dirname(__FILE__))\n end",
"def gem_dir\n if File.directory?(dir = File.join(working_dir, 'gems'))\n dir\n end\n end",
"def gem_dir\n if File.directory?(dir = File.join(working_dir, 'gems'))\n dir\n end\n end",
"def download(path)\n Gem.ensure_gem_subdirectories path\n\n if @spec.respond_to? :sources\n exception = nil\n path = @spec.sources.find do |source|\n begin\n source.download full_spec, path\n rescue exception\n end\n end\n return path if path\n raise exception if exception\n\n elsif @spec.respond_to? :source\n source = @spec.source\n source.download full_spec, path\n\n else\n source = Gem.sources.first\n source.download full_spec, path\n end\n end",
"def local_path\n fetch_path(DevTools.gem_root)\n end",
"def gem_dir\n return force_gem_dir if force_gem_dir\n if File.directory?(dir = default_gem_dir)\n dir\n end\n end",
"def gemfile_path\n @gemfile_path ||= GEMFILES.map { |g| @config.pwd.join g }\n .find { |f| f.exist? }\n end",
"def pkg_path\n \"pkg/#{spec.full_name}\"\n end",
"def gemspec_path\n Pathname.glob('*.gemspec').first\n end",
"def get_path(gemname, version_req)\n return gemname if gemname =~ /\\.gem$/i\n specs = SourceIndex.from_installed_gems.search(gemname, version_req)\n selected = specs.sort_by { |s| s.version }.last\n return nil if selected.nil?\n # We expect to find (basename).gem in the 'cache' directory.\n # Furthermore, the name match must be exact (ignoring case).\n if gemname =~ /^#{selected.name}$/i\n filename = selected.full_name + '.gem'\n return File.join(Gem.dir, 'cache', filename)\n else\n return nil\n end\n end",
"def gem_dir\n @gem_dir ||= File.expand_path File.join(gems_dir, full_name)\n end",
"def gem_install_dir\n if gems_use_tool_repo && tool_repo_install_dir && !user_install_enable\n path = eval_path(tool_repo_install_dir)\n else\n path = eval_path(find_val('user_gem_dir') || find_val('gem_install_dir') || home_dir)\n end\n\n append = find_val('append_gems')\n append = 'gems' if append == true || append.nil?\n\n if append\n unless path.end_with?(append)\n path = File.join(path, append)\n end\n end\n path\n end",
"def package_dir_path\n \"#{package_dir}/#{package_name}\"\n end",
"def path; Gem.ruby; end",
"def get_path_to_rails_gem\n path = ''\n rails_gem_contents = `gem contents rails -v #{get_rails_version_from_project}`\n rails_gem_contents.each_line do |contents|\n path_elements = contents.split(File::SEPARATOR)\n path_elements.pop\n path = path_elements.join(File::SEPARATOR)\n break\n end\n path\n end",
"def install_path\n Berkshelf.cookbook_store.storage_path\n .join(\"#{dependency.name}-#{revision}\")\n end",
"def elm_package_path(package)\n File.join(@git_resolver.repository_path(package), 'elm-package.json')\n end",
"def absolute_gem_binary\n ::File.expand_path(gem_binary, path)\n end",
"def gemfile_path\n @gemfile_path ||= begin\n path = ::File.expand_path(new_resource.path)\n if ::File.file?(path)\n # We got a path to a real file, use that.\n path\n else\n # Walk back until path==dirname(path) meaning we are at the root\n while path != (next_path = ::File.dirname(path))\n possible_path = ::File.join(path, 'Gemfile')\n return possible_path if ::File.file?(possible_path)\n path = next_path\n end\n end\n end\n end",
"def gem_dir(join=nil)\n if join\n File.join(gem_dir, join)\n else\n \"vendor/plugins/#{file_name}\"\n end\n end",
"def gem_dir\n return Dir.pwd unless Gem.loaded_specs.include? 'cts-mpx'\n\n Gem.loaded_specs['cts-mpx'].full_gem_path\n end",
"def get_pkg_location(cookbook)\n\n version = node.etcd.version\n base_url = get_mirror_svc('etcd')\n Chef::Log.info(\"Etcd base_url: #{base_url}\")\n\n # Replace any $version/$arch/$extn placeholder variables present in the URL\n # e.x: https://github.com/coreos/etcd/releases/download/v$version/etcd-v$version-$arch.$extn\n base_url = base_url.gsub('$version', version)\n .gsub('$arch', node.etcd.arch)\n .gsub('$extn', node.etcd.extn)\n exit_with_err(\"Invalid package base URL: #{base_url}\") unless url_valid?(base_url)\n\n file_name = File.basename(URI.parse(base_url).path)\n Chef::Log.info(\"Package url: #{base_url}, filename: #{file_name}\")\n return File.dirname(base_url), file_name\n\n end",
"def get_pkg_location(cookbook)\n\n version = node.etcd.version\n base_url = get_mirror_svc('etcd')\n Chef::Log.info(\"Etcd base_url: #{base_url}\")\n\n # Replace any $version/$arch/$extn placeholder variables present in the URL\n # e.x: https://github.com/coreos/etcd/releases/download/v$version/etcd-v$version-$arch.$extn\n base_url = base_url.gsub('$version', version)\n .gsub('$arch', node.etcd.arch)\n .gsub('$extn', node.etcd.extn)\n exit_with_err(\"Invalid package base URL: #{base_url}\") unless url_valid?(base_url)\n\n file_name = File.basename(URI.parse(base_url).path)\n Chef::Log.info(\"Package url: #{base_url}, filename: #{file_name}\")\n return File.dirname(base_url), file_name\n\n end",
"def gem_dir\n return Dir.pwd unless Gem.loaded_specs.include? 'cts-mpx'\n Gem.loaded_specs['cts-mpx'].full_gem_path\n end",
"def gem_root\n Pathname.new(__FILE__).dirname.parent.parent.expand_path\n end",
"def autoproj_gemfile_path; File.join(autoproj_install_dir, 'Gemfile') end",
"def release_path\n ::File.join(install_path, artifact_name, artifact_version)\n end",
"def dmg_dir_path\n \"#{package_dir}/#{dmg_name}\"\n end",
"def tar_path\n File.expand_path(@env[\"package.output\"], FileUtils.pwd)\n end",
"def gem_deps_file # :nodoc:\n File.basename @path\n end",
"def generate_downloaded_file_path(extension)\n \"#{File.join(Dir.tmpdir, VAGRANT_PACKAGE)}.#{extension}\"\n end",
"def installer_path\n %x[which apt-get].chomp\n end",
"def install_dir # :nodoc:\n File.join Gem.dir, 'bundler', 'gems', \"#{@name}-#{dir_shortref}\"\n end",
"def source_package_file\n pkg_file = nil\n pkg_dir = self.source_package_dir\n @source_urls.each do |url|\n poss_pkg_file = File.join(pkg_dir, File.basename(url[0]))\n if File::exists?(poss_pkg_file)\n pkg_file = poss_pkg_file\n break\n end\n end\n pkg_file\n end",
"def source_package_file\n pkg_file = nil\n pkg_dir = self.source_package_dir\n @source_urls.each do |url|\n poss_pkg_file = File.join(pkg_dir, File.basename(url[0]))\n if File::exists?(poss_pkg_file)\n pkg_file = poss_pkg_file\n break\n end\n end\n pkg_file\n end",
"def gem_name\n @gem_name ||= @source_path.sub_ext(\"\").basename.to_s\n end",
"def download_path\n ::File.join(Chef::Config[:file_cache_path],\n ::File.basename(source_path))\n end",
"def download_path\n ::File.join(Chef::Config[:file_cache_path], ::File.basename(URL))\n end",
"def install_dir # :nodoc:\n return unless File.exist? repo_cache_dir\n\n File.join base_dir, 'gems', \"#{@name}-#{dir_shortref}\"\n end",
"def path\n @backend.lib_dir + name_on_disk\n end",
"def relative_path\n File.join(@repo, @bundle)\n end",
"def gempath_to_yaypath gem_path\n\t\t\treturn \"#{gem_path}/gems/yay-#{Yay::VERSION}/data/yay\"\n\t\tend",
"def remote_path_for(package)\n File.join(path, package.trigger)\n end",
"def relative_install_path\n a = artifact\n name = File.basename(a.to_s)\n a.respond_to?(:group) ? \"#{a.group.gsub('.', '/')}/#{name}\" : \"#{name}\"\n end",
"def package_dir\r\n \"${0%/#{target_name}}\"\r\n end",
"def bundle_dir\n File.expand_path(File.join(Bixby.repo_path, self.relative_path))\n end",
"def remote_path_for(package)\n File.join(\n Config.artifactory_base_path,\n package.metadata[:name],\n package.metadata[:version],\n publish_platform(package),\n publish_platform_version(package),\n package.metadata[:basename],\n )\n end",
"def bundled_path\n File.dirname Wisp::Source.bundled_path\n end",
"def target_path(target_name)\r\n File.join(package_dir, target_name)\r\n end",
"def pack_path(name)\n path = WebpackerLite::Configuration.base_path\n file = WebpackerLite::Manifest.lookup(name)\n \"#{path}/#{file}\"\n end",
"def path_from_package(package_name)\n ret = package_from_name package_name\n ret && ret.root_path\n end",
"def pathDist\n\t\"../../\" + distPackageName + \"_\" + version + \"/\"\nend",
"def path_for(package)\n \"#{package.path}.metadata.json\"\n end",
"def package_scripts_path\n \"#{Config.project_root}/package-scripts/#{name}\"\n end",
"def manifest_path\n path = @config[\"manifest\"][\"path\"] if @config[\"manifest\"]\n return Licensed::Git.repository_root.join(path) if path\n\n @config.cache_path.join(\"manifest.json\")\n end",
"def gem_root\n @@root\n end",
"def gem_path?(file); end",
"def package_url\n \"https://github.com/arduino/arduino-cli/releases/download/#{@desired_version}/#{package_file}\"\n end",
"def find_requireable_file(file)\n root = full_gem_path\n\n require_paths.each do |lib|\n base = File.join(root, lib, file)\n Gem.suffixes.each do |suf|\n path = \"#{base}#{suf}\"\n return path if File.file? path\n end\n end\n\n return nil\n end",
"def install_dir(lib)\n if fr = ENV['FAKEROOT']\n return File.join(fr, lib)\n end\n\n lib\nend",
"def file_name\n \"#{full_name}.gem\"\n end",
"def component_libpath(cmp)\n vars = component_cmake_vars cmp\n libdir = vars.fetch('INSTALL_LIB_DIR', 'lib')\n File.join component_install_path(cmp), libdir\nend",
"def find_source_directory(gem_name, version=nil)\n if version == 'cwd'\n return Dir.pwd\n elsif version\n version_array = [\"= #{version}\"]\n else\n version_array = [\"> 0.0.0\"]\n end\n \n specs = Gem.source_index.find_name(gem_name,version_array)\n unless specs.to_a.size > 0\n raise InstallFailed, \"Can't locate version #{version}!\"\n end\n \n @install_version = specs.last.version\n message \"Installing #{app_name} #{@install_version}\"\n \n specs.last.full_gem_path\n end",
"def pkg_dir\n @pkg_dir ||= File.join( self.build_dir, \"#{name + ( version ? \"-#{version}\" : \"\" ) }\" )\n end",
"def repo_path\n @repo_path ||= \"/tmp/extension-repo-#{id}\"\n end",
"def path_for(package)\n \"#{package.path}.metadata.json\"\n end",
"def expanded_path\n relative_path(dependency.berksfile.filepath)\n end",
"def manifest_path\n build_output_dir.join('manifest.json')\n end",
"def lib_out\n @mpc_project.recipe.get_relative_path(@mpc_project.lib_out)\n end",
"def file_path path\n File.join(output_path, manifest.lookup(path).split('/')[2..-1])\n end",
"def lib_path; end",
"def lib_path; end",
"def lib_path; end",
"def remote_path\n pv = node['platform_version']\n file = if Gem::Version.new(pv) >= Gem::Version.new('10.9')\n 'X2GoClient_latest_macosx_10_9.dmg'\n else\n 'X2GoClient_latest_macosx.dmg'\n end\n \"http://code.x2go.org/releases/#{file}\"\n end",
"def build\n\t@built_gem_path ||= @helper.build_gem\nend",
"def gems_dir\n raise NotImplementedError\n end",
"def gemspec_file\n project_path( \"#{ name }.gemspec\" )\n end",
"def gem_uri\n @gem_uri ||=\n @rack_context.getInitParameter('gem.path') ||\n @rack_context.getInitParameter('gem.home') ||\n '/WEB-INF/gems'\n end",
"def local_path\n src = if %i(direct repo).include?(new_resource.source)\n package_metadata[:url]\n else\n new_resource.source.to_s\n end\n ::File.join(Chef::Config[:file_cache_path], ::File.basename(src))\n end",
"def gem_uri\n @gem_uri ||=\n @rack_context.getInitParameter('gem.path') ||\n @rack_context.getInitParameter('gem.home')\n end",
"def libfile\n libfile = Pathname.new(resource[:lib]).absolute? ? resource[:lib] : \"modules/#{resource[:lib]}\"\n end",
"def gem_r_lib\n File.expand_path(File.join(File.dirname(__FILE__), %w(.. r_lib)))\n end",
"def extension_dir\n @extension_dir ||= File.expand_path(File.join(extensions_dir, full_name)).tap(&Gem::UNTAINT)\n end",
"def default_path\n Gem.default_path + [@home]\n end",
"def license_package_location(component_name, where)\n if local?(where)\n File.join(output_dir, \"#{component_name}-#{File.split(where).last}\")\n else\n u = URI(where)\n File.join(output_dir, \"#{component_name}-#{File.basename(u.path)}\")\n end\n end",
"def license_package_location(component_name, where)\n if local?(where)\n File.join(output_dir, \"#{component_name}-#{File.split(where).last}\")\n else\n u = URI(where)\n File.join(output_dir, \"#{component_name}-#{File.basename(u.path)}\")\n end\n end",
"def gemspec_path\n unless instance_variable_defined? :@gemspec\n path = \"#{name}.gemspec\"\n\n unless File.exist?(path)\n shell.say 'No gemspec found'\n exit 1\n end\n\n @gemspec_path = path\n end\n\n @gemspec_path\n end"
] | [
"0.86328757",
"0.8569027",
"0.8511787",
"0.764266",
"0.7624339",
"0.7498303",
"0.71763456",
"0.70950896",
"0.70950896",
"0.7091811",
"0.7047844",
"0.7008313",
"0.7005286",
"0.69122773",
"0.6885031",
"0.6885031",
"0.68829566",
"0.68764734",
"0.6868022",
"0.68548036",
"0.67847955",
"0.6769897",
"0.6744987",
"0.67422086",
"0.6728374",
"0.67259276",
"0.6702808",
"0.6658755",
"0.6643578",
"0.66244954",
"0.6619361",
"0.66183853",
"0.6617244",
"0.6570604",
"0.6515049",
"0.6515049",
"0.6504307",
"0.6502916",
"0.6492575",
"0.64525926",
"0.64489794",
"0.64471704",
"0.64207906",
"0.6419756",
"0.63971406",
"0.63971114",
"0.63900197",
"0.63900197",
"0.63864464",
"0.6371441",
"0.63557935",
"0.6349021",
"0.63463116",
"0.6307549",
"0.62823796",
"0.6271591",
"0.6271242",
"0.62536705",
"0.6249402",
"0.62360954",
"0.6221315",
"0.621993",
"0.6210741",
"0.61889815",
"0.61643386",
"0.6149231",
"0.61479855",
"0.6114298",
"0.61138296",
"0.61080325",
"0.61070925",
"0.61046517",
"0.61018103",
"0.60880136",
"0.6081778",
"0.6080638",
"0.607343",
"0.60703504",
"0.60647166",
"0.60466385",
"0.6046412",
"0.6045416",
"0.604387",
"0.6039889",
"0.6039889",
"0.6039889",
"0.6034778",
"0.60345423",
"0.6034302",
"0.6033616",
"0.60216594",
"0.60080206",
"0.6003495",
"0.60006154",
"0.5996604",
"0.59842485",
"0.5983354",
"0.5981976",
"0.5979555",
"0.5978859"
] | 0.8444249 | 3 |
Returns path to gem, either specified one of downloaded one | def gem_path
@path || downloaded_gem_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gem_path\n @path || downloaded_gem_path\n end",
"def downloaded_gem_path\n self.class.downloaded_gem_path @name, @version\n end",
"def downloaded_gem_path\n self.class.downloaded_gem_path @name, @version\n end",
"def get_path(gemname, version_req)\n return gemname if gemname =~ /\\.gem$/i\n specs = SourceIndex.from_installed_gems.search(gemname, version_req)\n selected = specs.sort_by { |s| s.version }.last\n return nil if selected.nil?\n # We expect to find (basename).gem in the 'cache' directory.\n # Furthermore, the name match must be exact (ignoring case).\n if gemname =~ /^#{selected.name}$/i\n filename = selected.full_name + '.gem'\n return File.join(Gem.dir, 'cache', filename)\n else\n return nil\n end\n end",
"def package_path(extension='.gem')\n File.join(package_dir, package_basename(extension))\n end",
"def gemspec_path\n Pathname.glob('*.gemspec').first\n end",
"def find_requireable_file(file)\n root = full_gem_path\n\n require_paths.each do |lib|\n base = File.join(root, lib, file)\n Gem.suffixes.each do |suf|\n path = \"#{base}#{suf}\"\n return path if File.file? path\n end\n end\n\n return nil\n end",
"def downloaded_gem_path(name, version)\n # ensure gem is downloaded\n download_gem name, version\n GemCache.path_for(name, version)\n end",
"def gem_path?(file); end",
"def find_requirable_file(file)\n root = full_gem_path\n\n require_paths.each do |lib|\n base = \"#{root}/#{lib}/#{file}\"\n Gem.suffixes.each do |suf|\n path = \"#{base}#{suf}\"\n return path if File.file? path\n end\n end\n\n return nil\n end",
"def full_gem_path\n # TODO: This is a heavily used method by gems, so we'll need\n # to aleast just alias it to #gem_dir rather than remove it.\n @full_gem_path ||= find_full_gem_path\n end",
"def full_gem_path\n # TODO: This is a heavily used method by gems, so we'll need\n # to aleast just alias it to #gem_dir rather than remove it.\n @full_gem_path ||= find_full_gem_path\n end",
"def gem_path\n `gem environment gemdir`.chomp\nend",
"def gem_name\n @gem_name ||= @source_path.sub_ext(\"\").basename.to_s\n end",
"def gem_dir\n return force_gem_dir if force_gem_dir\n if File.directory?(dir = default_gem_dir)\n dir\n end\n end",
"def local_or_remote_gem(name, options = Hash.new)\n local_path = File.expand_path(\"../vendor/#{name}\", __FILE__)\n if File.exist?(local_path)\n gem name, options.merge(:path => local_path).delete_if { |key, _| [:git, :branch].include?(key) }\n else\n gem name, options\n end\nend",
"def path; Gem.ruby; end",
"def gem_path\n File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))\n end",
"def try_local(gem_name)\n if ENV['USE_LOCAL_GEMS']\n gem gem_name, path: \"../#{gem_name}\"\n else\n gem gem_name, github: \"omniscrapper/#{gem_name}\"\n end\nend",
"def pkg_path\n \"pkg/#{spec.full_name}\"\n end",
"def gemfile_path\n @gemfile_path ||= begin\n path = ::File.expand_path(new_resource.path)\n if ::File.file?(path)\n # We got a path to a real file, use that.\n path\n else\n # Walk back until path==dirname(path) meaning we are at the root\n while path != (next_path = ::File.dirname(path))\n possible_path = ::File.join(path, 'Gemfile')\n return possible_path if ::File.file?(possible_path)\n path = next_path\n end\n end\n end\n end",
"def gem_dir\n if File.directory?(dir = File.join(working_dir, 'gems'))\n dir\n end\n end",
"def gem_dir\n if File.directory?(dir = File.join(working_dir, 'gems'))\n dir\n end\n end",
"def find_gem(name, version)\n spec = source_index.find_name(name, version).last\n unless spec and (spec.installation_path rescue nil)\n alert_error \"Could not find gem #{name} (#{version})\"\n raise Gem::GemNotFoundException, \"Could not find gem #{name}, (#{version})\"\n end\n\n return spec\n end",
"def get_path_to_rails_gem\n path = ''\n rails_gem_contents = `gem contents rails -v #{get_rails_version_from_project}`\n rails_gem_contents.each_line do |contents|\n path_elements = contents.split(File::SEPARATOR)\n path_elements.pop\n path = path_elements.join(File::SEPARATOR)\n break\n end\n path\n end",
"def find_gem_name(base)\n spec = Dir[File.join(base, '*.gemspec')].first\n File.basename(spec, '.gemspec') if spec\n end",
"def download(path)\n Gem.ensure_gem_subdirectories path\n\n if @spec.respond_to? :sources\n exception = nil\n path = @spec.sources.find do |source|\n begin\n source.download full_spec, path\n rescue exception\n end\n end\n return path if path\n raise exception if exception\n\n elsif @spec.respond_to? :source\n source = @spec.source\n source.download full_spec, path\n\n else\n source = Gem.sources.first\n source.download full_spec, path\n end\n end",
"def gem?\n #return true if Dir[File.join(location, '*.gemspec')].first\n pkgname = File.basename(location)\n gemsdir = File.dirname(location)\n specdir = File.join(File.dirname(gemsdir), 'specifications')\n Dir[File.join(specdir, \"#{pkgname}.gemspec\")].first\n end",
"def gem_deps_file # :nodoc:\n File.basename @path\n end",
"def source_package_file\n pkg_file = nil\n pkg_dir = self.source_package_dir\n @source_urls.each do |url|\n poss_pkg_file = File.join(pkg_dir, File.basename(url[0]))\n if File::exists?(poss_pkg_file)\n pkg_file = poss_pkg_file\n break\n end\n end\n pkg_file\n end",
"def source_package_file\n pkg_file = nil\n pkg_dir = self.source_package_dir\n @source_urls.each do |url|\n poss_pkg_file = File.join(pkg_dir, File.basename(url[0]))\n if File::exists?(poss_pkg_file)\n pkg_file = poss_pkg_file\n break\n end\n end\n pkg_file\n end",
"def gemfile_path\n @gemfile_path ||= GEMFILES.map { |g| @config.pwd.join g }\n .find { |f| f.exist? }\n end",
"def gem_dir\n @gem_dir ||= File.expand_path File.join(gems_dir, full_name)\n end",
"def gemspec_file\n gemspec_file_system || gemspec_file_local\n end",
"def opal_gem(gem_name)\n Opal.use_gem(gem_name)\n Opal.paths.uniq!\n # require(gem_name)\n end",
"def gem(name, main_module)\n _, spec = Gem.loaded_specs.find { |spec_pair| spec_pair[0] == name }\n gems << spec\n modules << main_module\n spec.full_gem_path\n end",
"def gem_uri\n @gem_uri ||=\n @rack_context.getInitParameter('gem.path') ||\n @rack_context.getInitParameter('gem.home')\n end",
"def gem_uri\n @gem_uri ||=\n @rack_context.getInitParameter('gem.path') ||\n @rack_context.getInitParameter('gem.home') ||\n '/WEB-INF/gems'\n end",
"def gem_dir(join=nil)\n if join\n File.join(gem_dir, join)\n else\n \"vendor/plugins/#{file_name}\"\n end\n end",
"def gemspec(path)\n installed_gemspec(path) || local_gemspec(path)\n end",
"def get_gem_home_root(arr)\n gem_string = \"/gems/\"\n ret = nil\n arr.each do |line|\n if line.include? gem_string\n ret = line.split(gem_string)[0] + gem_string\n break\n end\n end\n ret\n end",
"def gem_dir\n directory = File.join(File.dirname(__FILE__), \"..\")\n File.expand_path(directory, File.dirname(__FILE__))\n end",
"def gem_build_complete_path # :nodoc:\n File.join extension_dir, 'gem.build_complete'\n end",
"def file_name\n \"#{full_name}.gem\"\n end",
"def custom_gem(name, options = Hash.new)\n local_path = File.expand_path \"../vendor/#{name}\", __FILE__\n\n if File.exist? local_path\n options = options.merge :path => local_path\n options.delete_if do |key, _|\n [:github, :branch].include? key\n end\n end\n\n gem name, options\nend",
"def find_plugin_path( mod_name )\n\t\tcandidates = self.plugin_path_candidates( mod_name )\n\t\tPluggability.log.debug \"Candidates for %p are: %p\" % [ mod_name, candidates ]\n\n\t\tcandidate_paths = candidates.\n\t\t\tflat_map {|path| Gem.find_latest_files( path ) }.\n\t\t\treject {|path| self.is_excluded_path?( path ) || ! File.file?(path) }\n\t\tPluggability.log.debug \"Valid candidates in the current gemset: %p\" % [ candidate_paths ]\n\n\t\treturn candidate_paths.first\n\tend",
"def local_gem(*args)\n load_local_gem(args[0]) || gem(*args)\n end",
"def find_source_directory(gem_name, version=nil)\n if version == 'cwd'\n return Dir.pwd\n elsif version\n version_array = [\"= #{version}\"]\n else\n version_array = [\"> 0.0.0\"]\n end\n \n specs = Gem.source_index.find_name(gem_name,version_array)\n unless specs.to_a.size > 0\n raise InstallFailed, \"Can't locate version #{version}!\"\n end\n \n @install_version = specs.last.version\n message \"Installing #{app_name} #{@install_version}\"\n \n specs.last.full_gem_path\n end",
"def download_gem\n self.class.download_gem @name, @version\n end",
"def gem_installed?(gem)\n begin\n old_stderr, $stderr = $stderr, StringIO.new\n if defined?(::Gem::Specification) && ::Gem::Specification.respond_to?(:find_by_name)\n gem_spec = ::Gem::Specification.find_by_name(gem)\n else\n gem_spec = ::Gem::GemPathSearcher.new.find(gem)\n end\n gem_spec.nil? ? nil : gem_spec.version.to_s\n rescue LoadError\n nil\n ensure\n $stderr = old_stderr\n end\n end",
"def absolute_gem_binary\n ::File.expand_path(gem_binary, path)\n end",
"def path_from_package(package_name)\n ret = package_from_name package_name\n ret && ret.root_path\n end",
"def gem_dir\n return Dir.pwd unless Gem.loaded_specs.include? 'cts-mpx'\n\n Gem.loaded_specs['cts-mpx'].full_gem_path\n end",
"def local_path\n fetch_path(DevTools.gem_root)\n end",
"def gems_dir\n raise NotImplementedError\n end",
"def download_gem\n self.class.download_gem @name, @version\n end",
"def local_gemspec(path)\n glob = File.join(path, '{,*}.gemspec')\n Dir[glob].first\n end",
"def get_short_lookup(gemname)\n md = /^([-a-zA-z_0-9\\.]+)(?:-|\\.)(?:\\d+(?:\\.[\\drc]+)*)$/.match(gemname)\n if (!md)\n puts %{skipping weirdly formed directory: \"#{gemname}\"}\n #raise Exception.new(%{Sorry, we failed to match against \"#{gemname}\"})\n end\n return $1\nend",
"def source\n case type\n when :gem then File.basename File.expand_path '..', @path\n when :home then 'home'\n when :site then 'site'\n when :system then 'ruby'\n else @path\n end\n end",
"def license_package_location(component_name, where)\n if local?(where)\n File.join(output_dir, \"#{component_name}-#{File.split(where).last}\")\n else\n u = URI(where)\n File.join(output_dir, \"#{component_name}-#{File.basename(u.path)}\")\n end\n end",
"def license_package_location(component_name, where)\n if local?(where)\n File.join(output_dir, \"#{component_name}-#{File.split(where).last}\")\n else\n u = URI(where)\n File.join(output_dir, \"#{component_name}-#{File.basename(u.path)}\")\n end\n end",
"def path_to_require\n name = self.rpartition('.').first\n $LOAD_PATH.each do |lib|\n name.sub!(lib+\"/\", '')\n end\n name\n end",
"def resource(gem_name, path)\n if not loaded? gem_name\n raise PluginNotLoaded.new(\"Plugin #{gem_name} not loaded when getting resource #{path}\")\n end\n\n file = File.join(@gems[gem_name], \"resources\", path)\n\n if File.exist? file\n return file\n else\n return nil\n end\n end",
"def find_latest_gem(gem_name)\n the_gem = Dir.glob(\"#{Gem.dir}/gems/#{gem_name}-*\")\n\n the_gem.empty? ? nil : the_gem.sort.last\n end",
"def gemspec_path\n unless instance_variable_defined? :@gemspec\n path = \"#{name}.gemspec\"\n\n unless File.exist?(path)\n shell.say 'No gemspec found'\n exit 1\n end\n\n @gemspec_path = path\n end\n\n @gemspec_path\n end",
"def gem_root\n Pathname.new(__FILE__).dirname.parent.parent.expand_path\n end",
"def elm_package_path(package)\n File.join(@git_resolver.repository_path(package), 'elm-package.json')\n end",
"def default_path\n Gem.default_path + [@home]\n end",
"def gems_uri\n raise NotImplementedError, not_implemented_msg(:gems_uri)\n end",
"def autoproj_gemfile_path; File.join(autoproj_install_dir, 'Gemfile') end",
"def gem_dir\n return Dir.pwd unless Gem.loaded_specs.include? 'cts-mpx'\n Gem.loaded_specs['cts-mpx'].full_gem_path\n end",
"def custom_gem(name, options = Hash.new)\n local_path = File.expand_path(\"../../#{name}\", __FILE__)\n if ENV[\"USE_JSUS_CUSTOM_GEMS\"] && File.directory?(local_path)\n gem name, options.merge(:path => local_path).delete_if { |key, _| [:git, :branch].include?(key) }\n else\n gem name, options\n end\nend",
"def gem_to_gemfile(gem)\n gem_str = <<~GEM\n #{gem.comment ? \"# #{gem.comment}\" : ''}\n #{(gem.commented_out ? '#' : '')}gem '#{gem.name}'#{gem_version_str(gem)}#{gem_options(gem)}\n GEM\n\n gem_str.strip\nend",
"def plugin_gem_location(plugin)\n \"sequel/plugins/#{plugin}\"\n end",
"def friendly_path\n case type\n when :gem then\n parent = File.expand_path '..', @path\n \"gem #{File.basename parent}\"\n when :home then RDoc.home\n when :site then 'ruby site'\n when :system then 'ruby core'\n else @path\n end\n end",
"def gemspec_file\n project_path( \"#{ name }.gemspec\" )\n end",
"def gemfile; end",
"def gemfile; end",
"def gemfile; end",
"def gemfile; end",
"def gemfile; end",
"def gemfile; end",
"def get_pkg_location(cookbook)\n\n version = node.etcd.version\n base_url = get_mirror_svc('etcd')\n Chef::Log.info(\"Etcd base_url: #{base_url}\")\n\n # Replace any $version/$arch/$extn placeholder variables present in the URL\n # e.x: https://github.com/coreos/etcd/releases/download/v$version/etcd-v$version-$arch.$extn\n base_url = base_url.gsub('$version', version)\n .gsub('$arch', node.etcd.arch)\n .gsub('$extn', node.etcd.extn)\n exit_with_err(\"Invalid package base URL: #{base_url}\") unless url_valid?(base_url)\n\n file_name = File.basename(URI.parse(base_url).path)\n Chef::Log.info(\"Package url: #{base_url}, filename: #{file_name}\")\n return File.dirname(base_url), file_name\n\n end",
"def get_pkg_location(cookbook)\n\n version = node.etcd.version\n base_url = get_mirror_svc('etcd')\n Chef::Log.info(\"Etcd base_url: #{base_url}\")\n\n # Replace any $version/$arch/$extn placeholder variables present in the URL\n # e.x: https://github.com/coreos/etcd/releases/download/v$version/etcd-v$version-$arch.$extn\n base_url = base_url.gsub('$version', version)\n .gsub('$arch', node.etcd.arch)\n .gsub('$extn', node.etcd.extn)\n exit_with_err(\"Invalid package base URL: #{base_url}\") unless url_valid?(base_url)\n\n file_name = File.basename(URI.parse(base_url).path)\n Chef::Log.info(\"Package url: #{base_url}, filename: #{file_name}\")\n return File.dirname(base_url), file_name\n\n end",
"def fetch_gem(name, version)\n http_get(host + \"/gems/#{name}-#{version}.gem\").body\n end",
"def gem_path(name, options) # :nodoc:\n return unless directory = options.delete(:path)\n\n pin_gem_source name, :path, directory\n\n @vendor_set.add_vendor_gem name, directory\n\n true\n end",
"def installer_path\n %x[which apt-get].chomp\n end",
"def try_gem_path file\n @gem_paths.each do |gem_path|\n if file.start_with? gem_path and not gem_path.empty?\n file.sub! File.join(gem_path, 'gems'), ''\n file.sub! %r{/[^/]*/}, ''\n return true\n end\n end\n return false\n end",
"def plugin_gem(name, options = {})\n lib, version = options.values_at(:lib, :version)\n begin\n Kernel.send :gem, name, version\n rescue Gem::LoadError\n dir = File.dirname(caller.first.split(':').first)\n $: << File.expand_path(\"#{dir}/../vendor/gems/#{name}-#{version.gsub(/[^\\d\\.]*/, '')}/lib\")\n end\n require(lib || name)\n end",
"def bundle_base_gem_path\n return '.bundle/install/ruby/2.5.0/bundler/gems'\nend",
"def gempath_to_yaypath gem_path\n\t\t\treturn \"#{gem_path}/gems/yay-#{Yay::VERSION}/data/yay\"\n\t\tend",
"def package\n @package ||= path.split('/lib/')[0].split('/').last.split('.js').last\n end",
"def gemfile_requirement(name)\n @original_gemfile ||= IO.read('Gemfile')\n req = @original_gemfile[/gem\\s+['\"]#{name}['\"]\\s*(,[><~= \\t\\d\\.\\w'\"]*)?.*$/, 1]\n req && req.tr(\"'\", %(\")).strip.sub(/^,\\s*\"/, ', \"')\nend",
"def gem_install_dir\n if gems_use_tool_repo && tool_repo_install_dir && !user_install_enable\n path = eval_path(tool_repo_install_dir)\n else\n path = eval_path(find_val('user_gem_dir') || find_val('gem_install_dir') || home_dir)\n end\n\n append = find_val('append_gems')\n append = 'gems' if append == true || append.nil?\n\n if append\n unless path.end_with?(append)\n path = File.join(path, append)\n end\n end\n path\n end",
"def libfile\n Pathname.new(resource[:lib]).absolute? ? resource[:lib] : \"modules/#{resource[:lib]}\"\n end",
"def paths_from_software_gems\n @paths_from_software_gems ||=\n Array(Config.software_gems).inject([]) do |array, name|\n if (spec = Gem::Specification.find_all_by_name(name).first)\n array << File.expand_path(spec.gem_dir)\n end\n\n array\n end\n end",
"def get_version(gem)\n lockfile_specs.find { |s| s.name == gem }&.version\n end",
"def relative_path\n File.join(@repo, @bundle)\n end",
"def check_gem(gem, gem_path)\n result = `#{gem_path} query --local | grep #{ gem }`\n if result == \"\"\n installed = false\n else\n installed = true\n end #if\n \n installed\n end",
"def add_hardcoded_gem(path)\n # make sure gem dir has a gemspec\n gemspec = File.join path, File.basename(path) + '.gemspec'\n return unless File.exists? gemspec\n # make sure gem dir has a lib dir\n libpath = File.join path, 'lib'\n return unless File.exists? libpath\n # all is ok, so add to loadpath\n @paths << libpath\n end"
] | [
"0.8079479",
"0.75119436",
"0.7334652",
"0.7258571",
"0.7078767",
"0.70415556",
"0.70225894",
"0.69959354",
"0.699445",
"0.69817716",
"0.69349766",
"0.69349766",
"0.69193554",
"0.6903768",
"0.68749917",
"0.68707067",
"0.6867492",
"0.674238",
"0.6721111",
"0.6708973",
"0.6669629",
"0.6654361",
"0.6654361",
"0.66374606",
"0.66080767",
"0.659428",
"0.6582034",
"0.6559503",
"0.65071106",
"0.65031797",
"0.65031797",
"0.64851856",
"0.64830756",
"0.6478399",
"0.6440212",
"0.6420188",
"0.6416408",
"0.6395869",
"0.63957655",
"0.6393473",
"0.6390625",
"0.63782793",
"0.6357197",
"0.63441277",
"0.6311192",
"0.63047546",
"0.63046676",
"0.6301483",
"0.62901807",
"0.62440616",
"0.62309396",
"0.61981",
"0.6175978",
"0.6172042",
"0.6159389",
"0.6146889",
"0.6137713",
"0.61347854",
"0.6132101",
"0.6127416",
"0.6127057",
"0.6125498",
"0.6119999",
"0.6116015",
"0.61114264",
"0.6110484",
"0.6104692",
"0.6099773",
"0.6096172",
"0.6092384",
"0.60922986",
"0.6089211",
"0.6081836",
"0.60766315",
"0.6071997",
"0.6062112",
"0.60433286",
"0.60433286",
"0.60433286",
"0.60433286",
"0.60433286",
"0.60433286",
"0.60292315",
"0.60292315",
"0.6024867",
"0.6013466",
"0.6011799",
"0.5997474",
"0.59785897",
"0.597717",
"0.5966189",
"0.59589887",
"0.5946636",
"0.59449536",
"0.59422934",
"0.5942228",
"0.5942143",
"0.59392405",
"0.5936363",
"0.5935147"
] | 0.79183096 | 1 |
Unpack files & return unpacked directory If block is specified, it will be invoked with directory after which directory will be removed | def unpack(&bl)
dir = nil
pkg = ::Gem::Installer.new gem_path, :unpack => true
if bl
Dir.mktmpdir do |tmpdir|
pkg.unpack tmpdir
bl.call tmpdir
end
else
dir = Dir.mktmpdir
pkg.unpack dir
end
dir
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unpack(args)\n full_path, file = args[:full_path], args[:file]\n \n # Is unpack activated?\n if self.config[:unpack][:active]\n self.files = File.directory?(full_path) ? Unpack.runner!(full_path, self.config[:unpack]) : []\n else\n self.files = []\n end\n \n if files.any?\n self.growl(self.messages[:unpack][:title], file, :unpack); return 5\n else\n return 6\n end\n end",
"def extract!(directory = nil, flags: DEFAULT_FLAGS, &block)\n raise ArgumentError, \"can't pass directory and block at the same time\" if block_given? && directory.present?\n\n if block_given?\n Dir.mktmpdir([\"danbooru-archive-\", \"-\" + File.basename(file.path)]) do |dir|\n filenames = extract_to!(dir, flags: flags)\n yield dir, filenames\n end\n else\n dir = directory.presence || Dir.mktmpdir([\"danbooru-archive-\", \"-\" + File.basename(file.path)])\n filenames = extract_to!(dir, flags: flags)\n [dir, filenames]\n end\n end",
"def unpack\n self.dir = Rails.root + 'tmp' + SecureRandom.hex(20)\n FileUtils.mkdir(dir)\n\n dirs = []\n files = []\n\n Zip::Archive.open(file_path) do |archive|\n archive.each do |file|\n next if file.name =~ /__MACOSX/ or file.name =~ /\\.DS_Store/\n destination = dir + file.name\n name = Pathname.new(file.name).cleanpath.to_s\n\n if file.directory?\n FileUtils.mkdir_p(destination)\n dirs << name\n else\n dirname = File.dirname(file.name)\n FileUtils.mkdir_p(dirname) unless File.exist?(dirname)\n open(destination, 'wb') {|f| f << file.read}\n files << name\n end\n end\n end\n\n [dirs, files]\n end",
"def unpack file_path\n name = file_path.split(@fs).last\n Dir.chdir Dir.tmpdir\n Dir.mkdir name\n Minitar.unpack(file_path, name)\n Dir.chdir name\n @temp_dir = Dir.pwd\n end",
"def unpack(src, dest, files = [], options = {}, &block)\n Input.open(src) do |inp|\n if File.exist?(dest) && !dir?(dest)\n raise \"Can't unpack to a non-directory.\"\n end\n\n FileUtils.mkdir_p(dest) unless File.exist?(dest)\n\n inp.each do |entry|\n if files.empty? || files.include?(entry.full_name)\n inp.extract_entry(dest, entry, options, &block)\n end\n end\n end\n end",
"def unpack(&bl)\n dir = nil\n pkg = ::Gem::Installer.new gem_path, :unpack => true\n\n if bl\n Dir.mktmpdir do |tmpdir|\n pkg.unpack tmpdir\n bl.call tmpdir\n end\n else\n dir = Dir.mktmpdir\n pkg.unpack dir\n end\n\n dir\n end",
"def each_file(&bl)\n unpack do |dir|\n Pathname.new(dir).find do |path|\n next if path.to_s == dir.to_s\n pathstr = path.to_s.gsub(\"#{dir}/\", '')\n bl.call pathstr unless pathstr.blank?\n end\n end\n end",
"def each_file(&bl)\n unpack do |dir|\n Pathname(dir).find do |path|\n next if path.to_s == dir.to_s\n pathstr = path.to_s.gsub(\"#{dir}/\", '')\n bl.call pathstr unless pathstr.blank?\n end\n end\n end",
"def extract\n Dir.mktmpdir do |dir|\n open_zip do |zip_file|\n zip_file.each do |entry|\n unless entry.name_is_directory?\n entry.extract(File.join(dir, File.basename(entry.name)))\n end\n end\n\n yield dir\n end\n end\n end",
"def extract\n Dir.mktmpdir do |dir|\n open_zip do |zip_file|\n zip_file.each do |entry|\n entry.extract(File.join(dir, File.basename(entry.name))) unless entry.name_is_directory?\n end\n\n yield dir\n end\n end\n end",
"def extract_pack\n io = Zlib::GzipReader.new(DataDragon.data_pack_path.open)\n\n Gem::Package::TarReader.new(io) do |tar|\n tar.each do |tarfile|\n destination_file = (DataDragon.data_unpacked_path + tarfile.full_name)\n\n if tarfile.directory?\n destination_file.mkpath\n else\n destination_directory = destination_file.dirname\n destination_directory.mkpath unless destination_directory.directory?\n destination_file.write(tarfile.read)\n end\n end\n end\n end",
"def unpack( archive, into = Dir.pwd )\n Dir.chdir( into ) do \n if archive.match( /\\.tar\\.gz\\Z/ ) or archive.match(/\\.tgz\\Z/) then\n tgz = ::Zlib::GzipReader.new( File.open( local_source, 'rb') )\n ::Archive::Tar::Minitar.unpack( tgz, into )\n elsif archive.match( /\\.gem\\Z/ ) then\n subdir = File.basename( archive, \".gem\" )\n Gem::Installer.new( archive ).unpack( subdir )\n else\n raise \"Unable to extract files from #{File.basename( local_source)} -- unknown format\"\n end\n end\n end",
"def extract_blocks(dir)\n @dir = File.expand_path(dir)\n if File.directory? @dir\n Find.find(*Dir[\"#{self.dir}/**/*.rb\"]) do |filename|\n if File.file? filename\n sexp = @rp.process(File.read(filename), filename)\n self.process(sexp)\n end\n end\n elsif File.file? @dir\n sexp = @rp.process(File.read(@dir), @dir)\n self.process(sexp)\n end\n @sexp_blocks\n end",
"def cleanup_unpack_path\n if unpack_path.exist?\n unpack_path.rmtree\n end\n end",
"def unpack_to(dir)\n sh \"cp -R #{local_path} #{dir}\"\n end",
"def unpack(file, dest)\n ::Zip::ZipFile.foreach(file) do |zentry|\n epath = \"#{dest}/#{zentry}\"\n dirname = File.dirname(epath)\n FileUtils.mkdir_p(dirname) unless File.exists?(dirname)\n zentry.extract(epath) unless File.exists?(epath)\n end\n end",
"def unzip\n file = self\n #destination = \"/\" + self.split(\"/\")[1..-2].join(\"/\") + \"/\"\n destination = self + \"_extracted_files/\"\n Zip::File.open(file) { |zip_file|\n zip_file.each { |f|\n f_path=File.join(destination, f.name)\n #puts f_path\n FileUtils.mkdir_p(File.dirname(f_path))\n FileUtils.rm f_path if File.exist?(f_path)\n zip_file.extract(f, f_path) #unless File.exist?(f_path)\n }\n }\n end",
"def unzip\n file = self\n #destination = \"/\" + self.split(\"/\")[1..-2].join(\"/\") + \"/\"\n destination = self + \"_extracted_files/\"\n Zip::ZipFile.open(file) { |zip_file|\n zip_file.each { |f|\n f_path=File.join(destination, f.name)\n #puts f_path\n FileUtils.mkdir_p(File.dirname(f_path))\n FileUtils.rm f_path if File.exist?(f_path)\n zip_file.extract(f, f_path) #unless File.exist?(f_path)\n }\n }\n end",
"def extract src_path, dst_path = File.dirname(src_path)\n src_path = File.expand_path(src_path)\n src_name = File.basename(src_path)\n src_suffix = File.extname(src_name)\n src_prefix = File.basename(src_name, src_suffix)\n\n Dir.mktmpdir(nil, dst_path) do |tmp_dir|\n # decompress the archive\n cd tmp_dir do\n case src_name.sub(/\\.part$/, '')\n when /\\.(tar\\.gz|tar\\.Z|tgz|taz)$/i\n system 'tar', '-zxf', src_path\n\n when /\\.(tar\\.bz|tar\\.bz2|tbz|tbz2)$/i\n system 'tar', '-jxf', src_path\n\n when /\\.(tar\\.xz|txz)$/i\n system 'tar', '-Jxf', src_path\n\n when /\\.(tar|cpio|gem)$/i\n system 'tar', '-xf', src_path\n\n when /\\.(tar.lzo|tzo)$/i\n system \"lzop -xc #{src_path.inspect} | tar -xf -\"\n\n when /\\.(lzo)$/i\n system 'lzop', '-x', src_path\n\n when /\\.(gz)$/i\n system \"gunzip -c #{src_path.inspect} > #{src_prefix.inspect}\"\n\n when /\\.(bz|bz2)$/i\n system \"bunzip2 -c #{src_path.inspect} > #{src_prefix.inspect}\"\n\n when /\\.(shar)$/i\n system 'sh', src_path\n\n when /\\.(7z)$/i\n system '7zr', 'x', src_path\n\n when /\\.(zip)$/i\n system 'unzip', src_path\n\n when /\\.(jar)$/i\n system 'jar', 'xf', src_path\n\n when /\\.(rz)$/i\n ln src_path, src_name # rzip removes the archive after extraction\n system 'rzip', '-d', src_name\n\n when /\\.(rar)$/i\n system 'unrar', 'x', src_path\n\n when /\\.(ace)$/i\n system 'unace', 'x', src_path\n\n when /\\.(arj)$/i\n system 'arj', 'x', src_path\n\n when /\\.(arc)$/i\n system 'arc', 'x', src_path\n\n when /\\.(lhz|lha)$/i\n system 'lha', 'x', src_path\n\n when /\\.(a|ar)$/i\n system 'ar', '-x', src_path\n\n when /\\.(Z)$/\n system \"uncompress -c #{src_path.inspect} > #{src_prefix.inspect}\"\n\n when /\\.(z)$/\n system \"pcat #{src_path.inspect} > #{src_prefix.inspect}\"\n\n when /\\.(zoo)$/i\n system 'zoo', 'x//', src_path\n\n when /\\.(cab)$/i\n system 'cabextract', src_path\n\n when /\\.(deb)$/i\n system 'ar', 'x', src_path\n\n when /\\.(rpm)$/i\n system \"rpm2cpio #{src_path.inspect} | cpio -i --make-directories\"\n\n else\n warn \"I do not know how to extract #{src_path.inspect}\"\n end\n end\n\n # clean any mess made by decompression\n manifest = Dir.new(tmp_dir).entries - %w[ . .. ]\n\n if manifest.length == 1 # there was no mess!\n adj_dst = File.join(dst_path, manifest.first)\n adj_src = File.join(tmp_dir, manifest.first)\n else\n adj_src = tmp_dir\n adj_dst = File.join(dst_path, src_name[/.*(?=\\..*?)/])\n end\n\n adj_dst << \"+#{Time.now.to_i}\" until\n not File.exist? adj_dst and\n mv(adj_src, adj_dst, :force => true)\n\n touch tmp_dir # give Dir.mktmpdir() something to remove\n\n adj_dst\n end\nend",
"def unpack(filename)\n @destination = Dir.mktmpdir\n Zip::File.open(filename){ |zip_file|\n zip_file.each{ |f|\n f_path=File.join(@destination, f.name)\n FileUtils.mkdir_p(File.dirname(f_path))\n zip_file.extract(f, f_path) unless File.exists?(f_path)\n }\n }\n end",
"def pack(src, dest, recurse_dirs = true, &block)\n require \"find\"\n Output.open(dest) do |outp|\n if src.is_a?(Array)\n src.each do |entry|\n if dir?(entry) && recurse_dirs\n Find.find(entry) do |ee|\n pack_file(ee, outp, &block)\n end\n else\n pack_file(entry, outp, &block)\n end\n end\n else\n Find.find(src) do |entry|\n pack_file(entry, outp, &block)\n end\n end\n end\n end",
"def unpack(file, path)\n require \"rubygems/package\"\n require \"securerandom\"\n\n # We are creating a random directory per extract,\n # if we dont do this bundler will not trigger download of the dependencies.\n # Use case is:\n # - User build his own gem with a fix\n # - User doesnt increment the version\n # - User install the same version but different code or dependencies multiple times..\n basename = ::File.basename(file, '.gem')\n unique = SecureRandom.hex(4)\n target_path = ::File.expand_path(::File.join(path, unique, basename))\n\n package = ::Gem::Package.new(file)\n package.extract_files(target_path)\n\n return [package, target_path]\n end",
"def download_and_uncompress(host, source_link, uncompress_to)\n # ERB Template\n installer_url = source_link\n dest_directory = uncompress_to\n directory_path = \"#{uncompress_to}/IBM\"\n\n # getting compress type\n if source_link.include? 'zip'\n compress_type = 'zip'\n elsif source_link.include? 'tar.gz'\n compress_type = 'tar.gz'\n else\n fail_test 'Only zip or tar.gz are is valid compressed file'\n end\n\n # getting group:\n if host['platform'] =~ %r{aix}\n user_group = 'system'\n elsif host['platform'] =~ %r{linux}\n user_group = 'root'\n end\n\n local_files_root_path = ENV['FILES'] || 'tests/files'\n manifest_template = File.join(local_files_root_path, 'download_uncompress_manifest.erb')\n manifest_erb = ERB.new(File.read(manifest_template)).result(binding)\n\n on(host, puppet('apply'), stdin: manifest_erb, exceptable_exit_codes: [0, 2]) do |result|\n assert_no_match(%r{Error}, result.output, 'Failed to download and/or uncompress')\n end\nend",
"def unpack_slice!\n app_slice_root = app_dir_for(:root)\n copied, duplicated = [], []\n Dir.glob(self.root / \"**/*\").each do |source|\n relative_path = source.relative_path_from(root)\n mirror_file(source, app_slice_root / relative_path, copied, duplicated) if unpack_file?(relative_path)\n end\n public_copied, public_duplicated = mirror_public!\n [copied + public_copied, duplicated + public_duplicated]\n end",
"def pack directory_path\n Dir.chdir directory_path\n name = Dir.pwd.split(@fs).last\n files = Dir.glob \"**#{@fs}*\"\n File.open([name, @ext].join(\".\"), \"wb\") do |tar|\n Minitar.pack(files, tar)\n end\n end",
"def mount\n res = true\n return :not_archive unless has_archive_extension?\n return if extract_in_progress?\n\n extract_in_progress!\n pn = Pathname.new(mounted_path)\n Dir.rmdir mounted_path if pn.exist? && pn.empty?\n return :non_empty_dir_already_exists if pn.exist?\n\n unless NfsStore::Manage::Group.group_id_range.include?(stored_file.current_gid)\n extract_failed!\n raise FsException::Filesystem,\n \"Current group specificed in stored archive file is invalid: #{stored_file.current_gid}\"\n end\n\n tpn = Pathname.new(temp_mounted_path)\n FileUtils.rm_rf temp_mounted_path if tpn.exist?\n dir = File.join(Manage::Filesystem.temp_directory, \"__filestore__#{SecureRandom.hex}\")\n FileUtils.mkdir_p dir\n\n tmpzipdir = \"#{dir}/zip\"\n FileUtils.mkdir_p tmpzipdir\n\n cmd = ['app-scripts/extract_archive.sh', archive_path, tmpzipdir]\n res = Kernel.system(*cmd)\n unless res\n extract_failed!\n puts \"Failed to unzip the archive file: #{archive_path}\"\n raise FsException::Action, \"Failed to unzip the archive file: #{archive_path}\"\n end\n\n FileUtils.chown_R nil, stored_file.current_gid.to_i, tmpzipdir\n FileUtils.cp_r tmpzipdir, temp_mounted_path\n\n begin\n FileUtils.mv temp_mounted_path, mounted_path\n FileUtils.rm_rf dir\n rescue StandardError => e\n extract_failed!\n begin\n FileUtils.rm_rf temp_mounted_path\n FileUtils.rm_rf mounted_path\n rescue StandardError => e2\n raise FsException::Action,\n \"Failed to move the extracted archive files and remove the mounted path for: #{archive_path}\\n\" \\\n \"#{e}\\n#{e2}\"\n end\n raise FsException::Action, \"Failed to move the extracted archive files: #{archive_path}\\n#{e}\"\n end\n\n extract_completed! if res\n res\n end",
"def extract(file, dir_or_buffer_size = DEFAULT_BUFFER_SIZE)\n\n if block_given?\n buffer_size = dir_or_buffer_size\n\n if (buffer_size.fdiv(DEFAULT_BUFFER_SIZE).modulo(1) != 0)\n raise ArgumentError, \n 'Buffer_size must be a multiple of DEFAULT_BUFFER_SIZE'\n end\n\n a = 0\n b = 0\n did_yield = false\n buffer = \"\\0\" * buffer_size\n\n extract_to_path(file) do |data|\n did_yield = false\n b = a + data.length - 1\n buffer[a..b] = data\n\n # full buffer - yield and reset\n if b + 1 == buffer_size \n yield buffer[0..b]\n did_yield = true\n a = 0\n\n # last read if it's less than default size\n elsif data.length > 0 && data.length < DEFAULT_BUFFER_SIZE\n yield buffer[0..b]\n did_yield = true\n \n else\n a = b + 1\n end\n end\n\n # last read happened to be default size\n yield buffer[0..b] if !did_yield && b > 0\n\n else\n path = Mspack.ensure_path(file.filename, dir_or_buffer_size)\n extract_to_path(file, path)\n return path\n end\n end",
"def stage_unzipped(zipfile, stage_dir)\n # Unzip file to a specified directory\n Dir.mkdir stage_dir unless Dir.exist?(stage_dir)\n Zip::File.open(zipfile) do |z|\n z.each do |f|\n extract_path = File.join(stage_dir, f.name)\n z.extract(f, extract_path) unless File.exist?(extract_path)\n end\n end\nend",
"def run_dir(root)\n\tDir.foreach(root) { |fn|\n\t\tnext if fn == \".\" || fn == \"..\"\n\t\tcombined = File.join(root, fn)\n\t\tif File.directory?(combined)\n\t\t\trun_dir(combined)\n\t\telsif File.file?(combined) && (fn[\".dll\"] || fn[\".pdb\"])\n\t\t\tfpath = combined\n\t\t\tfpath = fpath[2..-1] if fpath[0..1] == \"./\"\n\t\t\tfpath = fpath.gsub(\"/\", \"\\\\\")\n\t\t\tprint(\"#{fpath}\\n\")\n\t\t\t`compress -R #{fpath}`\n\t\t\texit(1) if $?.exitstatus != 0\n\t\t\t`del #{fpath}`\n\t\tend\n\t}\t\nend",
"def extract_from_archive(archive_path, destination_path, pattern=/.*/, &block)\n read_from_archive(archive_path, pattern) do |tarfile|\n destination_file = File.join(destination_path, tarfile.full_name)\n\n if tarfile.directory?\n FileUtils.mkdir_p(destination_file)\n else\n destination_directory = File.dirname(destination_file)\n FileUtils.mkdir_p(destination_directory) unless File.directory?(destination_directory)\n File.open(destination_file, \"wb\") do |f|\n f.write(tarfile.read)\n end\n end\n end\n\n if block_given? && File.exist?(destination_path)\n yield\n FileUtils.rm_rf(destination_path, :secure => true)\n return nil\n else\n return destination_path\n end\n end",
"def inspect_unpacked_dir(directory, metadata, _identifier)\n dir = Dir.new directory\n counter = 0\n files = dir['*']\n files.each do |file|\n file_format = format(\"#{directory}/#{file}\")\n if KNOWN_IMAGE_FORMATS.include? file_format\n counter += 1\n # unsupported ova content (more than one disk)\n return nil if counter > 1\n File.new(\"#{directory}/#{file}\", 'r').rename(file, \"#{metadata.dc_identifier}\")\n end\n end\n return nil if counter == 0\n\n file_format\n end",
"def extract(entry, dest_path, &block); end",
"def untar(file_to_untar,\n directory_for_untar)\n Log.log_debug('Into untar file_to_untar=' + file_to_untar +\n ' directory_for_untar=' + directory_for_untar)\n returned = []\n begin\n command_output = []\n command = \"/bin/tar -tf #{file_to_untar} | /bin/grep epkg.Z$\"\n Utils.execute2(command, command_output)\n untarred_files_array = command_output[0].split(\"\\n\")\n untarred_files = Utils.string_separated(untarred_files_array,\n ' ')\n #\n cmd = \"/bin/tar -xf #{file_to_untar} \\\n-C #{directory_for_untar} #{untarred_files}\"\n Utils.execute(cmd)\n #\n untarred_files_array.each do |untarred_file|\n absolute_untarred_file =\n ::File.join(directory_for_untar,\n untarred_file)\n returned << absolute_untarred_file\n end\n rescue StandardError => e\n Log.log_err('Exception e=' + e.to_s)\n if e.message =~ /No space left on device/\n Flrtvc.increase_filesystem(directory_for_untar)\n returned = untar(file_to_untar, directory_for_untar)\n else\n Log.log_warning(\"Propagating exception of type '#{e.class}' \\\nwhen untarring!\")\n raise e\n end\n rescue StandardError => e\n Log.log_err('Exception e=' + e.to_s)\n Log.log_warning(\"Propagating exception of type '#{e.class}' \\\nwhen untarring!\")\n raise e\n end\n Log.log_debug('Into untar returned=' + returned.to_s)\n returned\n end",
"def collect\n return if stat.ftype == \"directory\"\n self\n end",
"def extract(from, to)\n raise \"#{from} does not exist.\" unless @file_sys.exists? from\n raise \"#{from} is not a directory.\" unless @file_sys.is_dir? from\n\n dirs = @file_sys.get_subdirs from\n files = @file_sys.get_files from\n\n @file_sys.mkdir to\n\n files.select { |file| file.end_with? '.rb' }.\n each { |file| strip_file(\"#{from}/#{file}\", to) }\n\n dirs.each { |dir| extract(\"#{from}/#{dir}\", \"#{to}/#{dir}\") }\n end",
"def download_and_unpack_archive(uri, root)\n # all file types filtered here should be handled inside block.\n if uri.end_with?('.tgz', '.tar.gz', '.zip', 'jar')\n if uri.include? '://'\n print \"-----> Downloading from #{uri} ... \"\n else\n filename = File.basename(uri)\n print \"-----> Retrieving #{filename} ... \"\n end\n download_start_time = Time.now\n LibertyBuildpack::Util::Cache::ApplicationCache.new.get(uri) do |file|\n puts \"(#{(Time.now - download_start_time).duration})\"\n install_archive(file, uri, root)\n end\n else\n # shouldn't happen, expect index.yml or component_index.yml to always\n # name files that can be handled here.\n puts \"Unknown file type, not downloaded, at #{uri}\"\n end\n end",
"def unarchive\n unless in_zip?\n zips, gzs = selected_items.partition(&:zip?).tap {|z, others| break [z, *others.partition(&:gz?)]}\n zips.each do |item|\n FileUtils.mkdir_p current_dir.join(item.basename)\n Zip::File.open(item) do |zip|\n zip.each do |entry|\n FileUtils.mkdir_p File.join(item.basename, File.dirname(entry.to_s))\n zip.extract(entry, File.join(item.basename, entry.to_s)) { true }\n end\n end\n end\n gzs.each do |item|\n Zlib::GzipReader.open(item) do |gz|\n Gem::Package::TarReader.new(gz) do |tar|\n dest_dir = current_dir.join (gz.orig_name || item.basename).sub(/\\.tar$/, '')\n tar.each do |entry|\n dest = nil\n if entry.full_name == '././@LongLink'\n dest = File.join dest_dir, entry.read.strip\n next\n end\n dest ||= File.join dest_dir, entry.full_name\n if entry.directory?\n FileUtils.mkdir_p dest, mode: entry.header.mode\n elsif entry.file?\n FileUtils.mkdir_p dest_dir\n File.open(dest, 'wb') {|f| f.print entry.read}\n FileUtils.chmod entry.header.mode, dest\n elsif entry.header.typeflag == '2' # symlink\n File.symlink entry.header.linkname, dest\n end\n unless Dir.exist? dest_dir\n FileUtils.mkdir_p dest_dir\n File.open(File.join(dest_dir, gz.orig_name || item.basename), 'wb') {|f| f.print gz.read}\n end\n end\n end\n end\n end\n else\n Zip::File.open(current_zip) do |zip|\n zip.select {|e| selected_items.map(&:name).include? e.to_s}.each do |entry|\n FileUtils.mkdir_p File.join(current_zip.dir, current_zip.basename, File.dirname(entry.to_s))\n zip.extract(entry, File.join(current_zip.dir, current_zip.basename, entry.to_s)) { true }\n end\n end\n end\n ls\n end",
"def unpack(target_dir)\n file = File.open(cache_path, 'rb')\n reader = Zlib::GzipReader.new(file)\n begin\n Minitar.unpack(reader, target_dir)\n ensure\n reader.close\n end\n end",
"def extract_files\n while file = @package_file.next_header\n if file.pathname == \"control.tar.gz\"\n control_tar_gz = Archive.read_open_memory(@package_file.read_data)\n while control_entry = control_tar_gz.next_header\n case control_entry.pathname\n when \"./control\"\n @control_file_contents = control_tar_gz.read_data\n when \"./preinst\"\n @preinst_contents = control_tar_gz.read_data\n when \"./prerm\"\n @prerm_contents = control_tar_gz.read_data\n when \"./postinst\"\n @postinst_contents = control_tar_gz.read_data\n when \"./postrm\"\n @postrm_contents = control_tar_gz.read_data\n end\n end\n end\n if file.pathname == \"data.tar.gz\"\n data_tar_gz = Archive.read_open_memory(@package_file.read_data)\n while data_entry = data_tar_gz.next_header\n # Skip dirs; they're listed with a / as the last character\n @filelist << data_entry.pathname.sub(/^\\./, \"\") unless data_entry.pathname =~ /\\/$/\n end\n end\n end\n end",
"def unpack\n `rm -rf ./tmp/specs`\n `gunzip -f ./tmp/specs.tar.gz`\n `cd tmp; tar xvf specs.tar`\n `mv -f ./tmp/CocoaPods-Specs-* ./tmp/specs`\n end",
"def pull_dir(localpath, remotepath, options = {}, &block)\n connect! unless @connection\n @recursion_level += 1\n\n todelete = Dir.glob(File.join(localpath, '*'))\n \n tocopy = []\n recurse = []\n\n # To trigger error if path doesnt exist since list will\n # just return and empty array\n @connection.chdir(remotepath)\n\n @connection.list(remotepath) do |e|\n entry = Net::FTP::List.parse(e)\n \n paths = [ File.join(localpath, entry.basename), \"#{remotepath}/#{entry.basename}\".gsub(/\\/+/, '/') ]\n\n if entry.dir?\n recurse << paths\n elsif entry.file?\n if options[:since] == :src\n tocopy << paths unless File.exist?(paths[0]) and entry.mtime < File.mtime(paths[0]) and entry.filesize == File.size(paths[0])\n elsif options[:since].is_a?(Time)\n tocopy << paths unless entry.mtime < options[:since] and File.exist?(paths[0]) and entry.filesize == File.size(paths[0])\n else\n tocopy << paths\n end\n end\n todelete.delete paths[0]\n end\n \n tocopy.each do |paths|\n localfile, remotefile = paths\n unless should_ignore?(localfile)\n begin\n @connection.get(remotefile, localfile)\n log \"Pulled file #{remotefile}\"\n rescue Net::FTPPermError\n log \"ERROR READING #{remotefile}\"\n raise Net::FTPPermError unless options[:skip_errors]\n end\n end\n end\n \n recurse.each do |paths|\n localdir, remotedir = paths\n Dir.mkdir(localdir) unless File.exist?(localdir)\n pull_dir(localdir, remotedir, options, &block)\n end\n \n if options[:delete]\n todelete.each do |p|\n block_given? ? yield(p) : FileUtils.rm_rf(p)\n log \"Removed path #{p}\"\n end\n end\n \n @recursion_level -= 1\n close! if @recursion_level == 0\n rescue Net::FTPPermError\n close!\n raise Net::FTPPermError\n end",
"def unzip( fn, dest )\n Zip::ZipFile.open fn do |z|\n z.each do |f|\n fpath = File.join dest, f.name\n FileUtils.mkdir_p File.dirname fpath \n z.extract( f, fpath ) unless File.exist? fpath\n end\n end\nend",
"def unzip_file(destination)\n ensure_file_open!\n @file.each do |entry|\n entry_path = File.join(destination, entry.name)\n FileUtils.mkdir_p(File.dirname(entry_path))\n @file.extract(entry, entry_path) unless File.exist?(entry_path)\n end\n end",
"def within_folder dir_name, block\n Dir.chdir(dir_name) do |dir_name|\n # Pass the dir name back to the caller\n block.call dir_name\n end\nend",
"def unzip_file (file, destination)\n Zip::ZipFile.open(file) { |zip_file|\n zip_file.each { |f|\n f_path=File.join(destination, f.name)\n FileUtils.mkdir_p(File.dirname(f_path))\n zip_file.extract(f, f_path) unless File.exist?(f_path)\n }\n }\nend",
"def unzip(x)\r\n outdir = x.sub(/.*\\//, '')\r\n outdir = '.' if outdir == \"\"\r\n Zip::ZipFile::open(x) { |zf|\r\n zf.each { |e|\r\n fpath = File.join(outdir, e.name)\r\n FileUtils.mkdir_p(File.dirname(fpath))\r\n zf.extract(e, fpath)\r\n }\r\n }\r\nend",
"def unpack\n trace :debug, \"Build: apktool extract: #{@tmpdir}/apk\"\n\n apktool = path('apktool.jar')\n\n Dir[path('core.*.apk')].each do |d|\n version = d.scan(/core.android.(.*).apk/).flatten.first\n\n if version == \"melt\" then\n trace :debug, \"-jar #{apktool} d -f #{d} -o #{@tmpdir}/apk.#{version}\"\n #CrossPlatform.exec \"java\", \"-jar #{apktool} if #{@tmpdir}/jelly.apk jelly\"\n CrossPlatform.exec \"java\", \"-jar #{apktool} d -f #{d} -o #{@tmpdir}/apk.#{version}\"\n else\n trace :debug, \"-jar #{apktool} d -f -s -r #{d} -o #{@tmpdir}/apk.#{version}\"\n CrossPlatform.exec \"java\", \"-jar #{apktool} d -f -s -r #{d} -o #{@tmpdir}/apk.#{version}\"\n end\n\n [\"rb.data\", \"cb.data\"].each do |asset|\n CrossPlatform.exec \"pwd\",\"\"\n exists = File.exist?(path(\"apk.#{version}/assets/#{asset}\"))\n trace :debug, \"check #{@tmpdir}/apk.#{version}/assets/#{asset} #{exists}\" \n\n raise \"unpack failed. needed asset #{asset} not found\" unless File.exist?(path(\"apk.#{version}/assets/#{asset}\"))\n end\n\n end\nend",
"def extract_to!(directory, flags: DEFAULT_FLAGS)\n each_entry.map do |entry|\n raise Danbooru::Archive::Error, \"Can't extract archive containing absolute path (path: '#{entry.pathname_utf8}')\" if entry.pathname_utf8.starts_with?(\"/\")\n raise Danbooru::Archive::Error, \"'#{entry.pathname_utf8}' is not a regular file\" if !entry.file?\n\n path = \"#{directory}/#{entry.pathname_utf8}\"\n entry.extract!(path, flags: flags)\n end\n end",
"def extract\n for file_path in @files\n if !File.directory?(file_path)\n if file_path.downcase.index('.7zip') || file_path.downcase.index('.7z') || file_path.downcase.index('.zip')\n extension = '7zip' if file_path.downcase.index('.7zip')\n extension = '7z' if file_path.downcase.index('.7z')\n extension = 'zip' if file_path.downcase.index('.zip')\n cmd = \"7za e -o#{@dir} #{file_path}\"\n #puts \"Extracting #{file_path}: #{cmd}\"\n system(cmd)\n if cmd\n if file_path.downcase.index('att')\n file_name = File.join(@dir, \"attendance_ads_#{Time.now.year}_#{Time.now.month}_#{Time.now.day}.#{extension}\")\n elsif file_path.downcase.index('enroll')\n file_name = File.join(@dir, \"enrollment_ads_#{Time.now.year}_#{Time.now.month}_#{Time.now.day}.#{extension}\")\n elsif file_path.downcase.index('ili') || file_path.downcase.index('h1n1')\n file_name = File.join(@dir, \"ili_ads_#{Time.now.year}_#{Time.now.month}_#{Time.now.day}.#{extension}\")\n else\n file_name = File.join(@dir, \"ads_#{Time.now.year}_#{Time.now.month}_#{Time.now.day}.#{extension}\")\n end\n File.rename(file_path, file_name)\n FileUtils.mv(file_name, File.join(@dir, \"archive\"))\n end\n end\n end\n end\n\n end",
"def unpack_zip_entry entry, destination, clobber\n # Ensure hidden mac files don't get written to disk:\n path = File.join destination, entry.name\n\n if entry.directory?\n # If an archive has empty directories:\n FileUtils.mkdir_p path\n elsif entry.file?\n # On Windows, we don't get the entry for\n # each parent directory:\n FileUtils.mkdir_p File.dirname(path)\n begin\n entry.extract path\n rescue Zip::ZipDestinationFileExistsError => zip_dest_error\n if(clobber == :clobber)\n FileUtils.rm_rf path\n entry.extract path\n else\n raise Sprout::Errors::DestinationExistsError.new zip_dest_error.message\n end\n end\n end\n end",
"def unzip_entries(zipfile, destination, &block)\n SevenZipRuby::Reader.open(zipfile, password: @password) do |szr|\n szr.entries.each do |entry|\n # SECURE: TPG 2018-11-21: The path is stripped from the zipfile entry when extracted\n basename = ::File.basename(entry.path)\n next unless entry.file? && basename.match(@pattern)\n\n unzipped_filename = destination.join(basename)\n szr.extract([entry], unzipped_filename)\n\n unzipped_files(unzipped_filename, &block)\n end\n end\n end",
"def unpack_dmg(dmg_file, dir)\r\n # 1) Mount the dmg in place\r\n # 2) Recursively Copy it's contents to asproject_home\r\n # 3) Unmount the dmg\r\n if(mounted_path.nil?)\r\n raise StandardError.new('DMG file downloaded, but the RemoteFileTask needs a mounted_path in order to mount it')\r\n end\r\n\r\n if(!File.exists?(full_mounted_path))\r\n system(\"hdiutil mount #{dmg_file}\")\r\n end\r\n \r\n begin\r\n mounted_target = File.join(full_mounted_path, extracted_file)\r\n \r\n # Copy the DMG contents using system copy rather than ruby utils\r\n # Because OS X does something special with .app files that the\r\n # Ruby FileUtils and File classes break...\r\n puts '=================='\r\n from = mounted_target\r\n# from = File.join(full_mounted_path, extracted_file)\r\n to = File.join(@user.downloads, @name.to_s, extracted_file)\r\n puts 'from: ' + from\r\n puts 'to: ' + to\r\n FileUtils.makedirs(File.dirname(to))\r\n \r\n if(File.exists?(from))\r\n `ditto '#{from}' '#{to}'`\r\n end\r\n rescue\r\n puts 'inside finally!'\r\n if(File.exists?(full_mounted_path))\r\n puts 'unmounting now!'\r\n system(\"hdiutil unmount -force \\\"#{full_mounted_path}\\\"\")\r\n end\r\n end\r\n end",
"def each_directory(&block)\n @directories.each(&block)\n end",
"def unzip(file, destination)\n FileUtils.mkdir_p(destination)\n\n Zip::File.open(file) do |zip_file|\n zip_file.each do |f|\n fpath = File.join(destination, f.name)\n zip_file.extract(f, fpath) unless File.exist?(fpath)\n end\n end\nend",
"def extract_entry(destdir, entry) # :yields action, name, stats:\n stats = {\n :current => 0,\n :currinc => 0,\n :entry => entry\n }\n\n if entry.directory?\n dest = File.join(destdir, entry.full_name)\n\n yield :dir, entry.full_name, stats if block_given?\n\n if Archive::Tar::Minitar.dir?(dest)\n begin\n FileUtils.chmod(entry.mode, dest)\n rescue Exception\n nil\n end\n else\n FileUtils.mkdir_p(dest, :mode => entry.mode)\n FileUtils.chmod(entry.mode, dest)\n end\n\n fsync_dir(dest)\n fsync_dir(File.join(dest, \"..\"))\n return\n else # it's a file\n destdir = File.join(destdir, File.dirname(entry.full_name))\n FileUtils.mkdir_p(destdir, :mode => 0755)\n\n destfile = File.join(destdir, File.basename(entry.full_name))\n FileUtils.chmod(0600, destfile) rescue nil # Errno::ENOENT\n\n yield :file_start, entry.full_name, stats if block_given?\n\n File.open(destfile, \"wb\", entry.mode) do |os|\n loop do\n data = entry.read(4096)\n break unless data\n\n stats[:currinc] = os.write(data)\n stats[:current] += stats[:currinc]\n\n yield :file_progress, entry.full_name, stats if block_given?\n end\n os.fsync\n end\n\n FileUtils.chmod(entry.mode, destfile)\n fsync_dir(File.dirname(destfile))\n fsync_dir(File.join(File.dirname(destfile), \"..\"))\n\n yield :file_done, entry.full_name, stats if block_given?\n end\n end",
"def unpack_repo(command, path)\n destination = iso_location\n remove_directory(iso_location)\n destination.mkpath # in case it didn't already exist\n Archive.extract(path, destination) if path\n self.publish('release_temporary_repo', command)\n end",
"def cleanup_extract_source(attrs={})\n\n execute \"cleanup_source\" do\n cwd Chef::Config[:file_cache_path]\n command \"rm -rf #{attrs['src_dir']}\"\n not_if do ! FileTest.directory?(attrs['src_dir']) end\n action :run\n end\n\n extract_flags = \"tar zxf\" if attrs['src_file'] =~ /tar\\.gz/\n extract_flags = \"tar jxf\" if attrs['src_file'] =~ /tar\\.bz2/\n extract_flags = \"7za x\" if attrs['src_file'] =~ /7z/\n\n execute \"extract_source\" do\n cwd Chef::Config[:file_cache_path]\n command \"#{extract_flags} #{Chef::Config[:file_cache_path]}/#{attrs['src_file']}\"\n action :run\n end\n\nend",
"def generate_ansible_files\n \n # Helper to decide whether or not to generate/update a given file\n update = Proc.new do |fn, mtime|\n !(File.exists?(fn) && File.stat(fn).mtime >= mtime)\n true\n end\n\n Dir.glob('./templates/ansible.*').each do |template|\n\n # Get a template's last modified date\n source_mtime = File.stat(template).mtime \n\n # Get a destination's potential file name & path \n target_file = File.basename(template).split('.').slice(1...-1).join('.') \n target_paths = target_file.start_with?('inventory') ? ['inventory/'] : ['', 'plays/*/']\n\n # Walk destination path(s)\n target_paths.each do |target_path|\n \n Dir.glob(\"./ansible/#{target_path}\").each do |path|\n\n # Build a potential real path\n fn = File.join(File.expand_path(path), target_file) \n\n # Yield source (template file) & target if the target needs to be generated/updated\n yield template, fn if update.call(fn, source_mtime) && block_given?\n end\n end\n end\nend",
"def extract\n case @download\n when /\\.tar/ then untar\n when /\\.gz\\z/ then gunzip\n end\n end",
"def decompress_package(package)\n @logger.info \"Decompressing #{package.path}\\nto #{@target_location}\"\n FileUtils.mkdir_p(@target_location)\n Dir.chdir(@target_location) do\n # Clear out existing package\n FileUtils.rm_rf Dir.glob(\"#{@target_location}/*\")\n RakeUtils.system \"tar -zxf #{package.path}\"\n end\n @logger.info \"Decompressed\"\n end",
"def extract\n # Only used by tar\n compression_switch = \"\"\n compression_switch = \"z\" if downloaded_file.end_with?(\"gz\")\n compression_switch = \"--lzma -\" if downloaded_file.end_with?(\"lzma\")\n compression_switch = \"j\" if downloaded_file.end_with?(\"bz2\")\n compression_switch = \"J\" if downloaded_file.end_with?(\"xz\")\n\n if Ohai[\"platform\"] == \"windows\"\n if downloaded_file.end_with?(*TAR_EXTENSIONS) && source[:extract] != :seven_zip\n returns = [0]\n returns << 1 if source[:extract] == :lax_tar\n\n shellout!(\"tar #{compression_switch}xf #{downloaded_file} --force-local -C#{project_dir}\", returns: returns)\n elsif downloaded_file.end_with?(*COMPRESSED_TAR_EXTENSIONS)\n Dir.mktmpdir do |temp_dir|\n log.debug(log_key) { \"Temporarily extracting `#{safe_downloaded_file}' to `#{temp_dir}'\" }\n\n shellout!(\"7z.exe x #{safe_downloaded_file} -o#{windows_safe_path(temp_dir)} -r -y\")\n\n fname = File.basename(downloaded_file, File.extname(downloaded_file))\n fname << \".tar\" if downloaded_file.end_with?(\"tgz\", \"txz\")\n next_file = windows_safe_path(File.join(temp_dir, fname))\n\n log.debug(log_key) { \"Temporarily extracting `#{next_file}' to `#{safe_project_dir}'\" }\n shellout!(\"7z.exe x #{next_file} -o#{safe_project_dir} -r -y\")\n end\n else\n shellout!(\"7z.exe x #{safe_downloaded_file} -o#{safe_project_dir} -r -y\")\n end\n elsif downloaded_file.end_with?(\".7z\")\n shellout!(\"7z x #{safe_downloaded_file} -o#{safe_project_dir} -r -y\")\n elsif downloaded_file.end_with?(\".zip\")\n shellout!(\"unzip #{safe_downloaded_file} -d #{safe_project_dir}\")\n else\n shellout!(\"#{tar} #{compression_switch}xf #{safe_downloaded_file} -C#{safe_project_dir}\")\n end\n end",
"def pop_dir\n # the first time we pop, we need to put the current on stack\n if !$visited_dirs.index(Dir.pwd)\n $visited_dirs.push Dir.pwd\n end\n ## XXX make sure thre is something to pop\n d = $visited_dirs.delete_at 0\n ## XXX make sure the dir exists, cuold have been deleted. can be an error or crash otherwise\n $visited_dirs.push d\n Dir.chdir d\n $files = `zsh -c 'print -rl -- *(#{$sorto}#{$hidden}M)'`.split(\"\\n\")\n $patt=nil\nend",
"def pop_dir\n return # 2014-07-25 - 22:43 \n # the first time we pop, we need to put the current on stack\n if !$visited_dirs.index(Dir.pwd)\n $visited_dirs.push Dir.pwd\n end\n ## XXX make sure thre is something to pop\n d = $visited_dirs.delete_at 0\n ## XXX make sure the dir exists, cuold have been deleted. can be an error or crash otherwise\n $visited_dirs.push d\n Dir.chdir d\n $filterstr ||= \"M\"\n $files = `zsh -c 'print -rl -- *(#{$sorto}#{$hidden}#{$filterstr})'`.split(\"\\n\")\n post_cd\nend",
"def decompress_files(compressed_files=[], dir = decompressed_spool_dir )\n\n files = []\n\n compressed_files.each do |file|\n Zip::Archive.open(file) do |ar|\n ar.each do |zf|\n if zf.directory?\n FileUtils.mkdir_p(zf.name)\n else\n dirname = File.dirname(zf.name)\n FileUtils.mkdir_p(dirname) unless File.exist?(dirname)\n output_file = File.join(dir, zf.name)\n open(output_file, 'wb') do |f|\n f << zf.read\n end\n files << output_file\n end\n end\n end\n # TODO: Delete processed file\n end\n\n files\n end",
"def dir_contents(path, &b)\n path = Pathname.new(path).cleanpath\n if fs.directory?(path)\n entries = fs.entries(path).map do |entry|\n entry_path = path + entry\n if fs.directory?(entry_path)\n dir_item(entry)\n else\n file_item(entry, fs.get_size(entry_path))\n end\n end\n yield entries\n else\n yield Set.new\n end\n end",
"def extract (file = nil)\n export_path = archive.path.gsub('.zip', '_content')\n\n Zip::ZipFile.open(file.path) { |zip_file|\n zip_file.each { |image|\n image_path = File.join(export_path, image.name)\n FileUtils.mkdir_p(File.dirname(image_path))\n unless File.exist?(image_path)\n zip_file.extract(image, image_path)\n photo = photos.build\n photo.image = File.open(image_path)\n photo.save\n File.delete(image_path)\n end\n }\n }\n # clean up source files, but leave the zip\n FileUtils.remove_dir(export_path)\n end",
"def unpack_zip_on_darwin archive, destination, clobber\n # Unzipping on OS X\n FileUtils.makedirs destination\n zip_dir = File.expand_path File.dirname(archive)\n zip_name = File.basename archive\n output = File.expand_path destination\n # puts \">> zip_dir: #{zip_dir} zip_name: #{zip_name} output: #{output}\"\n %x(cd #{zip_dir};unzip #{zip_name} -d #{output})\n end",
"def resolve_files(file_or_dir_path, options = {}, &block)\n options = {\n # Set to :template when calling to consider references to template\n # files from an import library\n import: false\n }.merge(options)\n [file_or_dir_path].flatten.each do |file_or_dir_path|\n path = inject_import_path(file_or_dir_path, type: options[:import]) if options[:import]\n path = clean_path_to(file_or_dir_path, options)\n self.base_directory = path unless options[:internal_call]\n if path.directory?\n Dir.glob(\"#{path}/*\").sort.each do |file|\n resolve_files(file, { internal_call: true }.merge(options), &block)\n end\n else\n # Ignore files with the given prefix if supplied, but only if this is a file that\n # has been found, if explicitly asked to compile a file from the caller do it regardless\n if options[:ignore_with_prefix] && options[:internal_call]\n return nil if path.basename.to_s =~ /^#{options[:ignore_with_prefix]}/\n end\n yield path\n end\n end\n end",
"def download_zip(target_directory, strip_top_level_directory = true, description = @component_name)\n download(description) do |file|\n expand_start_time = Time.now\n print \" Expanding #{description} to #{target_directory} \"\n\n FileUtils.rm_rf target_directory\n FileUtils.mkdir_p File.dirname(target_directory)\n\n if strip_top_level_directory\n Dir.mktmpdir do |root|\n shell \"unzip -qq #{file.path} -d #{root} 2>&1\"\n FileUtils.mv Dir[root + '/*'][0], target_directory\n end\n else\n shell \"unzip -qq #{file.path} -d #{target_directory} 2>&1\"\n end\n\n puts \"(#{(Time.now - expand_start_time).duration})\"\n end\n end",
"def extract\n base.say_status 'extract', @file\n if @zip_file\n base.exec(\"cd #{@temp_dir} ; unzip #{@file}\")\n else\n base.exec(\"cd #{@temp_dir} ; tar xvfpz #{@file}\")\n end\n \n # Remove the file\n base.destination_files.rm_rf(@file_path)\n end",
"def pack(directory, name=nil)\n tmp_file = Tempfile.new(name || File.basename(directory))\n file_path = \"#{tmp_file.path}.zip\"\n tmp_file.delete\n entries = Hash[\n Dir.glob(File.join(directory, '**', '{*,.*}')).map do |path|\n next if path.end_with?('.')\n [path.sub(%r{#{Regexp.escape(directory)}/?}, ''), path]\n end\n ]\n Zip::File.open(file_path, Zip::File::CREATE) do |zipfile|\n entries.keys.sort.each do |entry|\n path = entries[entry]\n if(File.directory?(path))\n zipfile.mkdir(entry.dup)\n else\n zipfile.add(entry, path)\n end\n end\n end\n file = File.open(file_path, 'rb')\n file\n end",
"def unzip_package(zip_file)\n @log.info 'Unzipping ' + zip_file\n\n unless File.exist?(zip_file)\n @log.error zip_file + ' not found.'\n return nil\n end\n\n # create a new directory\n file_dir = File.join(@output_dir, File.basename(zip_file, '.zip'))\n Dir.mkdir file_dir unless Dir.exist?(file_dir)\n\n # extract contents of zip file\n Zip::File.open(zip_file) do |zipfile|\n zipfile.each do |f|\n fpath = File.join(file_dir, f.name)\n zipfile.extract(f, fpath) unless File.exist?(fpath)\n end\n end\n\n file_dir\nend",
"def unpack_using_seven_zip(tmpdir)\n if new_resource.absolute_path =~ /\\.t(ar\\.)?(gz|bz(2)?|xz)$/\n # 7-Zip doesn't know to unpack both levels of the archive on its own\n # so we need to handle this more explicitly.\n shell_out!(\"#{seven_zip_home}\\\\7z.exe x -so \\\"#{windows_path(new_resource.absolute_path)}\\\" | #{seven_zip_home}\\\\7z.exe x -si -ttar -o\\\"#{windows_path(tmpdir)}\\\"\")\n else\n shell_out!(\"#{seven_zip_home}\\\\7z.exe x -o\\\"#{windows_path(tmpdir)}\\\" \\\"#{windows_path(new_resource.absolute_path)}\\\"\")\n end\n end",
"def glob_to_directory(glob); end",
"def files_to_pack(dir)\n Dir.glob(\"#{dir}/**/*\", File::FNM_DOTMATCH).select do |f|\n File.exists?(f) &&\n PACK_EXCLUSION_GLOBS.none? do |e|\n File.fnmatch(e, File.basename(f))\n end\n end\n end",
"def unzipped_files(unzipped_filename)\n Registry.files(unzipped_filename, @options).each do |filename|\n yield(filename)\n end\n end",
"def each(&block)\n files.each(&block)\n\n directories.each do |subdirectory|\n block.call(subdirectory)\n\n subdirectory.each(&block)\n end\n end",
"def pop_dir\n # the first time we pop, we need to put the current on stack\n if !$visited_dirs.index(Dir.pwd)\n $visited_dirs.push Dir.pwd\n end\n ## XXX make sure thre is something to pop\n d = $visited_dirs.delete_at 0\n ## XXX make sure the dir exists, cuold have been deleted. can be an error or crash otherwise\n $visited_dirs.push d\n Dir.chdir d\n display_dir\n\n return\n # old stuff with zsh\n $filterstr ||= \"M\"\n $files = `zsh -c 'print -rl -- *(#{$sorto}#{$hidden}#{$filterstr})'`.split(\"\\n\")\n post_cd\nend",
"def imagepipeline\n # delete non-image files\n images = Dir.entries(@from_dir).delete_if do |file|\n (file =~ /\\w+\\.(jpg|jpeg)/) == nil\n end\n images.each do |file|\n yield File.join(@from_dir,file), File.join(@to_dir,file)\n end\n end",
"def update_files(&block)\n \n get_template_entries.each do |entry|\n \n next if entry.directory?\n \n entry.get_input_stream do |is|\n \n data = is.sysread\n \n if CONTENT_FILES.include?(entry.name)\n process_entry(data, &block)\n end\n \n @output_stream.put_next_entry(entry.name)\n @output_stream.write data\n \n end\n end\n end",
"def gather\n if File.exist?(@location_dir) && File.directory?(@location_dir)\n if Dir.glob(File.join(@location_dir, '*')).size > 0 # avoid creating the dest directory if the source dir is empty\n unless File.exists? @destination_dir\n FileUtils.mkpath @destination_dir\n end\n @files.each do |f|\n Dir.glob(File.join(@location_dir, f)).each do |file|\n FileUtils.cp_r file, @destination_dir\n end\n end\n end\n else\n puts \"Error: #{@location_dir}, doesn't exist or not a directory\"\n end\n end",
"def unpack_zip archive, destination, clobber=nil\n validate archive, destination\n\n ##\n # As it turns out, the Rubyzip library corrupts\n # binary files (like the Flash Player) on OSX and is also\n # horribly slow for large archives (like the ~120MB Flex SDK)\n # on all platforms.\n if is_darwin?\n unpack_zip_on_darwin archive, destination, clobber\n else\n Zip::ZipFile.open archive do |zipfile|\n zipfile.each do |entry|\n next if entry.name =~ /__MACOSX/ or entry.name =~ /\\.DS_Store/\n unpack_zip_entry entry, destination, clobber\n end\n end\n end\n end",
"def directory!\n @file_list = @file_list.select{ |f| File.directory?(f) }\n end",
"def unzip\n files = {}\n unzip_dir = @fullpath[0..-5]\n FileUtils.mkpath(unzip_dir)\n Zip::File.open(@fullpath) do |zipfile|\n zipfile.each do |entry|\n next unless entry.file?\n full_source_path = \"#{unzip_dir}/#{entry.name}\"\n entry.extract(full_source_path) { true } # true for overwrite\n files[full_source_path] = entry.name\n end\n end\n files\n end",
"def collect_in_dir directory, recursive = true\n if not File.readable? directory\n puts \"#{directory} not readable. Skipping.\" if @verbose\n else\n directory += \"/\" if not directory.end_with? \"/\"\n if File.directory? directory\n files = Dir.entries directory\n files.reject! {|d| d.match /^\\.{1,2}$/} # ignore parent and self links\n files.map! { |f| directory + f }\n files.each do |fname|\n if File.directory?(fname) and recursive\n collect_in_dir fname\n elsif not File.readable? fname\n puts \"#{fname} not readable.Skipping.\" if @verbose\n elsif File.file? fname and File.extname(fname) == @extension # if no directory\n pkg_info = parse_pkg fname\n @files[fname] = pkg_info if pkg_info\n end\n end\n end\n end\n end",
"def extract\n zip_file_path = \"#{Rails.root}/public/tmp/#{self.id}/#{self.zip_file_name}\"\n # 100.times { p File.exist?(zip_file_path) }\n\n Zip::ZipFile.open(zip_file_path) do |zipfile|\n zipfile.each do |file|\n export_path = \"#{Rails.root}/public/tmp/#{self.id}_2/\"\n zip_path = File.join(export_path, zip_file_name)\n\n 100.times do\n p zip_path\n end\n\n # export_path = \"#{Rails.root}/public/tmp/#{self.id}_2/\"\n # zip_path = File.join(export_path, zip_file_name)\n # FileUtils.mkdir_p(File.dirname(export_path))\n\n # unless File.exist?(zip_file_path)\n # zipfile.extract(file, zip_path)\n # # # ..stuff that it does..\n # end\n # 100.times do\n # p image_path\n # end\n # FileUtils.mkdir_p(File.dirname(image_path))\n # unless File.exist?(image_path)\n # zip_file.extract(image, image_path)\n # # ..stuff that it does..\n # end\n end\n end\n end",
"def build_dir\n Puppet::Forge::Cache.base_path + \"tmp-unpacker-#{Digest::SHA1.hexdigest(@filename.basename.to_s)}\"\n end",
"def unzip_file(file)\n end",
"def flatten_source_directory\n system(\"find #{@source} -mindepth 2 -type f -exec mv -i '{}' #{@source} ';'\")\n end",
"def in_directory( dir, &block )\n curdir = pwd\n begin\n cd dir\n return block.call\n ensure\n cd curdir\n end\nend",
"def execute\n gemname = get_one_gem_name\n path = get_path(gemname, options[:version])\n if path\n require 'fileutils'\n target_dir = File.basename(path).sub(/\\.gem$/, '')\n FileUtils.mkdir_p target_dir\n Installer.new(path).unpack(File.expand_path(target_dir))\n say \"Unpacked gem: '#{target_dir}'\"\n else\n alert_error \"Gem '#{gemname}' not installed.\"\n end\n end",
"def temp_dir(*args, &block)\n self.class.temp_dir(prefix_suffix, *args, &block)\n end",
"def unpack!\n @container = @container.container\n end",
"def unpack!\n @container = @container.container\n end",
"def unzip_archive(archive, dest)\n # Adapted from examples at...\n # https://github.com/rubyzip/rubyzip\n # http://seenuvasan.wordpress.com/2010/09/21/unzip-files-using-ruby/\n Zip::File.open(archive) do |zf|\n zf.each do |f|\n f_path = File.join(dest, f.name)\n FileUtils.mkdir_p(File.dirname(f_path))\n zf.extract(f, f_path) unless File.exist?(f_path) # No overwrite\n end\n end\nend",
"def extract(options = {})\n # Ensure that unspecified options have default values.\n file_path = options.has_key?(:file_path) ?\n options[:file_path].to_s :\n @zip_path\n restore_permissions = options.has_key?(:permissions) ?\n options[:permissions] :\n false\n restore_ownerships = options.has_key?(:ownerships) ?\n options[:ownerships] :\n false\n restore_times = options.has_key?(:times) ?\n options[:times] :\n false\n\n # Make the directory.\n FileUtils.mkdir_p(file_path)\n\n # Restore the metadata.\n ::File.chmod(mode, file_path) if restore_permissions\n ::File.chown(uid, gid, file_path) if restore_ownerships\n ::File.utime(atime, mtime, file_path) if restore_times\n\n nil\n end",
"def with_stabilizer_in_temp_dir\n test_f = File.expand_path(File.dirname(__FILE__)) + \"/import/samples/flame_stabilizer/fromCombustion_fromMidClip_wSnap.stabilizer\"\n in_temp_dir do | where |\n FileUtils.cp(test_f, where + \"/flm.stabilizer\")\n yield(where)\n end\n end",
"def for(file_or_dir); end",
"def to_unpacked_file(options={})\n allow_bad_times = options.delete(:fix)\n fix_bcw = allow_bad_times\n data.descriptor.allow_bad_times = allow_bad_times\n new_descriptor = data.descriptor.merge( :type=>data.type )\n new_descriptor.allow_bad_times = allow_bad_times\n tp = File.expand_path(data.tape_path)\n block_padding_repaired_data = Bun.cache(:repaired_data, tp) do\n data.with_block_padding_repaired(fix: fix_bcw)\n end\n new_descriptor.merge!(\n block_padding_repairs: block_padding_repaired_data.block_padding_repairs,\n block_count: block_padding_repaired_data.block_count,\n first_block_size: block_padding_repaired_data.first_block_size,\n )\n\n f = File::Unpacked.create(\n :data=>block_padding_repaired_data,\n :archive=>archive,\n :tape=>File.basename(tape),\n :tape_path=>tape_path,\n :descriptor=>new_descriptor,\n )\n if data.type == :frozen\n f.descriptor.merge!(:shards=>f.shard_descriptors)\n end\n f\n end",
"def unzip_file (file, destination)\n Zip::File.open(file) { |zip_file|\n zip_file.each { |f|\n f_path=File.join(destination, f.name)\n FileUtils.mkdir_p(File.dirname(f_path))\n zip_file.extract(f, f_path) unless File.exist?(f_path)\n }\n puts \"Successfully extracted\"\n }\n end"
] | [
"0.6768916",
"0.66020393",
"0.6573681",
"0.64379764",
"0.6370169",
"0.62573236",
"0.6100926",
"0.60210377",
"0.59827924",
"0.59468234",
"0.58653903",
"0.58344775",
"0.58059204",
"0.5795933",
"0.5757779",
"0.57250017",
"0.5668835",
"0.5661736",
"0.55946493",
"0.5581571",
"0.55590665",
"0.55562943",
"0.55483323",
"0.55463403",
"0.553225",
"0.55227053",
"0.54975986",
"0.5492675",
"0.548985",
"0.5478622",
"0.54391783",
"0.5428205",
"0.542662",
"0.5405116",
"0.5397334",
"0.5373719",
"0.53542095",
"0.5340383",
"0.5337597",
"0.53095794",
"0.52721643",
"0.52657616",
"0.5241413",
"0.52122676",
"0.5211776",
"0.5205657",
"0.52036965",
"0.51998395",
"0.5167335",
"0.5154634",
"0.5142777",
"0.5139961",
"0.51360416",
"0.5120363",
"0.5110394",
"0.51010823",
"0.5097791",
"0.5096008",
"0.5085626",
"0.5083416",
"0.5075919",
"0.50561506",
"0.50551456",
"0.50466317",
"0.50465167",
"0.50444585",
"0.5041864",
"0.5009803",
"0.50094336",
"0.5009177",
"0.5005551",
"0.49992922",
"0.49697214",
"0.49630144",
"0.49611375",
"0.49599716",
"0.49550894",
"0.49550742",
"0.4952404",
"0.4951346",
"0.49473614",
"0.49433827",
"0.49322924",
"0.49285984",
"0.49225363",
"0.4920273",
"0.4917651",
"0.4907421",
"0.49011686",
"0.48975337",
"0.48913774",
"0.4871122",
"0.4869545",
"0.4869545",
"0.48601937",
"0.48581398",
"0.4857034",
"0.48507032",
"0.4842254",
"0.4836271"
] | 0.6281311 | 5 |
Iterate over each file in gem invoking block with path | def each_file(&bl)
unpack do |dir|
Pathname(dir).find do |path|
next if path.to_s == dir.to_s
pathstr = path.to_s.gsub("#{dir}/", '')
bl.call pathstr unless pathstr.blank?
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_advisory_path(&block)\n Dir.glob(File.join(@path,'gems','*','*.yml'),&block)\n end",
"def each_file\n return to_enum(__method__) unless block_given?\n\n paths.each do |root|\n stat_tree(root).each do |filename, stat|\n if stat.file?\n yield filename\n end\n end\n end\n\n nil\n end",
"def each(options={}, &block)\n each_loadpath(&block)\n each_rubygems(&block)\n self\n end",
"def each_file\n files.each { |filename| yield filename }\n end",
"def each\n files.each do |file|\n yield file\n end\n end",
"def for_files(path)\r\n files_names = Dir[path]\r\n files_names.each do |filename|\r\n yield(filename)\r\n end\r\n end",
"def each_file\n return unless block_given?\n\n loc_path = LokaliseRails.locales_path\n Dir[\"#{loc_path}/**/*\"].sort.each do |f|\n full_path = Pathname.new f\n\n next unless file_matches_criteria? full_path\n\n relative_path = full_path.relative_path_from Pathname.new(loc_path)\n\n yield full_path, relative_path\n end\n end",
"def each_file(&bl)\n unpack do |dir|\n Pathname.new(dir).find do |path|\n next if path.to_s == dir.to_s\n pathstr = path.to_s.gsub(\"#{dir}/\", '')\n bl.call pathstr unless pathstr.blank?\n end\n end\n end",
"def each_file(&block)\n @files.keys.each do |file|\n yield(file)\n end\n end",
"def with_each_gemspec\n Dir[\"**/*.gemspec\"].each do |file|\n yield(file, Gem::Specification.load(file)) if block_given?\n end\nend",
"def each_data_file(path)\n return enum_for(:each_data_file,path) unless block_given?\n\n each_data_path(path) do |full_path|\n yield(full_path) if File.file?(full_path)\n end\n end",
"def each(&block)\n @files.each(&block)\n end",
"def foreach\n find_files.each do |file|\n yield(@build_result_dir, file)\n end\n end",
"def each_file(directory)\n directory_contents(directory).each do |path|\n yield path\n end\n end",
"def each(options={}, &block)\n return unless apply?(nil, options)\n\n gem_name = (options[:gem] || options[:from]).to_s\n\n if vers = options[:version]\n spec = ::Gem::Specification.find_by_name(gem_name, vers)\n else\n spec = ::Gem::Specification.find_by_name(gem_name)\n end\n\n return unless spec\n\n #spec.activate\n\n spec.require_paths.each do |path|\n traverse(File.join(spec.full_gem_path, path), &block)\n end\n end",
"def each(&blk)\n Utils::Kernel.Array(self).each do |path|\n blk.call Utils::Kernel.Pathname(path).realpath\n end\n end",
"def each_advisory_path_for(name,&block)\n Dir.glob(File.join(@path,'gems',name,'*.yml'),&block)\n end",
"def each_file(&block)\n each_tailer { |t| t.file }.map(&block)\n end",
"def each\n changeset.each { |file| yield file }\n end",
"def each\n files.each do |f|\n content = File.read(path(f))\n content = compress(content) if @app.compress_bundles\n # Include a new line to prevent weirdness at file boundaries\n yield(\"#{content}\\n\")\n end\n end",
"def each\n Dir[ path_pattern ].each { |path| yield open(path) }\n end",
"def each\n @sources.each { |directory, path| yield directory, path }\n end",
"def list_files\n Find.find(path) do |element| yield element end\n end",
"def each_line(*args, &block)\n IO.foreach(@path, *args, &block)\n end",
"def process!\n process_previews! if self.class.preview?\n\n versions.each do |name, blk|\n path = File.join(@dir, \"#{name}_#{@filename}\")\n process_version!(path, &blk)\n @paths << path\n end\n\n @paths\n end",
"def foreach(&block)\n ::Dir.foreach(path, &block)\n end",
"def foreach(path = nil, *rs)\n path = \".\" unless path\n path = expand_path(path)\n\n if File.directory?(path)\n\tDir.foreach(path){|fn| yield fn}\n else\n\tIO.foreach(path, *rs){|l| yield l}\n end\n end",
"def each(&block)\n @gems.each(&block)\n end",
"def each(&block)\n @gems.each(&block)\n end",
"def each_file\n self.files.each_pair do |path, data|\n if not data.empty?\n yield path, StateModule::File::new(path, data)\n end\n end\n end",
"def foreach(path)\n # :nocov:\n raise(Errno::ENOENT, path)\n # :nocov:\n end",
"def each_result_arg\n match_all = ->(_) { true }\n changeset.file_paths.each do |relative_filename|\n next unless relative_filename.to_s.end_with?(\".rb\")\n path = case relative_filename\n when Pathname then relative_filename\n else\n File.expand_path(relative_filename, @relative_git_dir)\n end\n\n root_ast = Imagen::Node::Root.new.build_from_file(path)\n next if root_ast.children.empty?\n\n coverage = lcov.source_files[path.to_s]\n\n root_ast.children[0].find_all(match_all).each do |node|\n yield(path.to_s, coverage, node)\n end\n end\n end",
"def each_io\n each_file do |filename|\n io = get filename\n yield filename, io\n end\n end",
"def each_io\n each_file do |filename|\n io = get filename\n yield filename, io\n end\n end",
"def each(&block)\n\t\t\t\treturn to_enum unless block_given?\n\t\t\t\t\n\t\t\t\t::Dir.glob(full_pattern, ::File::FNM_DOTMATCH) do |path|\n\t\t\t\t\t# Ignore `.` and `..` entries.\n\t\t\t\t\tnext if path =~ /\\/..?$/\n\t\t\t\t\t\n\t\t\t\t\tyield Path.new(path, @root)\n\t\t\t\tend\n\t\t\tend",
"def each_schema_file(&block)\n Dir[File.expand_path(\"../fixtures/*.yaml\", __FILE__)].each(&block)\n end",
"def enumerate_files search_path\n Enumerator.new do |e|\n Dir\n .glob(search_path)\n .each do |filename|\n if File.file?(filename)\n $stderr.puts \"Reading #{filename}\" if $verbose\n File.open filename do |file|\n e.yield file.read()\n end\n end\n end\n end\nend",
"def files_for_erb\n return Dir.chdir( base ) { Dir.glob( '*.erb' ) }\n end",
"def for_contents(path)\r\n if(path.end_with? 'zip')\r\n for_zipped_contents(path) { |line| yield(line) }\r\n else\r\n File.open(path, \"r\") do |file|\r\n file.each_line do |line|\r\n yield(line)\r\n end\r\n end\r\n end\r\n end",
"def each_file\n @sftp.dir.foreach(@path.to_s) do |entry|\n filename = entry.name\n yield filename unless directory? filename\n end\n end",
"def each(&block)\n\t\t\t\tfiles = []\n\n\t\t\t\t@filenames.each do |filename|\n\t\t\t\t\tf = open_file(filename)\n\t\t\t\t\tf.each do |line|\n\t\t\t\t\t\tline.gsub!(\"\\n\",\"\")\n\n\t\t\t\t\t\t# Ignore these lines since they does not contain a\n\t\t\t\t\t\t# filename.\n\t\t\t\t\t\tnext if /^#/.match(line)\n\n\t\t\t\t\t\t# Skip empty lines as well.\n\t\t\t\t\t\tnext if /^\\s*$/.match(line)\n\n\t\t\t\t\t\tline = File.join(@prefix, line) unless @prefix.nil?\n\t\t\t\t\t\tfiles << line\n\t\t\t\t\tend\n\t\t\t\t\tclose_file(f)\n\t\t\t\tend\n\n\t\t\t\tfiles.each(&block)\n\t\t\tend",
"def each_entry(&block) # :yield: p\n Dir.foreach(path) {|f| yield Path::Name.new(f) }\n end",
"def each_package(&block)\n packages_by_name.each_value(&block)\n end",
"def each_file_in_target(target, &block)\n target.build_phases.each {|phase|\n phase.files.each {|buildFile|\n buildFile.file_references.each {|fileRef|\n block.call(buildFile, fileRef)\n }\n }\n }\n end",
"def each(&block)\n files.each(&block)\n\n directories.each do |subdirectory|\n block.call(subdirectory)\n\n subdirectory.each(&block)\n end\n end",
"def each_object_path (path=@basepath, &block)\n\n Find.find(path) do |p|\n\n next unless File.exist?(p)\n next if File.stat(p).directory?\n #next unless OpenWFE::ends_with(p, '.yaml')\n next if p[-5..-1] != '.yaml'\n\n #ldebug { \"each_object_path() considering #{p}\" }\n block.call(p)\n end\n end",
"def files\n return enum_for(:files) unless block_given?\n\n yield @filename\n end",
"def ri_paths &block\n RDoc::RI::Paths.each true, true, true, :all, *@extra_doc_dirs, &block #TODO: pass extra_dirs\n end",
"def each_file_in_tree\n self.directories_in_tree.find_each do |directory|\n next if directory.nil?\n directory.cfs_files.find_each do |cfs_file|\n next if cfs_file.nil?\n\n yield cfs_file if block_given?\n end\n end\n end",
"def each(&block)\n @all_passed = true\n rows.each do |row|\n gemfile = row.gemfile\n if row.compatible_with_ruby?(current_ruby)\n @compatible_count += 1\n\n @aliased_rubys[current_ruby] = row.ruby\n\n print_title gemfile\n gemfile_passed = Env.with_gemfile(gemfile, row, &block)\n @all_passed &= gemfile_passed\n if gemfile_passed\n @results[row] = tint('Success', COLOR_SUCCESS)\n else\n @results[row] = tint('Failed', COLOR_FAILURE)\n end\n else\n @results[row] = tint(\"Skipped\", COLOR_WARNING)\n end\n end\n print_summary\n end",
"def each(&block)\n if block_given?\n @fog_wrapper.each do |key|\n yield file(key)\n end\n else\n to_enum(:each)\n end\n end",
"def each_plugin_element(filespec, &block)\n file = File.new(filespec)\n xml = REXML::Document.new file\n file.close\n plugin_element = xml.root\n if plugin_element.name==\"plugin\"\n yield plugin_element\n return\n else\n yield plugin_element if plugin_element.attributes[\"name\"] #register subsystem plugin\n plugin_element.each_element(\"plugin\") {|element| yield element}\n end\n end",
"def files(rootDir)\n Dir.foreach(rootDir) do |dir|\n if dir != \".\" && dir != \"..\"\n puts \"Processing \" + dir\n Dir.foreach(rootDir + \"/\" + dir) do |file|\n if file != \".\" && file != \"..\"\n open(rootDir + \"/\" + dir + \"/\" + file) do |f|\n yield(f)\n end\n end\n end\n end\n end\nend",
"def glob(*args, &block); end",
"def each(&block)\n if block_given?\n Parallel.each(each_path, in_threads: threads) do |path|\n load_script_from_path path, &block\n end\n else\n self.enum_for :each\n end\n end",
"def load_gems_in(*spec_dirs); end",
"def execute\n res = @include_list.map { |re_file| IO.read File.join(File.dirname(@file),re_file) }\n res << IO.read(@file)\n res.join \"\\n\"\n end",
"def swift_deps_files_in_dir(object_files_dirs)\n\t\tdirs = Array(object_files_dirs)\n\t\tdirs.each do |dir|\n\t\t Dir.glob(\"#{dir}/*.swiftdeps\") { |file| yield file }\n\t\tend\n\tend",
"def require_all dir\n `ls #{dir}`.each_line do |file|\n require \"#{dir}/#{file.strip}\"\n end\nend",
"def for_each_submodule_dir &block\n for_each_submodule { |dir| Dir.chdir(dir) { yield dir } }\nend",
"def run\n @files.each { |filename| load(filename) }\n end",
"def load_gems(an_array_of_strings)\n\n print \"Installing gems as necessary ... \" if $debug\n gemfile do\n source 'https://rubygems.org'\n Array(an_array_of_strings).each do |gem_name|\n print gem_name + ' ' if $debug\n gem gem_name\n end\n end\n\n puts 'done' if $debug\n\nend",
"def each_filename; end",
"def each_file(markup)\n @files.each do |dest,file|\n if (formatted_like?(dest,markup) || !formatted?(dest))\n yield dest, file\n end\n end\n end",
"def each(&block)\n SemanticLogger.named_tagged(dirmon_entry: id.to_s) do\n # Case insensitive filename matching\n Pathname.glob(pattern, File::FNM_CASEFOLD).each do |pathname|\n next if pathname.directory?\n pathname = begin\n pathname.realpath\n rescue Errno::ENOENT\n logger.warn(\"Unable to expand the realpath for #{pathname.inspect}. Skipping file.\")\n next\n end\n\n file_name = pathname.to_s\n\n # Skip archive directories\n next if file_name.include?(self.class.default_archive_directory)\n\n # Security check?\n if (whitelist_paths.size > 0) && whitelist_paths.none? { |whitepath| file_name.to_s.start_with?(whitepath) }\n logger.error \"Skipping file: #{file_name} since it is not in any of the whitelisted paths: #{whitelist_paths.join(', ')}\"\n next\n end\n\n # File must be writable so it can be removed after processing\n unless pathname.writable?\n logger.error \"Skipping file: #{file_name} since it is not writable by the current user. Must be able to delete/move the file after queueing the job\"\n next\n end\n block.call(pathname)\n end\n end\n end",
"def find_file(*path)\n f = File.join(path)\n if File.exists?(f)\n yield f\n end\n end",
"def installed_files\n Dir.chdir(@spec.gem_dir) { Dir['**/*'].reject {|fp| ::File.directory?(fp) } }\n end",
"def iterate_over_file_paths\n parsed_file.each do |hit|\n file_path_array << hit[0]\n end\n file_path_array\n end",
"def each_specification_file(apply_filter = true, &bl)\n return enum_for(:each_specification_file, apply_filter) unless block_given?\n _each_specification_file(config, apply_filter, &bl)\n end",
"def iterate resource, &block\n data = YAML.load_file \"#{@path}/#{resource}\" # cached file may be either in YAML or JSON format\n data['items'].each do |i|\n yield(i)\n end\n nil\n end",
"def each_table_file\n Dir[File.expand_path('../fixtures/basics/data/*.rb', __FILE__)].each{|file| \n name = File.basename(file, \".rb\")\n yield(name, file)\n }\n end",
"def foreach(zip_file_name, &block); end",
"def find_files_for_reload\n paths = [ './', *$LOAD_PATH ].uniq\n [ $0, *$LOADED_FEATURES ].uniq.map do |file|\n next if file =~ /\\.(so|bundle)$/\n yield(find(file, paths))\n end\n end",
"def files() = files_path.glob('**/*')",
"def templates() = templates_path.glob('**/*.erb')",
"def process_files\n loaded_files = []\n files.each do |file|\n Async do |task|\n task.async do\n loaded_files << load_file(file[:path], file[:source])\n end\n end\n end\n loaded_files\n end",
"def each_autobuild_package\n return enum_for(__method__) unless block_given?\n\n each_package_definition { |pkg| yield(pkg.autobuild) }\n end",
"def load_files(path)\n Dir[path].each {|file| require file}\nend",
"def generate_ansible_files\n \n # Helper to decide whether or not to generate/update a given file\n update = Proc.new do |fn, mtime|\n !(File.exists?(fn) && File.stat(fn).mtime >= mtime)\n true\n end\n\n Dir.glob('./templates/ansible.*').each do |template|\n\n # Get a template's last modified date\n source_mtime = File.stat(template).mtime \n\n # Get a destination's potential file name & path \n target_file = File.basename(template).split('.').slice(1...-1).join('.') \n target_paths = target_file.start_with?('inventory') ? ['inventory/'] : ['', 'plays/*/']\n\n # Walk destination path(s)\n target_paths.each do |target_path|\n \n Dir.glob(\"./ansible/#{target_path}\").each do |path|\n\n # Build a potential real path\n fn = File.join(File.expand_path(path), target_file) \n\n # Yield source (template file) & target if the target needs to be generated/updated\n yield template, fn if update.call(fn, source_mtime) && block_given?\n end\n end\n end\nend",
"def enumerate_available path\n trace :loading, \"Enumerating under #{path.inspect}\" do\n Loadable.new(path).\n enumerate.\n map do |filename|\n begin\n require(pathname = path+\"/\"+filename)\n trace :loading, \"Loaded #{pathname}\"\n filename\n rescue LoadError => e\n trace :loading, \"Can't load #{pathname}: #{e.class}: #{e.message} #{e.backtrace[0]}\"\n nil\n rescue Exception => e\n $stderr.puts \"Can't load #{pathname}: #{e.class}: #{e.message} #{e.backtrace[0]}\"\n nil\n end\n end.compact\n end\n end",
"def for_each_gemfile(command, why = 'install')\n command = \"#{bundle_environment}#{command}\"\n # We show full command output when --trace is set.\n tracing = Rake.application.options.trace\n dirs.each do |full_path|\n # Skip any components that do not include Gemfiles\n next unless File.exist?(File.join(full_path, 'Gemfile'))\n Dir.chdir(full_path) do\n output = `#{command} 2>&1`\n if $? == 0\n unless tracing\n output = \"bundle #{why} successful for #{File.basename(full_path)}\"\n end\n puts output\n else\n puts \"FATAL: `#{command}` failed in #{full_path}\"\n exit 1\n end\n end\n end\n end",
"def _each_specification_file(config, apply_filter = true)\n folder = config.folder\n world = config.folder/\"world\"\n fs = folder.glob(\"**/*.{yml, yaml}\").reject{|f|\n f.to_s.start_with?(world.to_s) || f.to_s =~ /openapi.base.yml/\n }\n fs = fs.sort\n fs = fs.select(&to_filter_proc(config.file_filter)) if apply_filter\n fs.each do |file|\n yield file, folder\n end\n end",
"def run\n files_to_inspect.each do |path|\n SourceFile.new(\n linter_config: linter_config,\n io: io,\n path: path,\n root: root\n ).process\n end\n end",
"def each(path = nil, &block)\r\n @specs.each do |k, v|\r\n next if !path.nil? && k.first != path\r\n block.call(v) if block.arity == 1\r\n block.call(k.last, v) if block.arity == 2\r\n block.call(k.first, k.last, v)\r\n end\r\n end",
"def load_gemfiles(directories)\n directories.each do |directory|\n gemfile = File.expand_path(File.join(directory, 'Gemfile'))\n eval(File.read(gemfile), binding) if File.exist?(gemfile)\n end\nend",
"def each_gem_spec(filtered_osdeps)\n return enum_for(:each_gem_spec, filter_osdeps) unless block_given?\n\n filtered_osdeps.each do |pkg, data|\n debian_pkg_name = data['default']\n # Use the package name to infer the installation directory\n gemspec_pattern =\n File.join(\"/opt\",\"rock\",\"*\",debian_pkg_name,\"share\",\"rubygems-integration\",\"**\",\"*.gemspec\")\n files = Dir.glob(gemspec_pattern)\n files.each do |gemspec_file|\n yield gemspec_file unless File.empty?(gemspec_file)\n end\n end\n end",
"def run\n loader = nil\n results = []\n begin\n loader = InputLoader.new(File.new(@path))\n while(loader.hasNext?)\n inst = loader.nextInstance\n results[results.count] = resolve(inst)\n end\n ensure\n loader.close if loader != nil\n end\n results\n end",
"def filepaths_from *types, &block\n expr = last_option(types)[:matching]\n the_files = types.inject([]) do |files, type|\n method = :\"#{type}_files\"\n files_found = send(method, expr) if respond_to?(method)\n files_found = RailsAssist::Artifact::Files.send(method, expr) if RailsAssist::Artifact::Files.respond_to?(method)\n files + files_found\n end.compact\n yield the_files if block\n the_files\n end",
"def dir_foreach( *args, &block )\n warn \"Path#dir_foreach is obsoleted. Use Path#each_entry.\"\n each_entry( *args, &block )\n end",
"def foreach(path)\n handle = sftp.opendir!(path)\n while entries = sftp.readdir!(handle)\n entries.each { |entry| yield entry }\n end\n return nil\n ensure\n sftp.close!(handle) if handle\n end",
"def each(&block)\n File.open(filepath, 'rb') do |io|\n while part = io.read(block_size)\n yield part\n end\n end\n end",
"def each_asset\n assets.each do |(path, destination)|\n path = path.to_s\n if destination == :root\n yield path, File.join(output_directory.to_s, File.basename(path))\n else\n yield path, File.join(output_directory.to_s, destination.to_str)\n end\n end\n end",
"def for_files(*wildcards)\n wildcards.each do |wildcard|\n Dir[wildcard].each do |fn|\n yield(fn)\n end\n end\n end",
"def for_files(*wildcards)\n wildcards.each do |wildcard|\n Dir[wildcard].each do |fn|\n yield(fn)\n end\n end\n end",
"def populate_files(path:)\n files = list_files(path: path)\n populated = []\n files.each do |file|\n populated << Manifests::FileEntry.new(file: { filepath: IngestUtils.relative_path(file, path) })\n end\n populated\n end",
"def each_object (&block)\n\n each_object_path do |path|\n block.call(load_object(path))\n end\n end",
"def run\n @file_paths.each do |path|\n process_file(path)\n end\n @report\n end",
"def each\n @config.each do |configfile|\n yield configfile[:file], configfile[:config]\n end\n end",
"def each_readable_with_basename basename, &block # :yields: path, parsed_content\n each_existing_readable(\"#{basename}#{FileLoader::make_wildcard_for_extensions(@readers.keys)}\", nil, &block)\n end",
"def find_files(block)\n files = []\n block.scan(URL_PATTERN).each do |attribute, path|\n if !URI.parse(path).absolute?\n resource = create_resource_file(attribute, path)\n files << resource if resource\n end\n end\n files\n end"
] | [
"0.7070386",
"0.6996039",
"0.69045496",
"0.68982726",
"0.68819165",
"0.686839",
"0.6828378",
"0.6794561",
"0.67542773",
"0.67044747",
"0.6674731",
"0.66717",
"0.66653067",
"0.6623254",
"0.66205245",
"0.6605908",
"0.655058",
"0.65376604",
"0.65147406",
"0.65110606",
"0.65024555",
"0.64612997",
"0.6423193",
"0.6419313",
"0.6416929",
"0.6366485",
"0.63536894",
"0.63508373",
"0.63508373",
"0.63304126",
"0.63062257",
"0.62517655",
"0.62484825",
"0.62484825",
"0.6246547",
"0.62390316",
"0.6222851",
"0.6203563",
"0.62016",
"0.6200308",
"0.6170272",
"0.61627",
"0.61612487",
"0.61463755",
"0.614634",
"0.61400783",
"0.6119216",
"0.6113986",
"0.60806024",
"0.6073532",
"0.6060082",
"0.60466015",
"0.60295737",
"0.60209924",
"0.60160995",
"0.5990976",
"0.59823406",
"0.59704506",
"0.595503",
"0.5947361",
"0.59471387",
"0.5943867",
"0.5919019",
"0.591886",
"0.59094644",
"0.5898946",
"0.58970255",
"0.588624",
"0.5882842",
"0.5880481",
"0.5867279",
"0.5867208",
"0.5862741",
"0.5855075",
"0.5845332",
"0.5841448",
"0.5838833",
"0.58336335",
"0.58307153",
"0.5830111",
"0.58208996",
"0.5816712",
"0.58033794",
"0.57982445",
"0.5789082",
"0.5783703",
"0.5782614",
"0.57816213",
"0.5768584",
"0.57668346",
"0.576472",
"0.57608336",
"0.5752649",
"0.5752649",
"0.57452875",
"0.5742916",
"0.57418036",
"0.5734809",
"0.5730386",
"0.5726321"
] | 0.6865856 | 6 |
Retrieve the list of paths to files in the gem | def file_paths
@file_paths ||= begin
files = []
each_file do |path|
files << path
end
files
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def files\n entries.map(&:filepath)\n end",
"def paths_from_software_gems\n @paths_from_software_gems ||=\n Array(Config.software_gems).inject([]) do |array, name|\n if (spec = Gem::Specification.find_all_by_name(name).first)\n array << File.expand_path(spec.gem_dir)\n end\n\n array\n end\n end",
"def all_files() = path.glob('**/*').select(&:file?).map(&:to_s)",
"def files\n %x{\n find . -type f ! -path \"./.git/*\" ! -path \"./node_modules/*\"\n }.\n split(\"\\n\").\n map { |p| Pathname.new(p) }\n end",
"def file_paths\n @file_paths ||= begin\n files = []\n each_file do |path|\n files << path\n end\n files\n end\n end",
"def files\n files_equivs = \"\"\n @package.documents.each do |file|\n ActiveRecord::Base.logger.info(\"#{file.attach_file_name} #{file.install_path}\")\n files_equivs += \"#{file.attach_file_name} #{file.install_path}\\n\\t\"\n end\n files_equivs\n end",
"def packages\n FileList[package_path('.*')]\n end",
"def filepaths\n object.object_files.map(&:relative_path)\n end",
"def files\n return get_result('files')\n end",
"def files\n @exported_pr_dir ? Dir.glob(@exported_pr_dir) : []\n end",
"def paths\n f = File.open(@path)\n f.grep(FILE_NAME_PATTERN) { $1 }\n end",
"def files\n @files.map do |file|\n if File.directory?(file)\n Dir[File.join(file, '**', '*.rb')]\n else\n file\n end\n end.flatten\n end",
"def files\n @files ||= full_files.map {|file| relative(file) }\n end",
"def get_file_list relative_path\n\t\t\t\tpath = File.join(@src, relative_path)\n\t\t\t\tresult = nil\n\t\t\t\tFileUtils.cd(path) do\n\t\t\t\t\tresult = Dir.glob(\"**/*\", File::FNM_DOTMATCH)\n\t\t\t\t\tresult.reject! { |fn| File.directory?(fn) }\n\t\t\t\t\tresult.reject! { |fn| fn =~ /(^_|\\/_)/ }\n\t\t\t\tend\n\t\t\t\tresult\n\t\t\tend",
"def installed_files\n Dir.chdir(@spec.gem_dir) { Dir['**/*'].reject {|fp| ::File.directory?(fp) } }\n end",
"def list\n Dir.glob(\"#{@path}/**/*\").select{|path| File.file?(path) }.map do |path|\n path.sub Regexp.new(\"^#{@path}\\/\"), ''\n end\n end",
"def expound_paths(*entries)\n paths = []\n\n entries.each do |entry|\n entry = entry.strip\n\n next if entry.empty?\n next if entry.start_with?('#')\n\n if File.directory?(entry)\n if library_path?(entry)\n paths << entry\n else\n if File.directory?(File.join(entry, 'gems'))\n subpaths = Dir.glob(File.join(entry, 'gems/*/'))\n else\n subpaths = Dir.glob(File.join(entry, '*/'))\n end\n subpaths.each do |subpath|\n paths << subpath if library_path?(subpath)\n end\n end\n elsif File.file?(entry)\n paths.concat(expound_paths(*File.readlines(entry)))\n else\n glob_paths = Dir.glob(entry)\n if glob_paths.first != entry\n paths.concat(expound_paths(*glob_paths))\n end\n end\n end\n\n paths\n end",
"def list\n factory.system.list(@path).collect do |item|\n candidate = dir(item)\n if (not candidate.exists?)\n candidate = file(item)\n end\n candidate\n end\n end",
"def files\n return [] unless meta?\n filename = meta['path'] + '/' + meta['filename']\n [\n Inch::Utils::CodeLocation.new('', filename, meta['lineno'])\n ]\n end",
"def all_files\n return manifest_entry.files\n end",
"def generate_require_paths\n return configured_require_paths unless gemspec?\n result = []\n gemspecs.each do |file|\n base = File.dirname(file)\n # HACK: Evaluating gemspec files violates the goal of not running\n # workspace code, but this is how Gem::Specification.load does it\n # anyway.\n cmd = ['ruby', '-e', \"require 'rubygems'; require 'json'; spec = eval(File.read('#{file}'), TOPLEVEL_BINDING, '#{file}'); return unless Gem::Specification === spec; puts({name: spec.name, paths: spec.require_paths}.to_json)\"]\n o, e, s = Open3.capture3(*cmd)\n if s.success?\n begin\n hash = o && !o.empty? ? JSON.parse(o.split(\"\\n\").last) : {}\n next if hash.empty?\n @gemnames.push hash['name']\n result.concat(hash['paths'].map { |path| File.join(base, path) })\n rescue StandardError => e\n Solargraph.logger.warn \"Error reading #{file}: [#{e.class}] #{e.message}\"\n end\n else\n Solargraph.logger.warn \"Error reading #{file}\"\n Solargraph.logger.warn e\n end\n end\n result.concat(config.require_paths.map { |p| File.join(directory, p) })\n result.push File.join(directory, 'lib') if result.empty?\n result\n end",
"def files() = files_path.glob('**/*')",
"def referenced_files\r\n\t\t(\r\n\t\t\t[file] +\r\n\t\t\t%w[sourcepath importfile].flat_map do |att|\r\n\t\t\t\tfind(att=>/./).flat_map do |asset|\r\n\t\t\t\t\tasset[att].values.compact.map do |path|\r\n\t\t\t\t\t\tpath.sub!(/#.+/,'')\r\n\t\t\t\t\t\tabsolute_path(path) unless path.empty?\r\n\t\t\t\t\tend.compact\r\n\t\t\t\tend\r\n\t\t\tend +\r\n\t\t\tfind.flat_map do |asset|\r\n\t\t\t\tasset.properties.select{ |name,prop| prop.type=='Texture' }.flat_map do |name,prop|\r\n\t\t\t\t\tasset[name].values.compact.uniq.map{ |path| absolute_path(path) }\r\n\t\t\t\tend\r\n\t\t\tend +\r\n\t\t\tfind(_type:'Text').flat_map do |asset|\r\n\t\t\t\tasset['font'].values.compact.map{ |font| absolute_path(font) }\r\n\t\t\tend +\r\n\t\t\t@doc.xpath('/UIP/Project/Classes/*/@sourcepath').map{ |att| absolute_path att.value }\r\n\t\t).uniq\r\n\tend",
"def lib_files\n @files.select do |file|\n require_paths.any? do |path|\n file.start_with? path\n end\n end\n end",
"def files\n real_path = self.path[2...-1] + \"s/*\"#trim './' and add 's/*' \n \n Dir[real_path].map{|file| file.split(\"/\")[-1]} \n end",
"def files\n return unless git_repo?\n output = Licensed::Shell.execute(\"git\", \"ls-files\", \"--full-name\", \"--recurse-submodules\")\n output.lines.map(&:strip)\n end",
"def local_gems\n %x(ls #{local_cache_path}).split(/\\s+/)\n end",
"def files\n directory.files\n\n #@files ||= (\n # files = []\n # Dir.recurse(directory.to_s) do |path|\n # next if IGNORE_FILES.include?(File.basename(path))\n # files << path.sub(directory.to_s+'/','')\n # end\n # files.reject{ |f| File.match?(CONFIG_FILE) }\n #)\n end",
"def files\n @files ||= preferred_sources([@path])\n end",
"def files\n @@files_array = Dir.entries(self.path).select {|f| !File.directory? f}\n end",
"def gempaths\n\t\t\treturn Gem.path\n\t\tend",
"def files\n file_sets.map{|fs| fs.files }.flatten\n end",
"def lookup_paths\n if list = ENV['RUBY_LIBRARY']\n list.split(/[:;]/)\n #elsif File.exist?(path_file)\n # File.readlines(path_file).map{ |x| x.strip }.reject{ |x| x.empty? || x =~ /^\\s*\\#/ }\n elsif ENV['GEM_PATH']\n ENV['GEM_PATH'].split(/[:;]/).map{ |dir| File.join(dir, 'gems', '*') }\n elsif ENV['GEM_HOME']\n ENV['GEM_HOME'].split(/[:;]/).map{ |dir| File.join(dir, 'gems', '*') }\n else\n warn \"No Ruby libraries.\"\n []\n end\n end",
"def require_paths\n raw_data['require_paths'] || []\n end",
"def rubyinstaller_build_gem_files\n spec = Gem.loaded_specs[\"rubyinstaller-build\"]\n if spec\n # A loaded gemspec has empty #files -> fetch the files from its path.\n # This is preferred to gemspec loading to avoid a dependency to git.\n Dir[\"**/*\", base: spec.full_gem_path].select do |f|\n FileTest.file?(File.join(spec.full_gem_path, f))\n end\n else\n # Not yet loaded -> load the gemspec and return the files added to the gemspec.\n Gem::Specification.load(File.join(GEM_ROOT, \"rubyinstaller-build.gemspec\")).files\n end\n end",
"def solution_files\n get_folder_files(SOLUTION_PATH)\n end",
"def file_list\n @file_list\n end",
"def file_path_list\n @file_path_list ||= self.class.default_file_path_list\n end",
"def files\n Native `#{@el}.files`\n end",
"def files\n Native `#{@el}.files`\n end",
"def files\n result = []\n @my_files.each do |f|\n result << f.fname if FileTest.file?(f.fname)\n end\n result\n end",
"def paths\n Array(config.path).map(&:to_s)\n end",
"def list\n Dir.glob(\"#{@directory}/**/*\").reject(&File.directory?).map do |p|\n Pathname.new(p).relative_path_from(@directory)\n end\n end",
"def paths\n @paths ||= []\n @paths\n end",
"def paths\n @paths ||= []\n @paths\n end",
"def files\n [@nuspec_file, @changelog_file, @readme_file]\n end",
"def files\n [@nuspec_file, @changelog_file, @readme_file]\n end",
"def files\n @files_array = Dir.entries(self.path).select {|f| !File.directory? f}\n # This returns:\n # [\"Action Bronson - Larry Csonka - indie.mp3\",\n # \"Real Estate - Green Aisles - country.mp3\",\n # \"Real Estate - It's Real - hip-hop.mp3\",\n # \"Thundercat - For Love I Come - dance.mp3\"]\n end",
"def files\n Dir[root_path(\"app\", \"**\", \"*.rb\")] + [@app_class.app_file]\n end",
"def lib_paths\n @mpc_project.recipe.get_relative_paths(@mpc_project.lib_paths)\n end",
"def paths\n unless @paths\n @paths = []\n @paths << project._(:source, :main, :assets) if File.exist?(project._(:source, :main, :assets))\n end\n @paths\n end",
"def filePaths\n result = OpenStudio::PathVector.new\n if @workflow[:file_paths]\n @workflow[:file_paths].each do |file_path|\n result << OpenStudio.toPath(file_path)\n end\n else\n result << OpenStudio.toPath('./files')\n result << OpenStudio.toPath('./weather')\n result << OpenStudio.toPath('../../files')\n result << OpenStudio.toPath('../../weather')\n result << OpenStudio.toPath('./')\n end\n result\n end",
"def files\n return @files\n end",
"def gemspec_path\n Pathname.glob('*.gemspec').first\n end",
"def get_chef_files_absolute_paths path\n get_file_absolute_paths(path).select { |file| is_valid_chef_component_file?(file) }\n end",
"def file_paths\n src_file_mask = File.join(@folder_path, '**', '*.c')\n @file_paths = Dir.glob(src_file_mask)\n return @file_paths\n end",
"def files\n ext_files = mapper.extracted_files || []\n ext_files + [mapper.zip.name.to_s]\n end",
"def related_files\n []\n end",
"def get_files\n if @options[:recursive]\n `find \"#{@srcdir}\" -name '*.#{@extension}'`.split(\"\\n\")\n else\n Dir.glob(\"#{@srcdir}/*.#{@extension}\")\n end\n end",
"def files\n # list_of_filenames = Dir.entries(path)\n @list_of_filenames = Dir.glob(\"#{@path}/*.mp3\").collect! {|x| x.gsub(\"#{@path}/\", \"\") }\n # binding.pry\n end",
"def files\n file_sets.map(&:original_file)\n end",
"def files\n templates.map(&:filename)\n end",
"def files\n files_in_path.map do |file|\n TemplateFile.from_full_path(@path, file) unless File.directory?(file)\n end.compact\n end",
"def files_in_path\n Dir.glob(\"#{@path}/**/*/**\") | Dir.glob(\"#{@path}/**\")\n end",
"def full_require_paths\n @full_require_paths ||=\n begin\n full_paths = raw_require_paths.map do |path|\n File.join full_gem_path, path.tap(&Gem::UNTAINT)\n end\n\n full_paths << extension_dir if have_extensions?\n\n full_paths\n end\n end",
"def entries\n ::Dir.entries(path) - ['.', '..']\n end",
"def paths\n Array(@ruhoh.cascade.paths.map{|h| h[\"path\"]}).map { |path|\n collection_path = File.join(path, resource_name)\n next unless File.directory?(collection_path)\n\n collection_path\n }.compact\n end",
"def files\n @files.values\n end",
"def file_paths\n Dir.glob(@filepath_pattern).sort\n end",
"def files\n Hash(@config[:files]).keys\n end",
"def files()\n\t\t\t\tlist = []\n\t\t\t\tdir = Dir.new( path() )\n\t\t\t\t\n\t\t\t\tdir.each do |f|\n\t\t\t\t\tnext if File.directory?( path() + \"/\" + f )\n\t\t\t\t\tnext unless ( f[/^([A-Z][A-Za-z]*)+\\.class\\.rb$/] == nil )\n\t\t\t\t\tlist << file( f )\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn list\n\t\t\tend",
"def helper_files\n source_dir = File.join(Dir.pwd, \"lib/drydock/jobs\", helper_source_dir)\n if Dir.exists?(source_dir)\n Dir[source_dir + \"/*\"]\n else\n []\n end\n end",
"def entries() Dir.entries(path).map {|f| Path::Name.new(f) } end",
"def plugin_files_by_dir\n Array(Ohai.config[:plugin_path]).inject([]) do |plugin_files, plugin_path|\n plugin_files + PluginFile.find_all_in(plugin_path)\n end\n end",
"def list_files_from path,opts = {}\n unless Dir.exists? path\n Logger.<<(__FILE__,\"ERROR\",\"Local fetcher: path does not exists for listing... #{path} \")\n raise \"Error LocalFileFetcher !\"\n end\n if opts[:directories]\n cmd = \"ls -td #{path}/*/\"\n else\n cmd = \"ls #{path}\"\n cmd += \"/#{opts[:regexp]}\" if opts[:regexp]\n end\n out = `#{cmd}`\n return out.split(\"\\n\")\n end",
"def working_files\n files.map {|f| working_file f}\n end",
"def files\n file = Dir[self.path + \"/*\"]\n file.each do |file_name|\n file_name.slice!(self.path + \"/\")\n end\n file\n end",
"def caller_files\n caller_locations.\n map { |file,line| file }\n end",
"def path(match, options={})\n return [] if options[:from]\n\n found = []\n $LOAD_PATH.uniq.map do |path|\n list = Dir.glob(File.join(File.expand_path(path), match))\n list = list.map{ |d| d.chomp('/') }\n found.concat(list)\n end\n found.concat(data_path(match, options))\n found\n end",
"def package_paths\n return @package_paths if defined?(@package_paths)\n\n @package_paths = begin\n output = Licensed::Shell.execute(\"php\", composer_application_path, \"show\", \"--format\", \"json\", \"--path\", allow_failure: true)\n return {} if output.to_s.empty?\n\n path_json = JSON.parse(output)\n return {} unless path_json[\"installed\"]\n\n path_json[\"installed\"].each_with_object({}) do |package, hsh|\n hsh[package[\"name\"]] = package[\"path\"]\n end\n end\n end",
"def files\n Dir.glob(bag_dir/\"**\"/\"*\")\n .map {|f| Pathname.new(f) }\n .reject(&:directory?)\n end",
"def files_for_directory(path)\n directory = find_preferred_file(\n @new_resource.cookbook_name, \n :remote_file, \n path, \n @node[:fqdn],\n @node[:platform],\n @node[:platform_version]\n )\n\n unless (directory && ::File.directory?(directory))\n raise NotFound, \"Cannot find a suitable directory\"\n end\n\n directory_listing = Array.new\n Dir[::File.join(directory, '**', '*')].sort { |a,b| b <=> a }.each do |file|\n next if ::File.directory?(file)\n file =~ /^#{directory}\\/(.+)$/\n directory_listing << $1\n end\n directory_listing\n end",
"def files\n @files = []\n Find.find(@path) do |path|\n if File.directory? path\n if File.basename(path)[0] == ?.\n Find.prune # don't look any further into this directory.\n else\n next\n end\n else\n @files << path\n end\n end\n @files.size\n end",
"def breadcrumb_files\n Dir[*Gretel.breadcrumb_paths]\n end",
"def files\n modules = (changed?) ? tag_configuration_plugins.collect {|p| p.plugin.modules} : \n plugins.collect {|p| p.modules}\n modules << Plugin::JshubCore.instance.modules\n modules.flatten!\n modules.sort!\n modules.uniq.collect { |m| m.name }\n end",
"def desired_contents\n @environments.map {|env| env.dirname }\n end",
"def files\n info[\"Files\"].to_a\n end",
"def get_bag_paths\n bag_paths = Array.new\n \n Dir.glob(@path).each do |entry|\n if !(File.directory? entry) || entry == \".\" || entry == \"..\"\n next\n end\n \n bag_paths.push entry\n end\n \n return bag_paths\n end",
"def gemfile_path\n @gemfile_path ||= GEMFILES.map { |g| @config.pwd.join g }\n .find { |f| f.exist? }\n end",
"def manifest_files\n files = []\n exclude = Regexp.new(PROJ.exclude.join('|'))\n Find.find '.' do |path|\n path.sub! %r/^(\\.\\/|\\/)/o, ''\n next unless test ?f, path\n next if path =~ exclude\n files << path\n end\n files.sort!\nend",
"def files_path\n File.expand_path(\"#{Config.project_root}/files\")\n end",
"def load_paths\n [root.join('lib'), root.join('spec')].join(':')\n end",
"def files\n @files ||= []\n end",
"def files(uri)\n [].tap do |ary|\n ary.concat Dir[uri]\n search_paths.each { |p| ary.concat Dir[File.join p, uri] }\n end\n end",
"def paths; end",
"def paths; end",
"def paths; end",
"def paths; end",
"def paths; end",
"def get_file_absolute_paths path\n get_file_names(path).map { |file| File.join(path, file) }\n end"
] | [
"0.7420614",
"0.72867376",
"0.7222215",
"0.720861",
"0.71873003",
"0.71671003",
"0.71605766",
"0.7147663",
"0.7143445",
"0.7109207",
"0.7037739",
"0.70111775",
"0.69997823",
"0.69755334",
"0.695947",
"0.6948758",
"0.6928298",
"0.6908902",
"0.6896523",
"0.6893822",
"0.688396",
"0.6882413",
"0.6864864",
"0.6864695",
"0.68625987",
"0.68613505",
"0.68602246",
"0.6852662",
"0.68406224",
"0.68379325",
"0.68296003",
"0.6823797",
"0.6802105",
"0.6777677",
"0.6765325",
"0.6759945",
"0.6756124",
"0.6755547",
"0.67539626",
"0.67539626",
"0.67525214",
"0.67487407",
"0.6738881",
"0.6737071",
"0.6737071",
"0.67140865",
"0.67140865",
"0.67118585",
"0.67084104",
"0.66953146",
"0.6694997",
"0.6684239",
"0.668176",
"0.6665213",
"0.66650367",
"0.6662208",
"0.6639345",
"0.663742",
"0.6619092",
"0.66184765",
"0.6596974",
"0.65908366",
"0.65874237",
"0.65865386",
"0.6586378",
"0.6585256",
"0.65847635",
"0.6581738",
"0.65807706",
"0.6580505",
"0.6571504",
"0.6556035",
"0.65484816",
"0.65285206",
"0.6523617",
"0.6513228",
"0.6512622",
"0.6508039",
"0.64984727",
"0.64956635",
"0.64928395",
"0.64779395",
"0.6476431",
"0.6476102",
"0.64730436",
"0.6471434",
"0.647026",
"0.64696896",
"0.64670455",
"0.6465535",
"0.64639926",
"0.646394",
"0.6463642",
"0.64633036",
"0.6462433",
"0.6462433",
"0.6462433",
"0.6462433",
"0.6462433",
"0.6461713"
] | 0.7225063 | 2 |
Retreive versions of gem available in all configured targets (optionally recursively) | def dependency_versions(args = {}, &bl)
versions = args[:versions] || {}
check_deps = args[:dev] ? dev_deps : deps
check_deps.each do |dep|
unless versions.key?(dep.name)
begin
gem = Polisher::Gem.retrieve(dep.name)
versions.merge! gem.versions(args, &bl)
rescue
unknown = Polisher::VersionChecker.unknown_version(:all, dep.name, &bl)
versions.merge! dep.name => unknown
end
end
args[:versions] = versions
end
versions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def versions_for_targets\n versions_for_targets = []\n target_version_array.each_with_index do |target_version, i|\n if !target_version.nil?\n versions_for_targets.push(target_version)\n else\n versions_for_targets.push(nil) if allow_nils?\n end\n end\n multipackage? ? versions_for_targets : versions_for_targets[0]\n end",
"def available_versions\n return unless @version\n the_gem_line = gem_remote_list_output.scan(/^#{name}\\s.*$/).first\n the_gem_line.scan /\\d+\\.\\d+\\.\\d+/\n end",
"def available_versions\n the_gem_line = gem_remote_list_output.scan(/^#{name}\\s.*$/).first\n the_gem_line.scan /\\d+\\.\\d+\\.\\d+/\n end",
"def versions(args = {}, &bl)\n local_args = Hash[args]\n recursive = local_args[:recursive]\n dev_deps = local_args[:dev_deps]\n versions = local_args[:versions] || {}\n\n gem_versions = Polisher::VersionChecker.versions_for(name, &bl)\n versions.merge! name => gem_versions\n local_args[:versions] = versions\n\n if recursive\n versions.merge! dependency_versions local_args, &bl\n versions.merge! dependency_versions local_args.merge(:dev => true), &bl if dev_deps\n end\n\n versions\n end",
"def versions(args = {}, &bl)\n local_args = Hash[args]\n recursive = local_args[:recursive]\n dev_deps = local_args[:dev_deps]\n versions = local_args[:versions] || {}\n\n gem_versions = Polisher::VersionChecker.versions_for(name, &bl)\n versions.merge! name => gem_versions\n local_args[:versions] = versions\n\n if recursive\n versions.merge! dependency_versions local_args, &bl\n versions.merge! dependency_versions local_args.merge(:dev => true), &bl if dev_deps\n end\n\n versions\n end",
"def dependency_versions(args = {}, &bl)\n versions = {}\n args = {:recursive => true, :dev_deps => true, :versions => versions}.merge(args)\n deps.each do |dep|\n gem = Polisher::Gem.retrieve(dep.name)\n versions.merge!(gem.versions(args, &bl))\n end\n versions\n end",
"def find_gems(match, options={})\n return [] unless defined?(::Gem)\n ::Gem.search(match)\n end",
"def gems\n provisioner, version = @impl.split('-')\n get_gem_list(provisioner, version)\n end",
"def dependency_versions(args = {}, &bl)\n versions = args[:versions] || {}\n check_deps = args[:dev] ? dev_deps : deps\n\n check_deps.each do |dep|\n unless versions.key?(dep.name)\n begin\n gem = Polisher::Gem.retrieve(dep.name)\n versions.merge! gem.versions(args, &bl)\n rescue\n unknown = Polisher::VersionChecker.unknown_version(:all, dep.name, &bl)\n versions.merge! dep.name => unknown\n end\n end\n\n args[:versions] = versions\n end\n\n versions\n end",
"def versions_in_target(name, target)\n require 'polisher/targets'\n Polisher.target(target).versions_for(name)\n end",
"def get_repo_list\n Chef::Log.debug(\n \"Fetching all versions of #{new_resource.module_name} \" +\n \"from #{new_resource.repository}.\",\n )\n latest = powershell_out!(\n <<-EOH,\n $splat = @{\n Name = \"#{new_resource.module_name}\"\n Repository = \"#{new_resource.repository}\"\n AllVersions = $True\n }\n (Find-Module @splat).Version.ForEach({$_.ToString()})\n EOH\n ).stdout.to_s.chomp.split(\"\\r\\n\")\n Chef::Log.debug(\"Available versions: #{latest.join(', ')}\")\n\n return latest.map { |v| Gem::Version.new(v) }\n end",
"def get_all_versions\n []\n end",
"def get_alchemy_versions\n # first we try rubygems.org\n response = query_rubygems\n if response.code == \"200\"\n alchemy_versions = JSON.parse(response.body)\n alchemy_versions.collect { |h| h[\"number\"] }.sort\n else\n # rubygems.org not available?\n # then we try github\n response = query_github\n if response.code == \"200\"\n alchemy_tags = JSON.parse(response.body)\n alchemy_tags.collect { |h| h[\"name\"].tr(\"v\", \"\") }.sort\n else\n # no luck at all?\n raise UpdateServiceUnavailable\n end\n end\n end",
"def get_all_versions()\n return []\n end",
"def find_all req\n res = []\n\n return res unless @remote\n\n versions(req.name).each do |ver|\n if req.dependency.match? req.name, ver[:number]\n res << Gem::Resolver::APISpecification.new(self, ver)\n end\n end\n\n res\n end",
"def build_candidate_versions\n versions = []\n new_resource.package_name.each_with_index do |name, index|\n version = if new_resource.version && !new_resource.version[index].nil?\n powershell_exec(build_powershell_package_command(\"Find-Package '#{name}'\", new_resource.version[index]), timeout: new_resource.timeout).result\n else\n powershell_exec(build_powershell_package_command(\"Find-Package '#{name}'\"), timeout: new_resource.timeout).result\n end\n if version.empty?\n version = nil\n end\n version = version.strip if version.respond_to?(:strip)\n versions.push(version)\n end\n versions\n end",
"def stable_gem_versions(http_response)\n http_response.blank? ? [] : http_response.select { |val| val['prerelease'] == false }\nend",
"def gems(*args)\n gems.each{|g| gem(g) }\n end",
"def available_versions\n Mixlib::Install.available_versions(project, channel)\n end",
"def find_versions\n components.each do |c|\n version_list_file = c.versions\n if version_list_file.exist?\n return version_list_file\n end\n end\n nil\n end",
"def find_dependencies(env)\n args = [] if (env = env.dup).sub!(REGEXP_DEVPKG,'') # are we in compile mode?\n return [[], [], args] if args && env.empty?\n\n require 'rubygems/remote_fetcher'\n @@deps = YAML.load(fetch(env))['gems'] unless defined?(@@deps)\n @@deps.key?(spec.name) or return(args ? [[], [], args] : nil)\n\n # find dependencies\n case deps = @@deps[spec.name]\n when nil, \"*\" # for nil or '*', use the default extension name\n deps = [\"*\"]\n when String # string of space-delimited packages and extensions\n when Array # array of packages and extensions\n when Hash # hash of packages and extensions, indexed by version requirements\n reqs, deps = deps.find do |reqs, info| # deps is an array or space-delimited string\n Gem::Requirement.new(reqs.split(',')).satisfied_by?(spec.version)\n end\n reqs or return # can't find the right version\n deps ||= [\"*\"] # deps are nil, use the default extension name\n end\n deps = deps.strip.split(/\\s+/) if deps.is_a?(String)\n deps = deps.compact.uniq\n\n # helpful variables\n bcwd = Dir.pwd\n benv = File.dirname(env.split(/[?;#]/,2).first)\n name = \"#{spec.full_name}.tar.gz\"\n\n # grok dependencies\n pkgs, exts = [], []\n deps.each do |item|\n if item.include?(\"*\") || item =~ REGEXP_SCHEMA || item.include?(\".tar.gz\")\n exts << item unless args\n elsif item =~ REGEXP_DEVPKG\n pkgs << $' if args\n elsif item =~ REGEXP_DEVARG\n args << $' if args\n else\n pkgs << item unless args\n end\n end\n exts.map! do |item|\n case item\n when \"*\" then item = File.join(benv, name) # use complete default tarball name\n when /\\A\\*/ then item[0,1] = benv # path relative to env variable\n when /\\A[^\\/]/ then item[0,0] = bcwd + \"/\" # path relative to current directory\n end\n item.gsub(\"*\", name) # swap inline wildcards with default tarball name\n end\n [pkgs, exts, args]\n end",
"def component_versions(cmp)\n component_build_vars(cmp)['PACKAGE_VERSIONS']\nend",
"def gem_dependencies(rubygem)\n (latest = latest_gemspec(rubygem)) ?\n latest.dependencies.select {|e| e.type == :runtime }.map {|e| e.name} : []\n end",
"def stable_gem_versions(http_response)\n http_response.blank? ? [] : http_response.select { |val| val['prerelease'] == false }\n end",
"def available_versions\n Mixlib::Install.new(\n product_name: project_name,\n channel: channel_name.to_sym,\n user_agent_headers: ['omnitruck']\n ).available_versions\n rescue Mixlib::Install::Backend::ArtifactsNotFound\n # Return an empty array if no artifacts are found\n []\n end",
"def instaled_versions(tmplt_root)\n (Dir.entries(conf_distribs_local_path(tmplt_root)).map do |e|\n next if e == '.' || e == '..'\n begin\n v = AssUpdater::AssVersion.new(e.split('_').join('.'))\n v if v.redaction == conf_redaction\n rescue ArgumentError\n nil\n end\n end).compact\n end",
"def runtime_specific_gems\n []\n end",
"def find_all(req)\n res = []\n\n return res unless @remote\n\n if @to_fetch.include?(req.name)\n prefetch_now\n end\n\n versions(req.name).each do |ver|\n if req.dependency.match? req.name, ver[:number], @prerelease\n res << Gem::Resolver::APISpecification.new(self, ver)\n end\n end\n\n res\n end",
"def relevant_packages\n packages.select { |p| p['version'] == version }\n end",
"def versions_for(gem)\n versions_hash[gem].map { |version| version[1] }\n end",
"def get_last_versions\n @last_release_mods = {}\n helper = PuppetfileHelper.new(@options[:last_release_puppetfile], @options[:root_dir], false)\n helper.modules.each do |mod|\n @last_release_mods[mod[:name]] = mod[:desired_ref]\n end\n end",
"def get_last_versions\n @last_release_mods = {}\n helper = PuppetfileHelper.new(@options[:last_release_puppetfile], @options[:root_dir], false)\n helper.modules.each do |mod|\n @last_release_mods[mod[:name]] = mod[:desired_ref]\n end\n end",
"def dependent_gems(check_dev=true)\n out = []\n Gem::Specification.each do |spec|\n deps = check_dev ? spec.dependencies : spec.runtime_dependencies\n deps.each do |dep|\n if self.satisfies_requirement?(dep)\n sats = []\n find_all_satisfiers(dep) do |sat|\n sats << sat\n end\n out << [spec, dep, sats]\n end\n end\n end\n out\n end",
"def p4_versions\n dirs = Dir[\"../[0-9]*\"].sort_by { |s| Gem::Version.new(File.basename(s)) }\n dirs << \"../dev\"\n dirs.map { |d| File.basename d }\n end",
"def find_all req\n res = []\n\n versions(req.name).each do |ver|\n if req.dependency.match? req.name, ver[:number]\n res << Gem::DependencyResolver::APISpecification.new(self, ver)\n end\n end\n\n res\n end",
"def outdated\n remotes = Gem::SourceInfoCache.search(//)\n outdateds = []\n latest_specs.each do |_, local|\n name = local.name\n remote = remotes.select { |spec| spec.name == name }.\n sort_by { |spec| spec.version }.\n last\n outdateds << name if remote and local.version < remote.version\n end\n outdateds\n end",
"def find_gems\n @gems = RubygemsApi.call :all\n end",
"def target_version_array\n @target_version_array ||=\n begin\n target_version_array = []\n each_package do |package_name, new_version, current_version, candidate_version, magic_version|\n case action\n when :upgrade\n if version_equals?(current_version, new_version)\n # This is a short-circuit (mostly for the rubygems provider) to avoid needing to\n # expensively query the candidate_version which must come later. This only checks\n # exact matching, the check for fuzzy matching is later.\n logger.trace(\"#{new_resource} #{package_name} #{new_version} is already installed\")\n target_version_array.push(nil)\n elsif current_version.nil?\n # This is a simple check to see if we have any currently installed version at all, this is\n # safe to do before the allow_downgrade check so we check this before.\n logger.trace(\"#{new_resource} has no existing installed version. Installing install #{candidate_version}\")\n target_version_array.push(candidate_version)\n elsif !allow_downgrade && version_compare(current_version, candidate_version) == 1\n # This check for downgrading when allow_downgrade is false uses the current_version rather\n # than the magic_version since we never want to downgrade even if the constraints are not met\n # if the version is higher. This check does use the candidate_version and unlazies this so\n # there will a perf hit on idempotent use when allow_downgrade is false which is unavoidable.\n logger.trace(\"#{new_resource} #{package_name} has installed version #{current_version}, which is newer than available version #{candidate_version}. Skipping...)\")\n target_version_array.push(nil)\n elsif magic_version.nil?\n # This is the check for fuzzy matching of the installed_version, where if the installed version\n # does not match the desired version constraints (but is not an exact match) then we need to\n # install the candidate_version (this must come after the allow_downgrade check)\n logger.trace(\"#{new_resource} has an installed version that does not match the version constraint. Installing install #{candidate_version}\")\n target_version_array.push(candidate_version)\n elsif candidate_version.nil?\n # This check necessarily unlazies the candidate_version and may be expensive (connecting to\n # rubygems.org or whatever). It comes as late as possible.\n logger.trace(\"#{new_resource} #{package_name} has no candidate_version to upgrade to\")\n target_version_array.push(nil)\n elsif version_equals?(current_version, candidate_version)\n # This check sees if the candidate_version is already installed or if we should upgrade/update the\n # package. This is the normal idempotent behavior of :upgrade and is inherently expensive due to\n # unlazying the candidate_version. To prevent the perf hit the version may be specified with a full\n # version constraint. Then the cookbook can roll the version forward and use :upgrade to force version\n # pinning.\n logger.trace(\"#{new_resource} #{package_name} #{candidate_version} is already installed\")\n target_version_array.push(nil)\n else\n logger.trace(\"#{new_resource} #{package_name} is out of date, will update to #{candidate_version}\")\n target_version_array.push(candidate_version)\n end\n\n when :install\n if current_version && new_version && !allow_downgrade && version_compare(current_version, new_version) == 1\n # This is the idempotency guard for downgrades when downgrades are not allowed. This should perhaps raise\n # an exception since we were told to install an exact package version but we are silently refusing to do so\n # because a higher version is already installed. Maybe we need a flag for users to apply their preferred\n # declarative philosophy? This has to come early and outside of the two code paths below.\n logger.warn(\"#{new_resource} #{package_name} has installed version #{current_version}, which is newer than available version #{new_version}. Skipping...)\")\n target_version_array.push(nil)\n elsif new_version && !use_magic_version?\n # This is for \"non magic version using\" subclasses to do comparisons between the current_version and the\n # desired new_version. XXX: If we converted this to current_version_requirement_satisfied? and made it specific\n # to the current version check and then eliminated the magic_version, we might be able to eliminate separate codepaths\n # here, and eliminate the semantic confusion around the magic_version?\n if version_requirement_satisfied?(current_version, new_version)\n logger.trace(\"#{new_resource} #{package_name} #{current_version} satisfies #{new_version} requirement\")\n target_version_array.push(nil)\n else\n # XXX: some subclasses seem to depend on this behavior where the new_version can be different from the\n # candidate_version and we install the new_version, it seems like the candidate_version should be fixed to\n # be resolved correctly to the new_version for those providers. although it may just be unit test bugs.\n # it would be more correct to use the candidate_version here, but then it needs to be the correctly resolved\n # candidate_version against the new_version constraint.\n logger.trace(\"#{new_resource} #{package_name} #{current_version} needs updating to #{new_version}\")\n target_version_array.push(new_version)\n end\n elsif magic_version.nil?\n # This is for when we have a \"magic version using\" subclass and where the installed version does not match the\n # constraint specified in the new_version, so we need to upgrade to the candidate_version. This is the only\n # codepath in the :install branch which references the candidate_version so it is slow, but it is the path where\n # we need to do work anyway. XXX: should we check for candidate_version.nil? somewhere around here?\n logger.trace(\"#{new_resource} #{package_name} not installed, installing #{candidate_version}\")\n target_version_array.push(candidate_version)\n else\n logger.trace(\"#{new_resource} #{package_name} #{current_version} already installed\")\n target_version_array.push(nil)\n end\n\n else\n # in specs please test the public interface provider.run_action(:install) instead of provider.action_install\n raise \"internal error - target_version_array in package provider does not understand this action\"\n end\n end\n\n target_version_array\n end\n end",
"def installed_gems\n gems = []\n\n cmd = [attributes.gem_binary, 'list', '-l']\n cmd << '--prerelease' if attributes.prerelease\n\n run_command(cmd).stdout.each_line do |line|\n next unless /\\A([^ ]+) \\(([^\\)]+)\\)\\z/ =~ line.strip\n\n name = $1\n versions = $2.split(', ')\n gems << { name: name, versions: versions }\n end\n gems\n rescue Backend::CommandExecutionError\n []\n end",
"def required_gem_list\n Mack::Utils::GemManager.instance.required_gem_list\n end",
"def find_all(req)\n res = []\n\n dep = req.dependency\n\n return res if @ignore_dependencies and\n @always_install.none? {|spec| dep.match? spec }\n\n name = dep.name\n\n dep.matching_specs.each do |gemspec|\n next if @always_install.any? {|spec| spec.name == gemspec.name }\n\n res << Gem::Resolver::InstalledSpecification.new(self, gemspec)\n end unless @ignore_installed\n\n if consider_local?\n matching_local = @local.values.select do |spec, _|\n req.match? spec\n end.map do |spec, source|\n Gem::Resolver::LocalSpecification.new self, spec, source\n end\n\n res.concat matching_local\n\n begin\n if local_spec = @local_source.find_gem(name, dep.requirement)\n res << Gem::Resolver::IndexSpecification.new(\n self, local_spec.name, local_spec.version,\n @local_source, local_spec.platform)\n end\n rescue Gem::Package::FormatError\n # ignore\n end\n end\n\n res.delete_if do |spec|\n spec.version.prerelease? and not dep.prerelease?\n end\n\n res.concat @remote_set.find_all req if consider_remote?\n\n res\n end",
"def build_current_versions\n version_list = []\n new_resource.package_name.each_with_index do |name, index|\n version = if new_resource.version && !new_resource.version[index].nil?\n powershell_exec(build_powershell_package_command(\"Get-Package '#{name}'\", new_resource.version[index]), timeout: new_resource.timeout).result\n else\n powershell_exec(build_powershell_package_command(\"Get-Package '#{name}'\"), timeout: new_resource.timeout).result\n end\n if version.empty?\n version = nil\n end\n version = version.strip if version.respond_to?(:strip)\n version_list.push(version)\n end\n version_list\n end",
"def find_all(req)\n res = []\n\n return res unless @remote\n\n name = req.dependency.name\n\n @all[name].each do |uri, n|\n if req.match? n, @prerelease\n res << Gem::Resolver::IndexSpecification.new(\n self, n.name, n.version, uri, n.platform)\n end\n end\n\n res\n end",
"def remote_versions_for(name)\n require 'json'\n\n client.url = \"https://rubygems.org/api/v1/versions/#{name}.json\"\n client.follow_location = true\n client.http_get\n json = JSON.parse(client.body_str)\n json.collect { |version| version['number'] }\n end",
"def available_versions\n command = resource_or_provider_command\n self.class.validate_command(command)\n\n command_version = self.class.pip_version(command)\n if self.class.compare_pip_versions(command_version, '1.5.4') == -1\n available_versions_with_old_pip\n else\n available_versions_with_new_pip(command_version)\n end\n end",
"def store_all_versions\n @versions = Gems.versions @node.name\n raise \"Gem '#{@node.name}' not found\" unless @versions.is_a? Array\n store_versions_dates\n rescue => e\n @node.errors << e\n end",
"def versions_for_select(unit_member)\n static_options = [['Most Recent','']]\n dynamic_options = package_branch.packages.map {|p| [p.version, p.id]}\n static_options + dynamic_options\n end",
"def versions_for_select(unit_member)\n static_options = [['Most Recent','']]\n pb = package_branch\n pb.bind_to_scope(unit_member)\n dynamic_options = pb.packages.map {|p| [p.version, p.id]}\n static_options + dynamic_options\n end",
"def remote_dependencies(gem_name, _version)\n conn = Faraday.new(url: 'https://rubygems.org') do |h|\n h.headers[:content_type] = 'application/x-www-form-urlencoded'\n h.request :url_encoded\n h.adapter :excon\n end\n response = conn.get(\"/api/v1/gems/#{gem_name}.json\")\n dep_list = MultiJson.load(response.body)\n dep_list['dependencies'].values.flatten.map do |j|\n Gem::Dependency.new(\n j['name'],\n Gem::Requirement.new(j['requirements'].split(','))\n )\n end\n end",
"def versions(module_name)\n path = \"/v3/modules/#{module_name.tr('/','-')}\"\n response = @conn.get(path)\n\n if response.status != 200\n raise R10K::Error.new(\"Request to Puppet Forge '#{path}' failed. Status: #{response.status}\")\n end\n\n releases = response.body['releases'].reject { |r| r['deleted_at'] }\n releases = releases.map do |version_info|\n version_info['version']\n end\n releases.reverse\n end",
"def core_fetch_dependencies(deps, verbose)\n deps.each do |pkg_name, pkg_version|\n core_fetch_dependency pkg_name, pkg_version, :runtime, verbose\n end\n end",
"def find_all_satisfiers(dep)\n Gem::Specification.each do |spec|\n yield spec if spec.satisfies_requirement? dep\n end\n end",
"def resolve(bundles)\n bundles.select { |b|\n by_pkg = b.exports.find { |ex| ex.package == self.package }\n if by_pkg\n version_range.includes?(by_pkg.version)\n end\n }\n end",
"def merge_gemfiles(*path, unlock: [])\n gems_remotes = Set.new\n dependencies = Hash.new do |h, k|\n h[k] = Hash.new do |h, k|\n h[k] = Hash.new do |a, b|\n a[b] = Array.new\n end\n end\n end\n path.each do |gemfile|\n bundler_def = Bundler::Dsl.evaluate(gemfile, nil, [])\n gems_remotes |= bundler_def.send(:sources).rubygems_remotes.to_set\n bundler_def.dependencies.each do |d|\n d.groups.each do |group_name|\n if !d.platforms.empty?\n d.platforms.each do |platform_name|\n dependencies[group_name][platform_name][d.name] = d\n end\n else\n dependencies[group_name][''][d.name] = d\n end\n end\n end\n end\n\n contents = []\n gems_remotes.each do |g|\n g = g.to_s\n if g.end_with?('/')\n g = g[0..-2]\n end\n contents << \"source '#{g.to_s}'\"\n end\n dependencies.each do |group_name, by_platform|\n contents << \"group :#{group_name} do\"\n by_platform.each do |platform_name, deps|\n deps = deps.values.sort_by(&:name)\n if !platform_name.empty?\n contents << \" platform :#{platform_name} do\"\n platform_indent = \" \"\n end\n deps.each do |d|\n if d.source\n options = d.source.options.map { |k, v| \"#{k}: \\\"#{v}\\\"\" }\n end\n contents << [\" #{platform_indent}gem \\\"#{d.name}\\\", \\\"#{d.requirement}\\\"\", *options].join(\", \")\n end\n if !platform_name.empty?\n contents << \" end\"\n end\n end\n contents << \"end\"\n end\n contents.join(\"\\n\")\n end",
"def get_versions\n return if not File.directory? @parent_release_directory\n\n Find.find(@parent_release_directory) do |file|\n begin\n next unless file.end_with? '/current' and File.symlink? file and File.realpath(file)\n\n application_name = file.slice((@parent_release_directory.length+1)..-9)\n\n next if application_name == 'sample'\n\n @registry[application_name].add_current_version version: File.basename(File.readlink(file)), ctime: File.stat(file).ctime\n\n if File.symlink?(File.dirname(file) + '/previous') and File.realpath(File.dirname(file) + '/previous')\n version = File.basename(File.readlink(File.dirname(file) + '/previous'))\n ctime = File.stat(File.dirname(file) + '/previous').ctime\n @registry[application_name].add_previous_version version: version, ctime: ctime\n end\n rescue Errno::ENOENT\n end\n end\n end",
"def fetch_dependency_remote_specs(gem_names, &blk)\n Bundler.ui.debug \"Query Gemcutter Dependency Endpoint API: #{gem_names.join(' ')}\"\n uri = URI.parse(\"#{@remote_uri}api/v1/dependencies?gems=#{gem_names.join(\",\")}\")\n marshalled_deps = fetch(uri)\n gem_list = Marshal.load(marshalled_deps)\n\n spec_list = gem_list.map do |s|\n [s[:name], Gem::Version.new(s[:number]), s[:platform]]\n end\n deps_list = gem_list.map do |s|\n s[:dependencies].collect {|d| d.first }\n end.flatten.uniq\n\n [spec_list, deps_list]\n end",
"def all_versions\n r = []\n raw['update'].each do |h|\n r << h['version']\n end\n AssUpdater::AssVersion.convert_array r\n end",
"def dependencies\n version_req = if options[:version]\n ::Gem::Requirement.create(options[:version])\n else\n ::Gem::Requirement.default\n end\n if gem_dir\n ::Gem.clear_paths; ::Gem.path.unshift(gem_dir)\n ::Gem.source_index.refresh!\n end\n deps = []\n ::Gem.source_index.each do |fullname, gemspec| \n if version_req.satisfied_by?(gemspec.version)\n deps << ::Gem::Dependency.new(gemspec.name, \"= #{gemspec.version}\")\n end\n end\n ::Gem.clear_paths if gem_dir\n deps.sort\n end",
"def versions\n @versions ||= json_dir_names.sort_by { |v| Gem::Version.new(v) }.reverse!\n end",
"def gems\n @gems ||=\n Bundler.load.current_dependencies.map do |dependency|\n GemsBond::Gem.new(dependency)\n end\n end",
"def get_release_packages\n get_local_constraints\n\n if !@force && @installed.include?(@module_name)\n\n raise AlreadyInstalledError,\n :module_name => @module_name,\n :installed_version => @installed[@module_name].first.version,\n :requested_version => @version || (@conditions[@module_name].empty? ? :latest : :best),\n :local_changes => @installed[@module_name].first.local_changes\n end\n\n if @ignore_dependencies && @source == :filesystem\n @urls = {}\n @remote = { \"#{@module_name}@#{@version}\" => { } }\n @versions = {\n @module_name => [\n { :vstring => @version, :semver => SemVer.new(@version) }\n ]\n }\n else\n get_remote_constraints\n end\n\n @graph = resolve_constraints({ @module_name => @version })\n @graph.first[:tarball] = @filename if @source == :filesystem\n resolve_install_conflicts(@graph) unless @force\n\n # This clean call means we never \"cache\" the module we're installing, but this\n # is desired since module authors can easily rerelease modules different content but the same\n # version number, meaning someone with the old content cached will be very confused as to why\n # they can't get new content.\n # Long term we should just get rid of this caching behavior and cleanup downloaded modules after they install\n # but for now this is a quick fix to disable caching\n Puppet::Forge::Cache.clean\n download_tarballs(@graph, @graph.last[:path])\n end",
"def versions name # :nodoc:\n if @data.key?(name)\n return @data[name]\n end\n\n uri = @dep_uri + \"?gems=#{name}\"\n str = Gem::RemoteFetcher.fetcher.fetch_path uri\n\n Marshal.load(str).each do |ver|\n @data[ver[:name]] << ver\n end\n\n @data[name]\n end",
"def runtime_dependencies\n dependencies.select(&:runtime?)\n end",
"def get_locked_dep_versions(curr_deps, gem)\n all_deps = []\n curr_specs = Bundler::LockfileParser.new(Bundler.read_file(Bundler.default_lockfile)).specs rescue []\n curr_deps.each do |curr_dep|\n found_spec = curr_specs.detect {|spec| spec.name.to_s == curr_dep.name.to_s}\n dep_to_push = OpenStruct.new\n #scope = []\n if found_spec\n dep_to_push.name = found_spec.name\n dep_to_push.version = found_spec.version\n else\n dep_to_push.name = curr_dep.name\n dep_to_push.version = curr_dep.version\n end\n dep_to_push.path = curr_dep.path\n #scope = curr_dep.groups if curr_dep.groups\n #dep_to_push.scope = scope\n\n all_deps.push(dep_to_push)\n end\n #return all_deps.map {|dep| {:name => dep.name, :version => dep.version, :scope => dep.scope}}.sort{|a, b| a[:name] <=> b[:name]}\n return all_deps.map {|dep| {:name => dep.name, :version => dep.version, :path => dep.path}}.sort{|a, b| a[:name] <=> b[:name]}\n end",
"def installed_versions(name, requirement)\n if gem_installed?(name, requirement)\n Chef::Log.info \"Gem #{name} (#{requirement}) found in OpsWorks user space.\"\n # from rubygems/specification.rb#find_all_by_name\n Gem::Dependency.new(name, requirement).matching_specs\n else\n Chef::Log.debug \"Gem #{name} (#{requirement}) not found in OpsWorks user space.\"\n []\n end\n end",
"def get_last_release_versions\n # determine last SIMP release\n last_release = nil\n last_puppetfile = nil\n debug('Determining last SIMP release')\n\n Dir.chdir(\"#{@options[:work_dir]}/simp-core\") do |dir|\n `git fetch -t origin 2>/dev/null`\n tags = `git tag -l`.split(\"\\n\")\n debug(\"Available simp-core tags = #{tags}\")\n last_release = (tags.sort { |a,b| Gem::Version.new(a) <=> Gem::Version.new(b) })[-1]\n `git checkout -q tags/#{last_release}`\n src = File.join(dir, 'Puppetfile.pinned')\n last_puppetfile = File.join(@options[:work_dir], \"Puppetfile.#{last_release}\")\n debug(\"Copying simp-core #{last_release} Puppetfile.pinned into #{last_puppetfile}\")\n FileUtils.cp(src, last_puppetfile)\n `git checkout -q master`\n end\n\n debug(\"Retrieving component versions for SIMP #{last_release} from #{last_puppetfile}\")\n @last_release_versions = {}\n helper = PuppetfileHelper.new(last_puppetfile, @options[:work_dir], false)\n helper.modules.each do |mod|\n @last_release_versions[mod[:name]] = mod[:desired_ref]\n end\n end",
"def fetch_versions\n http_get(\"#{host}/#{Configuration.versions_file}\").body\n end",
"def each(options={}, &block)\n return unless apply?(nil, options)\n\n gem_name = (options[:gem] || options[:from]).to_s\n\n if vers = options[:version]\n spec = ::Gem::Specification.find_by_name(gem_name, vers)\n else\n spec = ::Gem::Specification.find_by_name(gem_name)\n end\n\n return unless spec\n\n #spec.activate\n\n spec.require_paths.each do |path|\n traverse(File.join(spec.full_gem_path, path), &block)\n end\n end",
"def versions(name) # :nodoc:\n if @data.key?(name)\n return @data[name]\n end\n\n uri = @dep_uri + name\n str = Gem::RemoteFetcher.fetcher.fetch_path uri\n\n lines(str).each do |ver|\n number, platform, dependencies, requirements = parse_gem(ver)\n\n platform ||= \"ruby\"\n dependencies = dependencies.map {|dep_name, reqs| [dep_name, reqs.join(\", \")] }\n requirements = requirements.map {|req_name, reqs| [req_name.to_sym, reqs] }.to_h\n\n @data[name] << { name: name, number: number, platform: platform, dependencies: dependencies, requirements: requirements }\n end\n\n @data[name]\n end",
"def find(name)\n # look into each gempath for a matching file, sort by version (roughly), \n # and return the last hit\n gem_paths.\n map { |gem_path| Dir.glob(\"#{gem_path}/gems/#{name}-[0-9]*\") }.\n flatten.\n sort_by { |gem_path| gem_path.gsub(/.*\\/gems\\/[^-]+-/, \"\") }.\n last\n end",
"def package_names_for_targets\n package_names_for_targets = []\n target_version_array.each_with_index do |target_version, i|\n if !target_version.nil?\n package_name = package_name_array[i]\n package_names_for_targets.push(package_name)\n else\n package_names_for_targets.push(nil) if allow_nils?\n end\n end\n multipackage? ? package_names_for_targets : package_names_for_targets[0]\n end",
"def ensure_gem_versions_defined_in_appraisal_are_used\n gems_defined_in_appraisal = retrieve_gems_from_gemfile(ENV['BUNDLE_GEMFILE'])\n gems_defined_in_gemfile = retrieve_gems_from_gemfile('Gemfile').collect(&:gem_name)\n\n gems_defined_in_appraisal.reject { |l| gems_defined_in_gemfile.include? l.gem_name }.each do |gem|\n add_gem gem.gem_name, gem.attributes.join(',')\n end\n end",
"def gem_dependencies(list, gem_dependencies, options = {})\n gem_dependencies.each do |gd|\n if options['excludes'] && options['excludes'].to_s.split(',').include?(gd.name)\n next\n end\n\n gs = gd.matching_specs.first\n if gs\n unless list[gs.name]\n list[gs.name] = gs\n unless gs.dependencies.empty?\n list = gem_dependencies(list, gs.dependencies, options)\n end\n end\n else\n unless list[gd.name]\n list[gd.name] = Gem::Specification.new(\n gd.name,\n gd.requirements_list.last.scan(/[\\d\\.\\w]+/).first\n )\n rm_dep = remote_dependencies(gd.name, gd.requirements_list.last)\n unless rm_dep.empty?\n list = gem_dependencies(list, rm_dep, options)\n end\n end\n end\n end\n\n list\n end",
"def list(pattern = /.*/)\n if Gem::Specification.respond_to?(:each)\n Gem::Specification.select{|spec| spec.name =~ pattern }\n else\n Gem.source_index.gems.values.select{|spec| spec.name =~ pattern }\n end\n end",
"def merge_gemfiles(*path, ruby_version: nil, unlock: [])\n gems_remotes = Set.new\n dependencies = Hash.new do |h, k|\n h[k] = Hash.new do |i, j|\n i[j] = Hash.new do |a, b|\n a[b] = Array.new\n end\n end\n end\n path.each do |gemfile|\n bundler_def =\n begin Bundler::Dsl.evaluate(gemfile, nil, [])\n rescue Exception => e\n cleaned_message = e\n .message\n .gsub(/There was an error parsing([^:]+)/,\n \"Error in gem definitions\")\n .gsub(/# from.*/, \"\")\n raise ConfigError, cleaned_message\n end\n gems_remotes |= bundler_def.send(:sources).rubygems_remotes.to_set\n bundler_def.dependencies.each do |d|\n d.groups.each do |group_name|\n if d.platforms.empty?\n dependencies[group_name][\"\"][d.name] = d\n else\n d.platforms.each do |platform_name|\n dependencies[group_name][platform_name][d.name] = d\n end\n end\n end\n end\n end\n\n contents = []\n gems_remotes.each do |g|\n g = g.to_s\n g = g[0..-2] if g.end_with?(\"/\")\n contents << \"source '#{g}'\"\n end\n if ruby_version\n contents << \"ruby \\\"#{ruby_version}\\\" if respond_to?(:ruby)\"\n end\n valid_keys = %w[group groups git path glob name branch ref tag\n require submodules platform platforms type\n source install_if]\n dependencies.each do |group_name, by_platform|\n contents << \"group :#{group_name} do\"\n by_platform.each do |platform_name, deps|\n deps = deps.values.sort_by(&:name)\n unless platform_name.empty?\n contents << \" platform :#{platform_name} do\"\n platform_indent = \" \"\n end\n deps.each do |d|\n if d.source\n options = d.source.options.dup\n options.delete_if { |k, _| !valid_keys.include?(k) }\n options = options.map { |k, v| \"#{k}: \\\"#{v}\\\"\" }\n end\n contents << [\" #{platform_indent}gem \\\"#{d.name}\\\",\n \\\"#{d.requirement}\\\"\", *options].join(\", \")\n end\n contents << \" end\" unless platform_name.empty?\n end\n contents << \"end\"\n end\n contents.join(\"\\n\")\n end",
"def depend_upon(match_name) #, constraint)\n list = []\n each do |name, libs|\n case libs\n when Library\n list << libs if libs.requirements.any?{ |r| match_name == r['name'] } \n else\n libs.each do |lib|\n list << lib if lib.requirements.any?{ |r| match_name == r['name'] } \n end\n end\n end\n list\n end",
"def pythons\n deps.map(&:to_formula)\n .select { |f| f.name.match?(/^python@\\d\\.\\d+$/) }\n .sort_by(&:version)\n .map { |f| f.opt_libexec/\"bin/python\" }\n end",
"def installed_versions; end",
"def depends_upon(match_name) #, constraint)\n list = []\n $LEDGER.each do |name, libs|\n case libs\n when Library\n list << libs if libs.requirements.any?{ |r| match_name == r['name'] } \n else\n libs.each do |lib|\n list << lib if lib.requirements.any?{ |r| match_name == r['name'] } \n end\n end\n end\n list\n end",
"def get_gem_names\n fetcher = Gem::SpecFetcher.fetcher\n\n list, = fetcher.available_specs(:complete)\n\n tuples = list.values.first\n\n tuples.map do |tuple,|\n tuple = tuple.to_a\n case tuple.last\n when Gem::Platform::RUBY then\n tuple[0, 2]\n else\n tuple\n end.join '-'\n end\n end",
"def versions_matching(dep)\n remote_versions_for(dep.name).select { |v|\n dep.match? dep.name, v\n }\n end",
"def read_versions\n spec_files.map do |spec_file|\n spec = File.read(spec_file)\n spec.match(/^\\s*Version:\\s*(\\S+)$/)[1]\n end\nend",
"def find_dependency_versions(dependency)\n versions = []\n specs = Dir[File.join(gem_dir, 'specifications', \"#{dependency.name}-*.gemspec\")]\n unless specs.empty?\n specs.inject(versions) do |versions, gemspec_path|\n versions << gemspec_path[/-([\\d\\.]+)\\.gemspec$/, 1]\n end\n end\n versions.sort.reverse\n end",
"def versions name\n if @data.key?(name)\n return @data[name]\n end\n\n uri = @dep_uri + \"?gems=#{name}\"\n str = Gem::RemoteFetcher.fetcher.fetch_path uri\n\n Marshal.load(str).each do |ver|\n @data[ver[:name]] << ver\n end\n\n @data[name]\n end",
"def reverse_dependencies(rubygem)\n ::Gem.source_index.gems.values.select {|e| e.dependencies.any? {|e| e.name == rubygem && e.type == :runtime}}.\n map {|e| \"#{e.name}-#{e.version}\" }\n end",
"def gems; end",
"def gems; end",
"def gems; end",
"def _extract_versions(pb_versioneds)\r\n\t\tversions = []\r\n\t\tfor versioned in pb_versioneds\r\n\t\t\tversions << [versioned.value, versioned.version]\r\n end\r\n\t\treturn _resolve_conflicts(versions)\r\n end",
"def versions\n @versions ||= run( :versions, '--bare' ).lines.map( &:chomp )\n end",
"def get_update_pkgs\n get_update_dirs\n delete_contrib\n return @update_pkgs\n end",
"def get_requirements\n result = `rake gems 2>&1`\n parse_required(result) + parse_missing(result) + parse_deps(result)\n end",
"def find_dependencies(deps=nil, verbose=false)\n \n deps ||= all_dependencies\n\n search_list = Array(deps)\n found = []\n ret = []\n \n # if we discover a new local package via indirect dependencies then\n # it's dependencies will be fetchable one time.\n fetchable = Set.new\n \n until search_list.empty?\n name, version = search_list.shift\n\n if dup = found.find{|p| p.name == name}\n # already found, check for conflicts\n next if satisfied_by?(version, dup.version)\n raise PackageConflictError.new(name, dup.version, version)\n end\n\n pkg = locate_package(name, version, verbose)\n if pkg.nil? && fetchable.include?(name)\n fetchable.reject! { |x| x == name }\n core_fetch_dependency(name, version, :runtime, true) \n pkg = locate_package name, version, verbose\n end\n \n raise PackageNotFoundError.new(name, version) unless pkg\n\n found << pkg\n\n # Look up dependencies of dependencies\n new_deps = Array(pkg.dependencies) + Array(pkg.dependencies_build)\n if has_local_package? pkg.name\n new_deps += Array(pkg.dependencies_development)\n new_deps.each { |dep| fetchable.add dep.first }\n end\n \n search_list += new_deps\n\n ret << pkg\n end\n\n ret\n end",
"def gems\n Recommendable.config.ratable_classes.map { |klass| gemd_for(klass) }.flatten\n end",
"def find_all(req)\n @specs.values.select do |spec|\n req.match? spec\n end.map do |spec|\n source = Gem::Source::Vendor.new @directories[spec]\n Gem::Resolver::VendorSpecification.new self, spec, source\n end\n end",
"def compute_revdeps\n result = Hash.new { |h, k| h[k] = Set.new }\n each_autobuild_package do |pkg|\n pkg.dependencies.each do |pkg_name|\n result[pkg_name] << pkg.name\n end\n pkg.optional_dependencies.each do |pkg_name|\n result[pkg_name] << pkg.name\n end\n pkg.os_packages.each do |pkg_name|\n result[pkg_name] << pkg.name\n end\n end\n result\n end",
"def get_dependencies(lib_path)\n\tdeps = []\n\tentry_name_regex = /(.*)\\(compatibility version.*\\)/\n\t`otool -L '#{lib_path}'`.strip.split(\"\\n\").each do |entry|\n\t\tmatch = entry_name_regex.match(entry)\n\t\tif (match)\n\t\t\tdep_path = match[1].strip\n\n\t\t\t# Note - otool lists dependencies separately for each architecture\n\t\t\t# in a universal binary - only return the unique paths\n\t\t\tdeps << dep_path if !deps.include?(dep_path)\n\t\tend\n\tend\n\treturn deps\nend",
"def get_dependencies(lib_path)\n\tdeps = []\n\tentry_name_regex = /(.*)\\(compatibility version.*\\)/\n\t`otool -L '#{lib_path}'`.strip.split(\"\\n\").each do |entry|\n\t\tmatch = entry_name_regex.match(entry)\n\t\tif (match)\n\t\t\tdep_path = match[1].strip\n\n\t\t\t# Note - otool lists dependencies separately for each architecture\n\t\t\t# in a universal binary - only return the unique paths\n\t\t\tdeps << dep_path if !deps.include?(dep_path)\n\t\tend\n\tend\n\treturn deps\nend",
"def fetch_all_remote_specs(&blk)\n Bundler.ui.info \"Fetching source index for #{@remote_uri}\"\n Bundler.ui.debug \"Fetching modern index\"\n Gem.sources = [\"#{@remote_uri}\"]\n begin\n # Fetch all specs, minus prerelease specs\n Gem::SpecFetcher.new.list(true, false).each(&blk)\n # Then fetch the prerelease specs\n begin\n Gem::SpecFetcher.new.list(false, true).each(&blk)\n rescue Gem::RemoteFetcher::FetchError\n Bundler.ui.warn \"Could not fetch prerelease specs from #{@remote_uri}\"\n end\n rescue Gem::RemoteFetcher::FetchError\n raise Bundler::HTTPError, \"Could not reach #{@remote_uri}\"\n end\n end",
"def latest_version_in_target(name, target)\n versions_in_target(name, target).collect { |v| ::Gem::Version.new v }.max\n end"
] | [
"0.69748926",
"0.6747975",
"0.67198837",
"0.65630853",
"0.6534792",
"0.6527612",
"0.6520567",
"0.6399236",
"0.6348885",
"0.6348494",
"0.6296808",
"0.61587715",
"0.6118991",
"0.60960525",
"0.6090008",
"0.60530555",
"0.6030857",
"0.6023128",
"0.60221905",
"0.6021368",
"0.6020561",
"0.60192204",
"0.6017481",
"0.6009521",
"0.59990096",
"0.59934616",
"0.5979033",
"0.5969924",
"0.5946524",
"0.5936123",
"0.5934565",
"0.5934565",
"0.5933209",
"0.5932653",
"0.59110117",
"0.59069675",
"0.5900656",
"0.5898152",
"0.5887923",
"0.58798647",
"0.5873839",
"0.5853295",
"0.5813445",
"0.57877845",
"0.57831544",
"0.577773",
"0.5775878",
"0.5770862",
"0.57623655",
"0.57459146",
"0.5741395",
"0.57277507",
"0.5725121",
"0.5701952",
"0.56930983",
"0.56771713",
"0.5668755",
"0.56681114",
"0.5664925",
"0.5655273",
"0.5652001",
"0.5644942",
"0.5644496",
"0.5639242",
"0.56390405",
"0.56362313",
"0.56245726",
"0.5616566",
"0.56082857",
"0.5605957",
"0.5594111",
"0.5590888",
"0.55799073",
"0.5577074",
"0.5576586",
"0.55597156",
"0.55479026",
"0.55396616",
"0.55245936",
"0.55232656",
"0.5500448",
"0.54910964",
"0.5482056",
"0.54756236",
"0.5473792",
"0.5469558",
"0.5469558",
"0.5469558",
"0.5469418",
"0.54664236",
"0.5466329",
"0.546406",
"0.5462507",
"0.5448759",
"0.5445628",
"0.54405856",
"0.54294294",
"0.54293853",
"0.54214245",
"0.5412785"
] | 0.63326913 | 10 |
(and dependencies if specified) | def versions(args = {}, &bl)
local_args = Hash[args]
recursive = local_args[:recursive]
dev_deps = local_args[:dev_deps]
versions = local_args[:versions] || {}
gem_versions = Polisher::VersionChecker.versions_for(name, &bl)
versions.merge! name => gem_versions
local_args[:versions] = versions
if recursive
versions.merge! dependency_versions local_args, &bl
versions.merge! dependency_versions local_args.merge(:dev => true), &bl if dev_deps
end
versions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dependencies; end",
"def dependencies; end",
"def dependencies; end",
"def direct_dependencies; end",
"def dependencies=(_arg0); end",
"def adopt_dependencies\n super if defined? super\n end",
"def request_dependencies\n end",
"def install_dependencies\n raise 'Not implemented'\n end",
"def add_dependencies\n self.extra_deps = normalize_deps extra_deps\n self.extra_dev_deps = normalize_deps extra_dev_deps\n\n case name\n when \"hoe\" then\n # do nothing? these deps are already in the hoe spec in the Rakefile\n else\n version = VERSION.split(/\\./).first(2).join(\".\")\n dependency \"hoe\", \"~> #{version}\", :development\n end\n\n seen = {}\n\n extra_deps.each do |dep|\n next if seen[dep.first]\n seen[dep.first] = true\n\n spec.add_dependency(*dep)\n end\n\n extra_dev_deps.each do |dep|\n next if seen[dep.first]\n seen[dep.first] = true\n\n spec.add_development_dependency(*dep)\n end\n end",
"def dependencies\n\t\t0\n\tend",
"def load_dependencies\n dependencies.each { |dependency| dependency }\n end",
"def dependency_respects_ordering?; @dependency_respects_ordering; end",
"def load_dependencies( file_list, force_require=true )\r\n loader = DependencyLoader.new( file_list, force_require )\r\n loader.load_dependencies\r\nend",
"def dependencies\n []\n end",
"def dependencies\n @dependencies ||= {}\n end",
"def dependencies\n raise \"#{self.class} needs to overwrite dependencies\"\n end",
"def dependencies\n []\n end",
"def dependencies\n []\n end",
"def dependencies\n @dependencies ||= []\n end",
"def dependency_met?\n true\n end",
"def dependencies\n @dependencies ||= []\n end",
"def dependencies\n @dependencies ||= []\n end",
"def dependencies\n @dependencies ||= []\n end",
"def dependencies\n @dependencies ||= []\n end",
"def dependent; end",
"def dependent; end",
"def initial_dependencies\n []\n end",
"def dependencies\n EMPTY_SET\n end",
"def prerequisites\n\tsuper\n end",
"def prerequisites\n\tsuper\n end",
"def dependencies\n self.config.depends || []\n end",
"def fetch_development_dependencies # :nodoc:\n end",
"def require_gems; end",
"def dependencies( *args )\n names = args # note: for now assume all args are just names\n # e.g. 'pluto-models', 'pluto-update', etc.\n deps = @versions.select do |rec| names.include?( rec[0] ) end\n .map do |rec| [rec[0], rec[1]] end\n\n ## todo/fix: throw exception if dependency is missing!\n ## names.size == deps.size\n puts \"names.size == deps.size #{names.size} == #{deps.size}\"\n deps\n end",
"def conscientious_require; end",
"def load_dependencies\r\n @local_gems.each do |gem_info|\r\n gem_file_name = gem_info.gem_file\r\n gem_name = installed_as_name_for( short_form_of_gem_name( gem_file_name ) )\r\n @required_gem_names.delete gem_file_name\r\n end\r\n @required_gem_paths.each do |gem_path|\r\n gem_short_name = short_form_of_gem_name gem_path\r\n if @required_gem_names.include? gem_short_name\r\n puts \"installing #{gem_path}\"\r\n installer = @force_require ? PreloadingInstaller.new( gem_path, @local_gems ) : Installer.new( gem_path )\r\n installer.install\r\n end\r\n end\r\n end",
"def enable_dependency_loading=(_arg0); end",
"def enable_dependency_loading=(_arg0); end",
"def enable_dependency_loading; end",
"def enable_dependency_loading; end",
"def libs; end",
"def dependencies\n @dependencies ||= begin\n YARD::Registry.all(:dependency)\n end\nend",
"def dependencies\n @dependencies ||= Set.new\n end",
"def package_depends_on\n depends_on\n end",
"def required_dependencies\n dependencies - optional_dependencies\n end",
"def load_dependencies\n result = zh_client.dependencies(repo_name)\n\n result[\"dependencies\"].each do |hash|\n blocking = add_or_find(hash[\"blocking\"])\n blocked = add_or_find(hash[\"blocked\"])\n\n add_edge(blocked, blocking)\n end\n end",
"def runtime_dependencies\n dependencies.select(&:runtime?)\n end",
"def requires *deps\n return unless @dependency_lib\n\n @parents.concat(deps).uniq!\n deps.each do |dep|\n @dependency_lib.dependencies[dep].each{|d| d.add_child(@name) }\n end\n end",
"def dependencies\n @dependencies\n end",
"def check_dependencies\n ok = true\n\n @config.each_pair { |type, values|\n next if !values.instance_of?(Array)\n _shortclass, cfg_name, _cfg_plural, _classname = MU::Cloud.getResourceNames(type, false)\n next if !cfg_name\n values.each { |resource|\n next if !resource.kind_of?(Hash) or resource[\"dependencies\"].nil?\n addme = []\n deleteme = []\n\n resource[\"dependencies\"].each { |dependency|\n dependency[\"their_phase\"] ||= dependency[\"phase\"]\n dependency.delete(\"phase\")\n dependency[\"my_phase\"] ||= dependency[\"no_create_wait\"] ? \"groom\" : \"create\"\n dependency.delete(\"no_create_wait\")\n # make sure the thing we depend on really exists\n sibling = haveLitterMate?(dependency['name'], dependency['type'])\n if !sibling\n MU.log \"Missing dependency: #{type}{#{resource['name']}} needs #{cfg_name}{#{dependency['name']}}\", MU::ERR\n ok = false\n next\n end\n\n # Fudge dependency declarations to quash virtual_names that we know\n # are extraneous. Note that wee can't do all virtual names here; we\n # have no way to guess which of a collection of resources is the\n # real correct one.\n if sibling['virtual_name'] == dependency['name']\n real_resources = []\n found_exact = false\n resource[\"dependencies\"].each { |dep_again|\n if dep_again['type'] == dependency['type'] and sibling['name'] == dep_again['name']\n dependency['name'] = sibling['name']\n found_exact = true\n break\n end\n }\n if !found_exact\n all_siblings = haveLitterMate?(dependency['name'], dependency['type'], has_multiple: true)\n if all_siblings.size > 0\n all_siblings.each { |s|\n newguy = dependency.clone\n newguy['name'] = s['name']\n addme << newguy\n }\n deleteme << dependency\n MU.log \"Expanding dependency which maps to virtual resources to all matching real resources\", MU::NOTICE, details: { sibling['virtual_name'] => addme }\n next\n end\n end\n end\n\n if dependency['their_phase'] == \"groom\"\n sibling['dependencies'].each { |sib_dep|\n next if sib_dep['type'] != cfg_name or sib_dep['their_phase'] != \"groom\"\n cousin = haveLitterMate?(sib_dep['name'], sib_dep['type'])\n if cousin and cousin['name'] == resource['name']\n MU.log \"Circular dependency between #{type} #{resource['name']} <=> #{dependency['type']} #{dependency['name']}\", MU::ERR, details: [ resource['name'] => dependency, sibling['name'] => sib_dep ]\n ok = false\n end\n }\n end\n\n # Check for a circular relationship that will lead to a deadlock\n # when creating resource. This only goes one layer deep, and does\n # not consider groom-phase deadlocks.\n if dependency['their_phase'] == \"groom\" or\n dependency['my_phase'] == \"groom\" or (\n !MU::Cloud.resourceClass(sibling['cloud'], type).deps_wait_on_my_creation and\n !MU::Cloud.resourceClass(resource['cloud'], type).waits_on_parent_completion\n )\n next\n end\n\n if sibling['dependencies']\n sibling['dependencies'].each { |sib_dep|\n next if sib_dep['type'] != cfg_name or sib_dep['my_phase'] == \"groom\"\n cousin = haveLitterMate?(sib_dep['name'], sib_dep['type'])\n if cousin and cousin['name'] == resource['name']\n MU.log \"Circular dependency between #{type} #{resource['name']} <=> #{dependency['type']} #{dependency['name']}\", MU::ERR, details: [ resource['name'] => dependency, sibling['name'] => sib_dep ]\n ok = false\n end\n }\n end\n }\n resource[\"dependencies\"].reject! { |dep| deleteme.include?(dep) }\n resource[\"dependencies\"].concat(addme)\n resource[\"dependencies\"].uniq!\n\n }\n }\n\n ok\n end",
"def core_fetch_dependencies(deps, verbose)\n deps.each do |pkg_name, pkg_version|\n core_fetch_dependency pkg_name, pkg_version, :runtime, verbose\n end\n end",
"def process_project_dependencies\n BRIX11.log_warning(\"missing #process_project_dependencies implementation for #{self.to_s}\")\n end",
"def add_dependencies(groups, dependencies) # :nodoc:\n return unless (groups & @without_groups).empty?\n\n dependencies.each do |dep|\n @set.gem dep.name, *dep.requirement.as_list\n end\n end",
"def dependencies( names )\n names.each do |name|\n if calculation = fetch( name, nil )\n calculation.dependencies.each do |dependency|\n names << dependency unless names.include?( dependency )\n end\n end\n end\n end",
"def get_dependencies\n @dependencies\n end",
"def refresh_dependencies(options = {}); end",
"def inject_dependencies\n add_to_load_path\n add_to_dependency_load_paths\n add_to_dependency_load_once_paths\n add_to_mixable_app_types\n end",
"def requires\n []\n end",
"def check_dependencies!(dep)\n depend_on(dep)\n depend_on_asset(dep)\n rescue Sprockets::FileNotFound\n end",
"def dependencies(use_cache: false, debug: false)\n @dependencies ||= {}\n @loadbalancers ||= []\n @firewall_rules ||= []\n\n if @config.nil?\n return [@dependencies, @vpc, @loadbalancers]\n end\n if use_cache and @dependencies.size > 0\n return [@dependencies, @vpc, @loadbalancers]\n end\n @config['dependencies'] = [] if @config['dependencies'].nil?\n\n loglevel = debug ? MU::NOTICE : MU::DEBUG\n\n # First, general dependencies. These should all be fellow members of\n # the current deployment.\n @config['dependencies'].each { |dep|\n @dependencies[dep['type']] ||= {}\n next if @dependencies[dep['type']].has_key?(dep['name'])\n handle = @deploy.findLitterMate(type: dep['type'], name: dep['name']) if !@deploy.nil?\n if !handle.nil?\n MU.log \"Loaded dependency for #{self}: #{dep['name']} => #{handle}\", loglevel\n @dependencies[dep['type']][dep['name']] = handle\n else\n # XXX yell under circumstances where we should expect to have\n # our stuff available already?\n end\n }\n\n # Special dependencies: my containing VPC\n if self.class.can_live_in_vpc and !@config['vpc'].nil?\n @vpc, @nat = myVpc(@config['vpc'], loglevel: loglevel, debug: debug)\n elsif self.class.cfg_name == \"vpc\"\n @vpc = self\n end\n\n # Special dependencies: LoadBalancers I've asked to attach to an\n # instance.\n if @config.has_key?(\"loadbalancers\")\n @loadbalancers = [] if !@loadbalancers\n @config['loadbalancers'].each { |lb|\n MU.log \"Loading LoadBalancer for #{self}\", MU::DEBUG, details: lb\n if @dependencies.has_key?(\"loadbalancer\") and\n @dependencies[\"loadbalancer\"].has_key?(lb['concurrent_load_balancer'])\n @loadbalancers << @dependencies[\"loadbalancer\"][lb['concurrent_load_balancer']]\n else\n if !lb.has_key?(\"existing_load_balancer\") and\n !lb.has_key?(\"deploy_id\") and !@deploy.nil?\n lb[\"deploy_id\"] = @deploy.deploy_id\n end\n lbs = MU::MommaCat.findStray(\n @config['cloud'],\n \"loadbalancer\",\n deploy_id: lb[\"deploy_id\"],\n cloud_id: lb['existing_load_balancer'],\n name: lb['concurrent_load_balancer'],\n region: @config[\"region\"],\n calling_deploy: @deploy,\n dummy_ok: true\n )\n @loadbalancers << lbs.first if !lbs.nil? and lbs.size > 0\n end\n }\n end\n\n # Munge in external resources referenced by the existing_deploys\n # keyword\n if @config[\"existing_deploys\"] && !@config[\"existing_deploys\"].empty?\n @config[\"existing_deploys\"].each { |ext_deploy|\n if ext_deploy[\"cloud_id\"]\n found = MU::MommaCat.findStray(\n @config['cloud'],\n ext_deploy[\"cloud_type\"],\n cloud_id: ext_deploy[\"cloud_id\"],\n region: @config['region'],\n dummy_ok: false\n ).first\n \n MU.log \"Couldn't find existing resource #{ext_deploy[\"cloud_id\"]}, #{ext_deploy[\"cloud_type\"]}\", MU::ERR if found.nil?\n @deploy.notify(ext_deploy[\"cloud_type\"], found.config[\"name\"], found.deploydata, mu_name: found.mu_name, triggering_node: @mu_name)\n elsif ext_deploy[\"mu_name\"] && ext_deploy[\"deploy_id\"]\n MU.log \"#{self}: Importing metadata for #{ext_deploy[\"cloud_type\"]} #{ext_deploy[\"mu_name\"]} from #{ext_deploy[\"deploy_id\"]}\", MU::DEBUG\n found = MU::MommaCat.findStray(\n @config['cloud'],\n ext_deploy[\"cloud_type\"],\n deploy_id: ext_deploy[\"deploy_id\"],\n mu_name: ext_deploy[\"mu_name\"],\n region: @config['region'],\n dummy_ok: false\n ).first\n \n if found.nil?\n MU.log \"Couldn't find existing resource #{ext_deploy[\"mu_name\"]}/#{ext_deploy[\"deploy_id\"]}, #{ext_deploy[\"cloud_type\"]}\", MU::ERR\n else\n @deploy.notify(ext_deploy[\"cloud_type\"], found.config[\"name\"], found.deploydata, mu_name: ext_deploy[\"mu_name\"], triggering_node: @mu_name, no_write: true)\n end\n else\n MU.log \"Trying to find existing deploy, but either the cloud_id is not valid or no mu_name and deploy_id where provided\", MU::ERR\n end\n }\n end\n\n if @config['dns_records'] && !@config['dns_records'].empty?\n @config['dns_records'].each { |dnsrec|\n if dnsrec.has_key?(\"name\")\n if dnsrec['name'].start_with?(@deploy.deploy_id.downcase) && !dnsrec['name'].start_with?(@mu_name.downcase)\n MU.log \"DNS records for #{@mu_name} seem to be wrong, deleting from current config\", MU::WARN, details: dnsrec\n dnsrec.delete('name')\n dnsrec.delete('target')\n end\n end\n }\n end\n\n return [@dependencies, @vpc, @loadbalancers]\n end",
"def has_dependencies?\n update_for.length > 0 or requires.length > 0\n end",
"def get_dependencies(_fidl, _interaction_types, _project_dependencies)\n # noop\n end",
"def resolve_dependencies!\n return unless Config.resolve? && targets.any?\n\n puts 'resolving dependencies...'\n each_threaded(targets) do |target|\n Depends.resolve(target, self)\n end\n end",
"def before_resolution\n output.print 'Resolving dependencies...'\n end",
"def dependencies\n manager.dependencies\n end",
"def bundler_dependencies_for(bundler_runtime, *groups); end",
"def test_dependencies\n []\n end",
"def test_dependencies\n []\n end",
"def vendor(dependencies)\n return nil if dependencies.nil? || dependencies.empty?\n @dep_list = Resolver.resolve(dependencies, @cache, @cwd, @backend)\n end",
"def fetch_dependencies()\n\t\"berks vendor cookbooks #{(@debug ? '-v' : '-q')}\"\n end",
"def require_libs(*libs); end",
"def add_dependencies(dependencies, providers)\r\n dependencies.each do |dependency|\r\n add_dependency(dependency, providers)\r\n end\r\n end",
"def dependencies(source, done=[])\n d_path = source.ext(\"d\") # get the dependency file\n Rake::Task[d_path].invoke # ensure the dependency file exists\n d_file = IO.read(d_path) # read the dependencies from dependency file\n d_file = d_file.split(': ')[1].gsub(\"\\n\",'').gsub('\\\\ ','').gsub(/\\s+/,' ').split(' ') # get a list of dependencies\n d_list = [] # list of dependencies\n # only save dependencies which are in our source directories\n d_file.each do |d|\n SRC_DIRS.each do |dir|\n if File.dirname(d)==dir then\n d_list << d\n end\n end\n end\n # get the dependencies of these dependencies, if we don't know them already\n done << source.ext(\"o\")\n done.uniq!\n d_list.each do |d|\n d = d.ext(\"o\")\n next if done.include? d\n done += dependencies(d, done)\n end\n done.uniq!\n return done\nend",
"def collect_dependencies(dependency, known_dependencies: {})\n dep_spec = dependency.matching_specs\n return known_dependencies if dep_spec.empty?\n\n dep_spec = dep_spec.first\n known_dependencies[dep_spec.name] = dep_spec.version\n dep_spec.dependencies.each do |dep|\n unless known_dependencies.has_key?(dep.name)\n collect_dependencies(dep, known_dependencies: known_dependencies)\n end\n end\n known_dependencies\n end",
"def requires(*args)\n normalize_list(args).each do |dependency|\n @available.add_required(dependency)\n end\n end",
"def dependencies(use_cache: false)\n @dependencies = {} if @dependencies.nil?\n @loadbalancers = [] if @loadbalancers.nil?\n if @config.nil?\n return [@dependencies, @vpc, @loadbalancers]\n end\n if use_cache and @dependencies.size > 0\n return [@dependencies, @vpc, @loadbalancers]\n end\n @config['dependencies'] = [] if @config['dependencies'].nil?\n\n # First, general dependencies. These should all be fellow members of\n # the current deployment.\n @config['dependencies'].each { |dep|\n @dependencies[dep['type']] ||= {}\n next if @dependencies[dep['type']].has_key?(dep['name'])\n handle = @deploy.findLitterMate(type: dep['type'], name: dep['name']) if !@deploy.nil?\n if !handle.nil?\n MU.log \"Loaded dependency for #{self}: #{dep['name']} => #{handle}\", MU::DEBUG\n @dependencies[dep['type']][dep['name']] = handle\n else\n # XXX yell under circumstances where we should expect to have\n # our stuff available already?\n end\n }\n\n # Special dependencies: my containing VPC\n if self.class.can_live_in_vpc and !@config['vpc'].nil?\n MU.log \"Loading VPC for #{self}\", MU::DEBUG, details: @config['vpc']\n if !@config['vpc'][\"vpc_name\"].nil? and @deploy\n sib_by_name = @deploy.findLitterMate(name: @config['vpc']['vpc_name'], type: \"vpcs\", return_all: true)\n if sib_by_name.is_a?(Array)\n if sib_by_name.size == 1\n @vpc = matches.first\n else\n# XXX ok but this is the wrong place for this really the config parser needs to sort this out somehow\n # we got multiple matches, try to pick one by preferred subnet\n # behavior\n sib_by_name.each { |sibling|\n all_private = sibling.subnets.map { |s| s.private? }.all?(true)\n all_public = sibling.subnets.map { |s| s.private? }.all?(false)\n if all_private and [\"private\", \"all_private\"].include?(@config['vpc']['subnet_pref'])\n @vpc = sibling\n break\n elsif all_public and [\"public\", \"all_public\"].include?(@config['vpc']['subnet_pref'])\n @vpc = sibling\n break\n else\n MU.log \"Got multiple matching VPCs for #{@mu_name}, so I'm arbitrarily choosing #{sibling.mu_name}\"\n @vpc = sibling\n break\n end\n }\n end\n else\n @vpc = sib_by_name\n end\n end\n\n if !@vpc and !@config['vpc'][\"vpc_name\"].nil? and\n @dependencies.has_key?(\"vpc\") and\n @dependencies[\"vpc\"].has_key?(@config['vpc'][\"vpc_name\"])\n @vpc = @dependencies[\"vpc\"][@config['vpc'][\"vpc_name\"]]\n elsif !@vpc\n tag_key, tag_value = @config['vpc']['tag'].split(/=/, 2) if !@config['vpc']['tag'].nil?\n if !@config['vpc'].has_key?(\"vpc_id\") and\n !@config['vpc'].has_key?(\"deploy_id\") and !@deploy.nil?\n @config['vpc'][\"deploy_id\"] = @deploy.deploy_id\n end\n vpcs = MU::MommaCat.findStray(\n @config['cloud'],\n \"vpc\",\n deploy_id: @config['vpc'][\"deploy_id\"],\n cloud_id: @config['vpc'][\"vpc_id\"],\n name: @config['vpc'][\"vpc_name\"],\n tag_key: tag_key,\n tag_value: tag_value,\n region: @config['vpc'][\"region\"],\n calling_deploy: @deploy,\n dummy_ok: true\n )\n @vpc = vpcs.first if !vpcs.nil? and vpcs.size > 0\n end\n if !@vpc.nil? and (\n @config['vpc'].has_key?(\"nat_host_id\") or\n @config['vpc'].has_key?(\"nat_host_tag\") or\n @config['vpc'].has_key?(\"nat_host_ip\") or\n @config['vpc'].has_key?(\"nat_host_name\")\n )\n\n nat_tag_key, nat_tag_value = @config['vpc']['nat_host_tag'].split(/=/, 2) if !@config['vpc']['nat_host_tag'].nil?\n\n @nat = @vpc.findBastion(\n nat_name: @config['vpc']['nat_host_name'],\n nat_cloud_id: @config['vpc']['nat_host_id'],\n nat_tag_key: nat_tag_key,\n nat_tag_value: nat_tag_value,\n nat_ip: @config['vpc']['nat_host_ip']\n )\n\n if @nat.nil?\n if !@vpc.cloud_desc.nil?\n @nat = @vpc.findNat(\n nat_cloud_id: @config['vpc']['nat_host_id'],\n nat_filter_key: \"vpc-id\",\n region: @config['vpc'][\"region\"],\n nat_filter_value: @vpc.cloud_id,\n credentials: @config['credentials']\n )\n else\n @nat = @vpc.findNat(\n nat_cloud_id: @config['vpc']['nat_host_id'],\n region: @config['vpc'][\"region\"],\n credentials: @config['credentials']\n )\n end\n end\n end\n elsif self.class.cfg_name == \"vpc\"\n @vpc = self\n end\n\n # Special dependencies: LoadBalancers I've asked to attach to an\n # instance.\n if @config.has_key?(\"loadbalancers\")\n @loadbalancers = [] if !@loadbalancers\n @config['loadbalancers'].each { |lb|\n MU.log \"Loading LoadBalancer for #{self}\", MU::DEBUG, details: lb\n if @dependencies.has_key?(\"loadbalancer\") and\n @dependencies[\"loadbalancer\"].has_key?(lb['concurrent_load_balancer'])\n @loadbalancers << @dependencies[\"loadbalancer\"][lb['concurrent_load_balancer']]\n else\n if !lb.has_key?(\"existing_load_balancer\") and\n !lb.has_key?(\"deploy_id\") and !@deploy.nil?\n lb[\"deploy_id\"] = @deploy.deploy_id\n end\n lbs = MU::MommaCat.findStray(\n @config['cloud'],\n \"loadbalancer\",\n deploy_id: lb[\"deploy_id\"],\n cloud_id: lb['existing_load_balancer'],\n name: lb['concurrent_load_balancer'],\n region: @config[\"region\"],\n calling_deploy: @deploy,\n dummy_ok: true\n )\n @loadbalancers << lbs.first if !lbs.nil? and lbs.size > 0\n end\n }\n end\n\n return [@dependencies, @vpc, @loadbalancers]\n end",
"def set_dependencies\n Console.show 'There are no dependencies for this scroll', 'info'\n end",
"def process_dependencies(data)\n import_paths = data.scan(IMPORT_SCANNER).flatten.compact.uniq\n import_paths.each do |path|\n pathname = begin\n #TODO: use resolve to partialize paths\n context.resolve(path)\n rescue Sprockets::FileNotFound\n nil\n end\n \n unless pathname.nil? || passthrough?(pathname)\n # mark dependency in Sprockets context\n context.depend_on(path)\n # recurse for more dependencies\n process_dependencies File.read(pathname)\n end\n end\n end",
"def os_dependencies\n []\n end",
"def resolve_dependencies\r\n @nodes.each do |node|\r\n puts \"processing #{node}\"\r\n\r\n node.outgoing_dependencies do |dependency|\r\n providers = nodes_satisfying(dependency.target)\r\n node.add_dependency(dependency, providers)\r\n end\r\n \r\n node.dependencies.values.each { |vals| vals.sort! }\r\n end\r\n end",
"def requirements; end",
"def requirements; end",
"def requirements; end",
"def requirements; end",
"def dependency_target\n self.name == \"hoe\" ? extra_deps : extra_dev_deps\n end",
"def dependencies\n spec.dependencies\n end",
"def dependencies\n spec.dependencies\n end",
"def check_for_libraries; end",
"def local_deps\n @local_deps ||= build_local_dependency_list\n end",
"def _requires\n @_requires ||= requires\n end",
"def dependencies_satisfied?\n missing_dependencies.empty?\n end",
"def update_dependencies()\n\t\"berks vendor cookbooks #{(@debug ? '-d' : '-q')}\"\n end",
"def merge_dependencies(data)\n data['dependencies'].each do |dep|\n add_dependency(dep['name'], dep['version_requirement'], dep['repository'])\n end\n\n # Clear dependencies so @data dependencies are not overwritten\n data.delete 'dependencies'\n end",
"def import(deps)\n @dependencies += deps\n end",
"def dependencies\n @dependencies ||= Payload::RailsLoader.load\n end",
"def build_gems; end",
"def packages; end",
"def depends(name)\n @dependencies << name unless @dependencies.include?(name)\n end",
"def require_lib(*libs); end",
"def gem_dependencies(list, gem_dependencies, options = {})\n gem_dependencies.each do |gd|\n if options['excludes'] && options['excludes'].to_s.split(',').include?(gd.name)\n next\n end\n\n gs = gd.matching_specs.first\n if gs\n unless list[gs.name]\n list[gs.name] = gs\n unless gs.dependencies.empty?\n list = gem_dependencies(list, gs.dependencies, options)\n end\n end\n else\n unless list[gd.name]\n list[gd.name] = Gem::Specification.new(\n gd.name,\n gd.requirements_list.last.scan(/[\\d\\.\\w]+/).first\n )\n rm_dep = remote_dependencies(gd.name, gd.requirements_list.last)\n unless rm_dep.empty?\n list = gem_dependencies(list, rm_dep, options)\n end\n end\n end\n end\n\n list\n end",
"def dependencies(pkg)\n pkg.resolve_optional_dependencies\n deps_rock_packages = pkg.dependencies.map do |pkg_name|\n debian_name(Autoproj.manifest.package(pkg_name).autobuild)\n end.sort\n\n pkg_osdeps = Autoproj.osdeps.resolve_os_dependencies(pkg.os_packages)\n # There are limitations regarding handling packages with native dependencies\n #\n # Currently gems need to converted into debs using gem2deb\n # These deps dependencies are updated here before uploading a package\n # \n # Generation of the debian packages from the gems can be done in postprocessing step\n # i.e. see convert_gems\n \n deps_osdeps_packages = []\n native_package_manager = Autoproj.osdeps.os_package_handler\n _, native_pkg_list = pkg_osdeps.find { |handler, _| handler == native_package_manager }\n\n deps_osdeps_packages += native_pkg_list if native_pkg_list\n\n # Update global list\n @osdeps += deps_osdeps_packages\n\n non_native_handlers = pkg_osdeps.collect do |handler, pkg_list|\n if handler != native_package_manager\n [handler, pkg_list]\n end\n end.compact\n\n non_native_handlers.each do |pkg_handler, pkg_list|\n # Convert native ruby gems package names to rock-xxx \n if pkg_handler.kind_of?(Autoproj::PackageManagers::GemManager)\n pkg_list.each do |name,version|\n @ruby_gems << [name,version]\n deps_osdeps_packages << debian_ruby_name(name)\n end\n else\n raise ArgumentError, \"cannot package #{pkg.name} as it has non-native dependencies (#{pkg_list}) -- #{pkg_handler.class} #{pkg_handler}\"\n end\n end\n\n # Remove duplicates\n @osdeps.uniq!\n @ruby_gems.uniq!\n\n # Return rock packages and osdeps\n [deps_rock_packages, deps_osdeps_packages]\n end"
] | [
"0.83350015",
"0.83350015",
"0.83350015",
"0.8048307",
"0.74851626",
"0.69822156",
"0.6963211",
"0.6946507",
"0.6849558",
"0.68485314",
"0.6848463",
"0.68482226",
"0.68170995",
"0.6816483",
"0.67942774",
"0.6782293",
"0.678214",
"0.6765038",
"0.67462504",
"0.6739112",
"0.66256255",
"0.66256255",
"0.66256255",
"0.66256255",
"0.662511",
"0.662511",
"0.66214216",
"0.6618678",
"0.6607967",
"0.6607967",
"0.660292",
"0.659694",
"0.6562785",
"0.6497368",
"0.6482089",
"0.64775056",
"0.64463717",
"0.64463717",
"0.6438393",
"0.6438393",
"0.64251155",
"0.6424168",
"0.64137167",
"0.640268",
"0.6396934",
"0.638247",
"0.637087",
"0.63512796",
"0.635113",
"0.63441783",
"0.6334062",
"0.63169265",
"0.63012224",
"0.6269308",
"0.6268703",
"0.6256731",
"0.6250846",
"0.6235904",
"0.62316746",
"0.6223798",
"0.61819756",
"0.6172306",
"0.61674017",
"0.61640626",
"0.6163545",
"0.6158994",
"0.61534494",
"0.61534494",
"0.61492217",
"0.61420363",
"0.61352545",
"0.612077",
"0.61170346",
"0.6105815",
"0.608865",
"0.6080642",
"0.60486805",
"0.60457474",
"0.6040372",
"0.603709",
"0.6035071",
"0.6035071",
"0.6035071",
"0.6035071",
"0.6032392",
"0.60133547",
"0.60133547",
"0.6012631",
"0.6010114",
"0.5995406",
"0.5992174",
"0.5984742",
"0.59803325",
"0.5979688",
"0.5979427",
"0.59786713",
"0.59753454",
"0.5965089",
"0.59646934",
"0.59542626",
"0.5952442"
] | 0.0 | -1 |
Return diff of content in this gem against other | def diff(other)
require_cmd! diff_cmd
out = nil
begin
this_dir = unpack
other_dir = other.is_a?(Polisher::Gem) ? other.unpack :
(other.is_a?(Polisher::Git::Repo) ? other.path : other)
result = AwesomeSpawn.run("#{diff_cmd} -r #{this_dir} #{other_dir}")
out = result.output.gsub("#{this_dir}", 'a').gsub("#{other_dir}", 'b')
rescue
ensure
FileUtils.rm_rf this_dir unless this_dir.nil?
FileUtils.rm_rf other_dir unless other_dir.nil? ||
!other.is_a?(Polisher::Gem)
end
out
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_diff wA, wB\n\n # puts \"---------------------------------> generating diff for #{wA} and #{wB}\"\n # sort by magnitude of id\n # returns w1 has earlier id than w2\n wA < wB ? w1id = wA : w1id = wB\n wA < wB ? w2id = wB : w2id = wA\n\n # get refs to whole works\n w1 = Work.find(w1id)\n w2 = Work.find(w2id)\n\n # check they belong to same project\n errors.add(:project, \"projects don't match\") unless w1.project_id == w2.project_id\n\n project = Project.find(w2.project_id) # same as w1\n\n\n # ----------- make diffs ------------ #\n\n # set values to diff from neighbord\n w1_md = w1.file_content_md.force_encoding(\"UTF-8\") if !w1.file_content_md.nil?\n w1_html = w1.file_content_html.force_encoding(\"UTF-8\") if !w1.file_content_html.nil?\n w1_text = w1.file_content_text.force_encoding(\"UTF-8\") if !w1.file_content_text.nil?\n\n # **note** self.file_content_md is coming from ReverseMarkdown now, instead of PandocRuby\n diff_md_val = Diffy::Diff.new(w1_md ,w2.file_content_md).to_s\n diff_html_val = Diffy::Diff.new(w1_md ,w2.file_content_md).to_s(:html)\n diff_text_val = Diffy::Diff.new(w1_text ,w2.file_content_text).to_s\n\n ### ALWAYS DIFF INTO :HTML FORMAT SO WE CAN DISPLAY IT NEATLY.\n ### ALWAYS DIFF !EMPTY RIGHT/LEFT\n diff_left_val = Diffy::SplitDiff.new(w1_md ,w2.file_content_md, :format => :html, :allow_empty_diff => false).left if !w1_md.nil?\n diff_right_val = Diffy::SplitDiff.new(w1_md ,w2.file_content_md, :format => :html, :allow_empty_diff => false).right if !w1_md.nil?\n\n # _text diffs for pdfs and plain text docs\n diff_left_text_val = Diffy::SplitDiff.new(w1_text ,w2.file_content_text, :format => :html, :allow_empty_diff => false).left if !w1_text.nil?\n diff_right_text_val = Diffy::SplitDiff.new(w1_text ,w2.file_content_text, :format => :html, :allow_empty_diff => false).right if !w1_text.nil?\n\n # ** .scrub! ensures we don't get any fucked up character encoding errors from mysql2\n # if !diff_md_val.nil? ensures we're dealing with a diffable doc (ie not a picture)\n diff_md_val.force_encoding(\"UTF-8\").scrub! if !diff_md_val.nil? #.encode!('UTF-8', :invalid => :replace, :undef => :replace, :replace => '')!diff_md_val.nil?\n diff_html_val.force_encoding(\"UTF-8\").scrub! if !diff_html_val.nil?\n diff_text_val.force_encoding(\"UTF-8\").scrub! if !diff_text_val.nil?\n\n diff_left_val.force_encoding(\"UTF-8\").scrub! if !diff_left_val.nil?\n diff_right_val.force_encoding(\"UTF-8\").scrub! if !diff_right_val.nil?\n\n # diff_left_text_val.force_encoding(\"UTF-8\").scrub! if !diff_left_val.nil?\n # diff_right_text_val.force_encoding(\"UTF-8\").scrub! if !diff_right_val.nil?\n # diff_left_val.force_encoding(\"UTF-8\").scrub! if !diff_left_val.nil?\n # diff_right_val.force_encoding(\"UTF-8\").scrub! if !diff_right_val.nil?\n diff_left_text_val.force_encoding(\"UTF-8\").scrub! if !diff_left_text_val.nil?\n diff_right_text_val.force_encoding(\"UTF-8\").scrub! if !diff_right_text_val.nil?\n\n # ----------- update or create diff ------------ #\n\n # update_or_create for, well, updating or creating\n diff = Diff.where(project_id: project.id, work1: w1id, work2: w2id).first_or_create\n diff.update!(\n diff_md: diff_md_val,\n diff_html: diff_html_val,\n diff_text: diff_text_val,\n left: diff_left_val,\n right: diff_right_val,\n left_text: diff_left_text_val,\n right_text: diff_right_text_val\n )\n\n end",
"def diff(other)\n HQMF::Measure::LogicExtractor.get_measure_logic_diff(self,other,true)\n end",
"def display_diff(version1, version2)\n version1_text = render_wiki_content(:content => version1)\n version2_text = render_wiki_content(:content => version2)\n diff(version1_text, version2_text)\n end",
"def compute_diff\n original_content_file = Tempfile.new(rand(1024).to_s)\n original_content_file.open\n original_content_file.write(content)\n original_content_file.flush\n diff = `diff #{original_content_file.path} #{tempfile.path}`\n diff.gsub!(/> (.*\\n)/m, '\\1'.green)\n diff.gsub!(/< (.*\\n)/m, '\\1'.red)\n ensure\n original_content_file.close\n original_content_file.unlink\n diff\n end",
"def diff_to_compare; end",
"def diff_strings(a, b)\n require 'tempfile'\n require 'open3'\n\n # Create files\n Tempfile.open('old') do |old_file|\n Tempfile.open('new') do |new_file|\n # Write files\n old_file.write(a)\n old_file.flush\n new_file.write(b)\n new_file.flush\n\n # Diff\n cmd = [ 'diff', '-u', old_file.path, new_file.path ]\n Open3.popen3(*cmd) do |stdin, stdout, stderr|\n result = stdout.read\n return (result == '' ? nil : result)\n end\n end\n end\n rescue Errno::ENOENT\n warn 'Failed to run `diff`, so no diff with the previously compiled ' \\\n 'content will be available.'\n nil\n end",
"def diff(other)\n if engine != other.engine && @input_engine\n [:engine, engine, other.engine]\n elsif version != other.version\n [:version, version, other.version]\n elsif engine_version != other.engine_version && @input_engine\n [:engine_version, engine_version, other.engine_version]\n elsif patchlevel != other.patchlevel && @patchlevel\n [:patchlevel, patchlevel, other.patchlevel]\n end\n end",
"def diff2; end",
"def generate_diff\n jsons = version_jsons.map { |j| pretty_json(j) }\n differ = Differ.send(diff_method, *jsons).format_as(:html)\n differ.gsub!('<ins', \"\\n<ins\") if diff_method == :diff_by_line\n @diff = sanitize(differ).html_safe\n end",
"def diff(v1, v2)\n repos.git.diff(v1, v2, path)\n end",
"def diff(other, options={})\n Differences::Entry.compute(self, other, diff_criteria(options), options)\n end",
"def diff(other)\n if engine != other.engine && @input_engine\n [:engine, engine, other.engine]\n elsif !version || !matches?(version, other.version)\n [:version, version, other.version]\n elsif @input_engine && !matches?(engine_version, other.engine_version)\n [:engine_version, engine_version, other.engine_version]\n elsif patchlevel && (!patchlevel.is_a?(String) || !other.patchlevel.is_a?(String) || !matches?(patchlevel, other.patchlevel))\n [:patchlevel, patchlevel, other.patchlevel]\n end\n end",
"def diff\n return if diffs.empty?\n\n minimized_hunk.diff(:unified) + NEWLINE\n end",
"def diff(other_sha1)\n git \"diff #{other_sha1} -- #{@path}\"\n end",
"def differ\n @differ ||= Differ.new(externals)\n end",
"def content_diff\n if params[:version] && !params[:version].match?(/^[1-9]\\d*$/)\n render(plain: \"400 Bad Request: version parameter must be positive integer\", status: :bad_request)\n return\n end\n obj_version = params[:version].to_i if params[:version]&.match?(/^[1-9]\\d*$/)\n subset = params[:subset] ||= 'all'\n render(xml: MoabStorageService.content_diff(druid, params[:content_metadata], subset, obj_version).to_xml)\n rescue ArgumentError => e\n render(plain: \"400 Bad Request: #{e}\", status: :bad_request)\n rescue Moab::MoabRuntimeError => e\n render(plain: \"500 Unable to get content diff: #{e}\", status: :internal_server_error)\n Honeybadger.notify(e)\n end",
"def diff1; end",
"def diff\n @diff ||= instance.client.createDiffHTML(padID: pad.id, startRev: start_rev, endRev: end_rev)\n end",
"def diff(other)\n Distance.diff_total(self, other, true)\n end",
"def diff_unified(text_old, text_new, label=\"--- old\\n+++ new\\n\", context=3)\n tmp_old = \"_tmp.old.#{rand()}\"\n tmp_new = \"_tmp.new.#{rand()}\"\n File.open(tmp_old, 'w') {|f| f.write(text_old) }\n File.open(tmp_new, 'w') {|f| f.write(text_new) }\n begin\n #diff = `diff -u #{tmp_old} #{tmp_new}`\n diff = `diff --unified=#{context} #{tmp_old} #{tmp_new}`\n ensure\n File.unlink(tmp_old)\n File.unlink(tmp_new)\n end\n diff.sub!(/\\A\\-\\-\\-.*\\n\\+\\+\\+.*\\n/, label.to_s)\n return diff\n end",
"def diff\n @diff ||= begin\n commit.diffs.collect{|diff| diff.diff}.join(\"\\n\")\n end\n end",
"def diff\n deprecation_notice!\n downstream = @cisauraus.downstreams(app, 1).first\n verify_downstream! downstream\n\n print_and_flush \"Comparing #{app} to #{downstream}...\"\n\n diff = @cisauraus.diff(app)\n print_and_flush \"done, \"\n\n if diff.size > 0\n display \"#{app} ahead by #{diff.size} #{plural('commit', diff.size)}:\"\n diff.each do |commit|\n commit_detail = `git log -n 1 --pretty=format:\" %h %ad %s (%an)\" --date=short #{commit} 2>/dev/null`\n if $?.exitstatus == 0\n display commit_detail\n else\n display \" #{commit}\"\n end\n end\n else\n display \"everything is up to date\"\n end\n end",
"def difference\n end",
"def diff(other)\n\t\tif other.is_a? Hash\n\t\t\treturn int_diff(other)\n\t\tend\n\t\t\n\t\tif other.is_a? RHash\n\t\t\treturn int_diff(other)\n\t\tend\t\n\tend",
"def evaluateDiffResult()\n\n end",
"def diff(&block); end",
"def persistable_diff(a, b)\n diff = Diff::LCS.diff a, b\n reify_diff_element(diff).as_json\n end",
"def unified_diff(text_old, text_new, label=\"--- old\\n+++ new\\n\", context=3)\n msg = \"\\\\ No newline at end of string\"\n lines_old = _text2lines(text_old, msg)\n lines_new = _text2lines(text_new, msg)\n #\n buf = \"#{label}\"\n len = 0\n prevhunk = hunk = nil\n diffs = Diff::LCS.diff(lines_old, lines_new)\n diffs.each do |diff|\n hunk = Diff::LCS::Hunk.new(lines_old, lines_new, diff, context, len)\n if hunk.overlaps?(prevhunk)\n hunk.unshift(prevhunk)\n else\n buf << prevhunk.diff(:unified) << \"\\n\"\n end if prevhunk\n len = hunk.file_length_difference\n prevhunk = hunk\n end\n buf << prevhunk.diff(:unified) << \"\\n\" if prevhunk\n return buf\n end",
"def diff_output\n `\n git diff \\\n --diff-filter=AM \\\n --ignore-space-at-eol \\\n --no-color \\\n --cached \\\n -p \\\n -- '*.rb' '*.rake'\n `\n end",
"def diff_and_markup(s1, s2, ignore_limit=1)\n diffs=Diff::LCS.sdiff(s1, s2).map {|lcs_change| handle_lcs_change( lcs_change ) }\n changes_to_chunks( diffs, ignore_limit )\n end",
"def diff(fn1,fn2)\n result = ''\n f1 = File.open(fn1)\n f2 = File.open(fn2)\n while f1.eof? == false and f2.eof? == false\n line1 = f1.gets\n line2 = f2.gets\n result << \"<#{line1}\\n>#{line2}\\n\" if line1 != line2\n end\n if f1.eof? == false\n while f1.eof? == false\n line1 = f1.gets\n result << \"<#{line1}\\n\"\n end\n end\n if f2.eof? == false\n while f2.eof? == false\n line2 = f2.gets\n result \">#{line2}\\n\"\n end\n end\n f1.close\n f2.close\n result\nend",
"def diff\n element_name = happy_path? ? @processor.kind.output_name : @processor.kind.error_name\n html_diff(\n @ciat_file.element(element_name).as_file,\n @ciat_file.element(element_name, :generated).as_file, \n @ciat_file.element(element_name, :diff).as_file)\n end",
"def current_diff(a_hash, another_hash)\n\n relevant_diffs = a_hash.diff(another_hash)\n @ignored_files = [\"metadata.json\", \".gitignore\"]\n @ignored_files.each do |file|\n relevant_diffs.delete(file)\n end\n relevant_diffs\n\n end",
"def diff\n require \"tempfile\"\n new_file = Tempfile.new([\"new_config.\", \".yml\"])\n new_file.write(sorted_file)\n result = `git diff --no-index -- #{file} #{new_file.path}`.gsub(\n no_slash_beginning(new_file.path),\n no_slash_beginning(file)\n )\n ensure\n new_file.close\n new_file.unlink\n result\n end",
"def diff(other, callbacks = nil, &block)\n Diff::LCS.diff(self, other, callbacks, &block)\n end",
"def difference(rt1, rt2)\n return template_tags(rt1) - template_tags(rt2)\n end",
"def native(from,to)\n command = \"cd #{@repodir} ; git diff --name-status #{from} #{to}\"\n puts \"Checking difference : \\n#{command}\"\n result = `#{command}`\n exitcode = $?\n exit -1 unless exitcode == 0\n return result.split(/\\n/)\n end",
"def diff url\n parse_response HTTParty.get \"#{url}.diff\"\n end",
"def diffed(old, new)\n differ = Differ.diff_by_line(new, old)\n differ.to_s[/\\{[^}]+\\}/][1...-1].gsub(/\\s{2,}/, '')\n end",
"def get_content_diff(subset = :all, version = nil)\n if Dor::Config.stacks.local_workspace_root.nil?\n raise Dor::ParameterError, 'Missing Dor::Config.stacks.local_workspace_root' \n end\n unless %w{all shelve preserve publish}.include?(subset.to_s)\n raise Dor::ParameterError, \"Invalid subset value: #{subset}\"\n end\n\n basename = version.nil? ? \"#{DIFF_FILENAME}.#{subset}.xml\" : \"#{DIFF_FILENAME}.#{subset}.#{version}.xml\"\n druid = DruidTools::Druid.new(self.pid, Dor::Config.stacks.local_workspace_root)\n diff_cache = File.join(druid.temp_dir, basename)\n # check for cached copy before contacting SDR\n if File.exists? diff_cache\n File.read(diff_cache)\n else\n # fetch content metadata inventory difference from SDR\n if Dor::Config.sdr.rest_client.nil?\n raise Dor::ParameterError, 'Missing Dor::Config.sdr.rest_client'\n end\n sdr_client = Dor::Config.sdr.rest_client\n current_content = self.datastreams['contentMetadata'].content\n if current_content.nil?\n raise Dor::Exception, \"Missing contentMetadata datastream\"\n end\n query_string = { :subset => subset.to_s }\n query_string[:version] = version.to_s unless version.nil?\n query_string = URI.encode_www_form(query_string)\n sdr_query = \"objects/#{self.pid}/#{DIFF_QUERY}?#{query_string}\"\n response = sdr_client[sdr_query].post(current_content, :content_type => 'application/xml')\n # cache response\n File.open(diff_cache, 'w') { |f| f << response }\n response\n end\n end",
"def diff(nocolor: false)\n xml = Nokogiri::XML(File.open(@path), &:noblanks)\n ideal = xml.to_xml(indent: 2)\n now = File.read(@path)\n differ(ideal, now, nocolor: nocolor)\n end",
"def diff( path, options={} )\n raise Svn::Error, \"cannot diff directory #{path}@#{to_s}\" if dir? path\n\n other = options[:with] if options[:with].is_a? Root\n other = repo.revision(options[:with]) if options[:with].is_a? Numeric\n other ||= repo.revision(to_i - 1)\n\n return other.diff( path, :with => self ) if other < self\n\n content = \"\"\n begin\n content = file_content_stream( path ).to_counted_string\n rescue Svn::Error => err\n raise if options[:raise_errors]\n end\n\n other_content = \"\"\n begin\n other_content= other.file_content_stream( path ).to_counted_string\n rescue Svn::Error => err\n raise if options[:raise_errors]\n end\n\n Diff.string_diff( content, other_content ).unified(\n :original_header => \"#{path}@#{to_s}\",\n :modified_header => \"#{path}@#{other}\"\n )\n end",
"def diffyable\n # add appropriate diff column data for diff.right and diff.left and update other attrs to the Diffy way®\n\n w1id = self.work1\n w2id = self.work2\n w1work = Work.find(w1id)\n w2work = Work.find(w2id)\n w1md = w1work.file_content_md\n w2md = w2work.file_content_md\n w1txt = w1work.file_content_text\n w2txt = w2work.file_content_text\n\n html = Diffy::Diff.new(w1md, w2md).to_s(:html)\n md = Diffy::Diff.new(w1md, w2md).to_s\n text = Diffy::Diff.new(w1txt, w2txt).to_s\n \n lucy = Diffy::SplitDiff.new(w1md, w2md, :format => :html).left\n recha = Diffy::SplitDiff.new(w1md, w2md, :format => :html).right\n\n html.force_encoding(\"UTF-8\").scrub!\n md.force_encoding(\"UTF-8\").scrub!\n text.force_encoding(\"UTF-8\").scrub!\n\n lucy.force_encoding(\"UTF-8\").scrub!\n recha.force_encoding(\"UTF-8\").scrub!\n\n self.update_attributes(left: lucy, right: recha, diff_md: md, diff_html: html, diff_text: text)\n self.save\n end",
"def diff(from, to=nil)\n scm :diff, repository, authentication, \"-r#{from}:#{to || head}\"\n end",
"def diff___( from_file, to_file )\r\n raise StandardError, \"Under investigation\" \r\n got = @ndev.rpc.file_compare( :from_file => from_file, :to_file => to_file )\r\n end",
"def diff(from, to)\n @repository.diff(from, to, path)\n end",
"def diff(text)\n @diff ||= begin\n files = affected(text).uniq\n @raw.split(\"Index: \")\n .select { |i| files.any? { |f| i.start_with? f } }\n .map { |i| i.split \"\\n\" }\n .flatten\n end\n end",
"def diffem\n\t\tputs \"\\nFile 1 [#{file1.size} bytes]\"\n\t\tputs \"File 2 [#{file2.size} bytes]\\n\\n\"\n\n\t\tcount = 0\n\n\t\t@file1.each_byte do |byte|\n\t\t\tif byte == @file2[count]\n\t\t\t\tprint sprintf(ColorConstants::BLUE + \"%02x \", byte)\n\t\t\telse\n\t\t\t\tprint sprintf(ColorConstants::RED + \"%02x \", byte)\n\t\t\tend\n\n\t\t\tcount = count+1\n\n\t\t\tif count % 32 == 0\n\t\t\t\tprint \"\\n\"\n\t\t\tend\n\t\tend\n\n\t\tputs ColorConstants::NO_COLOR + \"\\n---\"\n\t\tcount = 0\n\n\t\t@file2.each_byte do |byte|\n\t\t\tif byte == @file1[count]\n\t\t\t\tprint sprintf(ColorConstants::BLUE + \"%02x \", byte)\n\t\t\telse\n\t\t\t\tprint sprintf(ColorConstants::RED + \"%02x \", byte)\n\t\t\tend\n\n\t\t\tcount = count+1\n\n\t\t\tif count % 32 == 0\n\t\t\t\tprint \"\\n\"\n\t\t\tend\n\t\tend\n\tend",
"def diff(from, to)\n @repo.diff(from, to).path(path)\n end",
"def diff(other_message)\n out = self.class.new\n\n self.class.valid_attrs.each do |attr|\n ours = read(attr)\n theirs = other_message.read(attr)\n\n if ours != theirs\n out.write(attr, ours)\n end\n end\n\n out\n end",
"def diff(from, to=nil)\n scm :diff, repository, authentication, \"-r#{from}:#{to || head}\"\n end",
"def local_diff\n `cd #{@local_path} && git diff HEAD`\n end",
"def file_diff(fn1, fn2)\n result = ''\n File.open(fn1) do |f1|\n File.open(fn2) do |f2|\n while f1.eof? == false && f2.eof? == false\n line1 = f1.gets.chomp\n line2 = f2.gets.chomp\n result << \"<#{line1}\\n>#{line2}\\n\" if line1 != line2\n end\n if f1.eof? == false\n while f1.eof? == false\n line1 = f1.gets\n result << \"<#{line1}\\n\"\n end\n end\n if f2.eof? == false\n while f2.eof? == false\n line2 = f2.gets\n result << \">#{line2}\\n\"\n end\n end\n end\n end\n result\nend",
"def getDiff ( x , y )\n\tdiff = x - y\n\treturn diff\nend",
"def diff(file1, data)\n return true unless File.exists?(file1)\n f1 = File.open(file1)\n d1 = f1.read\n f1.close\n return ! (d1 == data)\n end",
"def diff_arrays(generated, expected)\n gen_result = []\n exp_result = []\n Diff::LCS.sdiff(generated, expected) do |chunk|\n case chunk.action\n when '-'\n gen_result << %(<strong>#{CGI.escape_html chunk.old_element}</strong>)\n when '+'\n exp_result << %(<strong>#{CGI.escape_html chunk.new_element}</strong>)\n when '='\n gen_result << (CGI.escape_html chunk.old_element)\n exp_result << (CGI.escape_html chunk.new_element)\n when '!'\n gen_result << %(<strong>#{CGI.escape_html chunk.old_element}</strong>)\n exp_result << %(<strong>#{CGI.escape_html chunk.new_element}</strong>)\n end\n end\n [gen_result, exp_result]\n end",
"def generate_file_diff(left, right, overrides = {})\n defaults = {title_left: 'Expected', title_right: 'Actual', stylesheet: link('styles/compare_it.css')}\n overrides = defaults.merge(overrides)\n # Temporary file for the HTML report - it is deleted after we're done.\n temp_diff_file = Tempfile.new('diff')\n temp_diff_file.close\n # The Windows file paths.\n left_file = Converter.to_windows_path(left)\n right_file = Converter.to_windows_path(right)\n diff_file = Converter.to_windows_path(temp_diff_file.path)\n # Arguments\n # /min - Minimised mode.\n # /G: - Generate report, N - Line numbers, S - Statistics, X - External CSS, 0 - Context lines.\n executable = @config_manager['tool.compare_it.executable']\n args = [left_file, \"/=#{overrides[:title_left]}\", right_file, \"/=#{overrides[:title_right]}\", '/min', '/G:NSX0', diff_file]\n FileUtils.cd(Dir.tmpdir) { system(executable, *args) }\n # The diff content.\n diff_html = File.readlines(temp_diff_file.path)\n diff_html[0] = '<!DOCTYPE html>' + \"\\n\"\n diff_html[6] = '<link href=\"' + overrides[:stylesheet] + '\" rel=\"stylesheet\" type=\"text/css\" />' + \"\\n\"\n # Delete the temporary file.\n temp_diff_file.unlink\n # Return the diff content.\n diff_html.join\n end",
"def review_diff(other)\n diff = {}\n if self.publication_type != other.publication_type\n diff[:publication_type] = {from: I18n.t('publication_types.'+other.publication_type.code+'.label'), to: I18n.t('publication_types.'+self.publication_type.code+'.label')}\n end\n\n unless (self.category_svep_ids & other.category_svep_ids == self.category_svep_ids) && (other.category_svep_ids & self.category_svep_ids == other.category_svep_ids)\n diff[:category_hsv_local] = {from: other.categories, to: self.categories}\n end\n\n if self.ref_value != other.ref_value\n diff[:ref_value] = {from: I18n.t('ref_values.'+other.ref_value.to_s), to: I18n.t('ref_values.'+self.ref_value.to_s)}\n end\n\n return diff\n end",
"def test_ut_diff_result_02\n original_file = OriginalFile.new(\n :source_name => \"simple 1\",\n :path => \"http\",\n :normal_result_id => 349898,\n :hirisk_result_id => 4564,\n :critical_result_id => 45 )\n assert_equal(\"simple 1\",original_file.source_name)\n assert_equal(349898,original_file.normal_result_id)\n assert_equal(4564,original_file.hirisk_result_id)\n assert_equal(45,original_file.critical_result_id)\n assert_equal(\"http\",original_file.path)\n end",
"def test_ut_diff_result_02\n original_source_code = OriginalSourceCode.new(\n :original_file_id => 10,\n :line_number => 349898,\n :error_line => 4564,\n :line_content => \"123456\"\n )\n assert_equal(10,original_source_code.original_file_id)\n assert_equal(349898,original_source_code.line_number)\n assert_equal(4564,original_source_code.error_line)\n assert_equal(\"123456\",original_source_code.line_content)\n end",
"def html\n diff[:html]\n end",
"def file_diff(fn1,fn2)\n result = ''\n File.open(fn1) do |f1|\n File.open(fn2) do |f2|\n while f1.eof? == false and f2.eof? == false\n line1 = f1.gets.chomp\n line2 = f2.gets.chomp\n result << \"<#{line1}\\n>#{line2}\\n\" if line1 != line2\n end\n if f1.eof? == false\n while f1.eof? == false\n line1 = f1.gets\n result << \"<#{line1}\\n\"\n end\n end\n if f2.eof? == false\n while f2.eof? == false\n line2 = f2.gets\n result \">#{line2}\\n\"\n end\n end\n end\n end\n result\nend",
"def diff(matches)\n if matches.empty?\n v1.map { |x| Display.deleted(x) } + v2.map { |x| Display.added(x) }\n elsif matches.first[0] == 0 && matches.first[1] == 0\n remaining_matches = matches.drop(1).map { |t| [t[0]-1, t[1]-1] }\n [v1[0]] + Versions.new(v1.drop(1), v2.drop(1)).diff(remaining_matches)\n elsif matches.first[0] == 0\n remaining_matches = matches.map { |t| [t[0], t[1]-1] }\n [Display.added(v2[0])] + Versions.new(v1, v2.drop(1)).diff(remaining_matches)\n else matches.first[1] == 0\n remaining_matches = matches.map { |t| [t[0]-1, t[1]] }\n [Display.deleted(v1[0])] + Versions.new(v1.drop(1), v2).diff(remaining_matches)\n end\n end",
"def diff_files(file_id1, file_id2)\n\t\t\tfile1 = get_file(file_id1)\n\t\t\tfile2 = get_file(file_id2)\n\t\t\tfile1 = file1.lines\n\t\t\tfile2 = file2.lines\n\n\t\t\treturn ((file1 - file2) + (file2-file1))\n\t\tend",
"def changes(start_ref, end_ref)\n check_refs(start_ref, end_ref)\n s = Mixlib::ShellOut.new(\n \"#{@bin} diff -r #{start_ref}:#{end_ref} --summarize #{@repo_path}\")\n s.run_command.error!\n @logger.info(\"Diff between #{start_ref} and #{end_ref}\")\n s.stdout.lines.map do |line|\n m = line.match(/^(\\w)\\w?\\s+(\\S+)$/)\n fail \"Could not parse line: #{line}\" unless m\n\n {\n :status => m[1] == 'D' ? :deleted : :modified,\n :path => m[2].sub(\"#{@repo_path}/\", '')\n }\n end\n end",
"def diff(objectish = 'HEAD', obj2 = nil)\n Git::Diff.new(self, objectish, obj2)\n end",
"def diff_file(from_file, to_file, context=3)\n seq1 = File.open(from_file).readlines\n from_mtime = File.stat(from_file).mtime\n seq2 = File.open(to_file).readlines\n to_mtime = File.stat(to_file).mtime\n sdiff = Diff::LCS.sdiff(seq1, seq2)\n diff_lines(seq1, seq2, from_file, to_file, from_mtime, \n to_mtime, context)\n end",
"def run_diff(a, b)\n\t\t\ta = \"\" if a == nil\n\t\t\tb = \"\" if b == nil\n\t\t\n\t\t\t@a = a\n\t\t\t@b = b\n\t\t\n\t\t\t# run the initial word-based diff\n\t\t\t@worddiff = WordDiff.new(a, b)\n\t\t\n\t\t\tawords = @worddiff.a_words\n\t\t\tbwords = @worddiff.b_words\n\t\t\twdiff = @worddiff.differences\n\t\t\n\t\t\t#\n\t\t\t# now run through all the words in the longest\n\t\t\t# of the sentences, and for words that differ\n\t\t\t# run a character based diff and calculate the differing\n\t\t\t# characters actual position within the sentences\n\t\t\t#\n\t\t\tmax = awords.length\n\t\t\tmax = bwords.length if bwords.length > awords.length\n\t\t\n\t\t\tstr = \"\"\n\t\t\n\t\t\tfor i in 0..max-1\n\t\t\n\t\t\t\tif wdiff.include?(i)\n\t\t\t\t\tdiff_by_char(awords[i], bwords[i]).each do |chardiff|\n\t\t\t\t\t\t@differences.push(chardiff + str.length)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\n\t\t\t\tstr << \" #{bwords[i]}\"\n\t\t\tend\n\n\t\t\t# return void\t\t\n\t\t\treturn\n\t\tend",
"def createDiffResult(working_dir, channel_cfg, vimapp, isReleaseOperator,backupRoot)\n\n remotedir = readChannelDir(channel_cfg, vimapp) + \"/\"+ File.basename(working_dir)\n puts remotedir.green\n if File.directory?(remotedir) == false\n FileUtils.mkdir_p remotedir\n end\n\n reportFile1 = \"#{remotedir}/report\"\n reportFile2 = \"#{remotedir}/rdetail\"\n lines = File.open(reportFile1, \"r:UTF-8\").each_line.to_a\n\n hashes = Array.new\n lines.each do |line|\n if line.start_with? \"hash=\"\n hashes.push line.gsub(\"hash=\",\"\").strip.chomp\n end\n end\n\n g = gitOpen(working_dir)\n \n logs = getGitLog(g)\n local_branches = getGitBranches(g)[:local]\n diff = compareHashes g, logs, hashes\n \n def getDiffDetails(diffinfo)\n puts \"diffdetails\"\n data = Array.new \n\n diffinfo[:files].each do |file|\n print \"[\"\n print file[0].cyan\n print \"] \"\n print \"[+] #{file[1][:insertions]}\".green\n print \" \"\n print \"[-] #{file[1][:deletions]}\".red\n puts\n # file, insertions, deletions\n data.push \"file=#{file[0]},#{file[1][:insertions]},#{file[1][:deletions]}\"\n end\n\n return data \n end\n\n diff_details = getDiffDetails diff[1]\n \n puts \"\\n\\n|||||||||||||||||||||||||WRITE|||||||||||||||||||||||||||||||||\\n\\n\"\n\n puts \"hash=\"+diff[2]\n puts \"hash=\"+diff[3]\n diff_details.each do |d| \n puts d\n end\n\n diffReportDir = \"#{working_dir}/.diffreport\"\n FileUtils.mkdir_p diffReportDir \n\n #write diff detail to file \n r_detail = \"#{diffReportDir}/detail\"\n\n puts \">> 222\"\n f = File.open(r_detail, \"w:UTF-8\")\n diff[0].each do |l|\n f.puts l\n end\n f.close\n\n f = File.open(r_detail+\".color\", \"w:UTF-8\")\n diff[0].each do |l|\n if isPlus(l)\n f.puts l.green\n elsif isMinus(l)\n f.puts l.red\n else\n f.puts l\n end\n end\n f.close\n\n puts \">> 111\"\n #write diff to file\n diffReport = \"#{diffReportDir}/report\"\n f = File.open(diffReport, \"w:UTF-8\")\n f.puts \"hash=\"+diff[2]\n f.puts \"hash=\"+diff[3]\n diff_details.each do |d| \n f.puts d\n end\n f.close\n puts \"\\n\\nWRITTEN\\n\\n\".green\n\n if isReleaseOperator == false\n FileUtils.cp \"#{diffReport}\", \"#{reportFile1}\"\n FileUtils.cp \"#{r_detail}\", \"#{reportFile2}\"\n else\n metaOK = FileUtils.identical?(diffReport, reportFile1)\n detailOK = FileUtils.identical?(r_detail, reportFile2)\n \n puts \n print \"[ OVERVIEWS ] \" #metaOK.to_s.red\n puts metaOK ? \"IDENTICAL\".green : \"DIFFERENT\".red\n print \"[CODE DETAILS] \"\n puts detailOK ? \"IDENTICAL\".green : \"DIFFERENT\".red\n puts\n def compare(file1, file2)\n puts \">> compare\"\n lines1 = File.open(file1, \"r:UTF-8\").each_line.to_a\n lines2 = File.open(file2, \"r:UTF-8\").each_line.to_a\n def showInclusion(lines1, lines2, i)\n lines1.each do |line|\n if lines2.include?(line) == false\n if i == true\n puts \"[YOURS] \"+ line.chomp.cyan\n else\n puts \"[REMOTE] \"+ line.chomp.yellow\n end\n end\n end\n end\n showInclusion(lines1, lines2, true)\n showInclusion(lines2, lines1, false)\n end\n compare diffReport, reportFile1\n compare r_detail, reportFile2\n end\n\n files = Array.new\n diff_details.each do |d| \n if d.start_with? \"file=\"\n files.push d.gsub(\"file=\",\"\").strip.chomp\n end\n end\n if hashes.size > 0\n #compareBackupsWithOldVersion(g, working_dir, backupRoot, files, hash) \n #compareBackupsWithOldVersion(g, working_dir,backupRoot,files, hash[1]) \n end\n end",
"def diff_string(string1, string2); end",
"def diff_gitignore\n system(\"diff .gitignore ~/code/tmpl/gitignore-gem\")\n end",
"def diff_gitignore\n system(\"diff .gitignore ~/code/tmpl/gitignore-gem\")\n end",
"def historic_diff\n # get the two versions to diff\n @new_measure = Measure.by_user(current_user).where({:_id => params[:new_id]}).first\n unless @new_measure\n @new_measure = ArchivedMeasure.where({:measure_db_id => params[:new_id]}).first.to_measure\n end\n\n @old_measure = Measure.by_user(current_user).where({:_id => params[:old_id]}).first\n unless @old_measure\n @old_measure = ArchivedMeasure.where({:measure_db_id => params[:old_id]}).first.to_measure\n end\n\n results = {}\n results['diff'] = []\n results['pre_upload'] = { \n 'cms_id' => @old_measure.cms_id,\n 'updateTime' => (@old_measure.updated_at.tv_sec * 1000),\n 'hqmf_id' => @old_measure.hqmf_id,\n 'hqmf_version_number' => @old_measure.hqmf_version_number }\n results['post_upload'] = { \n 'cms_id' => @new_measure.cms_id,\n 'updateTime' => (@new_measure.updated_at.tv_sec * 1000),\n 'hqmf_id' => @new_measure.hqmf_id,\n 'hqmf_version_number' => @new_measure.hqmf_version_number }\n\n measure_logic_names = HQMF::Measure::LogicExtractor::POPULATION_MAP.clone\n measure_logic_names['VARIABLES'] = 'Variables'\n\n # Walk through the population sets and populations for the measure and create a\n # diffy for each populationm.\n @new_measure.populations.each_with_index do |new_population_set, population_set_index|\n old_population_set = @old_measure.populations[population_set_index]\n population_diff = []\n\n # For each population within the population set, get the population logic and\n # perform the diffy\n measure_logic_names.each_pair do |population_code, population_title|\n # if the code is for VARIABLE, leave it. If it's IPP, etc., then access the actual code name from the\n # population set (e.g. IPP_1).\n code = (population_code == 'VARIABLES') ? 'VARIABLES' : new_population_set[population_code]\n new_logic = @new_measure.measure_logic.find { |logic| logic['code'] == code }\n old_logic = @old_measure.measure_logic.find { |logic| logic['code'] == code }\n\n # skip if both are non existent\n next if !new_logic && !old_logic\n \n # Remove the first line of the measure logic, which is the the name of the population.\n old_logic_text = old_logic ? old_logic['lines'][1..-1].join() : \"\"\n new_logic_text = new_logic ? new_logic['lines'][1..-1].join() : \"\"\n\n logic_diff = Diffy::SplitDiff.new(old_logic_text, new_logic_text,\n format: :html, include_plus_and_minus_in_html: true, allow_empty_diff: false)\n\n population_diff << {code: population_code, title: population_title, pre_upload: logic_diff.left, post_upload: logic_diff.right}\n end\n\n results['diff'] << population_diff\n end\n\n render :json => results\n end",
"def ldiff(license)\n xml = Nokogiri::XML(File.open(@path), &:noblanks)\n comment = xml.xpath('/comment()')[0]\n now = comment.nil? ? '' : comment.text.to_s.strip\n ideal = license.strip\n differ(ideal, now)\n end",
"def make_package_diff(before, after)\n installed = package_diff after, before\n removed = package_diff before, after\n { 'installed' => installed, 'removed' => removed }\n end",
"def diff_ratio( other )\n return 0.0 if self == other\n return 1.0 if empty? || other.empty?\n\n s_words = self.words( true )\n o_words = other.words( true )\n\n common = (s_words & o_words).size.to_f\n union = (s_words | o_words).size.to_f\n\n (union - common) / union\n end",
"def return_resource_diffs(r1, r2)\n only_in_old = []\n (r2 - r1).each do |r|\n only_in_old << r.to_s\n end\n only_in_new = []\n (r1 - r2).each do |r|\n only_in_new << r.to_s\n end\n differences = {\n titles_only_in_old: only_in_old,\n titles_only_in_new: only_in_new\n }\n differences\n end",
"def run_diff(a, b)\n\t\t\ta = \"\" if a == nil\n\t\t\tb = \"\" if b == nil\n\t\n\t\t\t@a_words = a.split(\" \")\n\t\t\t@b_words = b.split(\" \")\n\t\n\t\t\tmax = @a_words.length\n\t\t\tmax = @b_words.length if @b_words.length > @a_words.length\n\t\n\t\t\tfor i in 0..max-1\n\t\t\t\t@differences.push(i) if @a_words[i] != @b_words[i]\n\t\t\tend\n\t\t\t\n\t\t\t# return void\n\t\t\treturn\n\t\tend",
"def package_diff(a, b, ignore_versions = false)\n result = a.dup\n b.each_pair do |k, v|\n if a.key? k\n if a[k] == v or ignore_versions\n result.delete k\n end\n end\n end\n result\n end",
"def diff_lines(seq1, seq2, from_file, to_file, \n from_mtime, to_mtime, context=3)\n sdiff = Diff::LCS.sdiff(seq1, seq2)\n # PP.pp sdiff\n # puts '-' * 40\n started = false\n result = []\n i = 0\n n = -(context+1)\n while true do\n i = find_next(sdiff, i)\n break if i >= sdiff.size\n if n < i-context\n if started\n result << '***************'\n else\n result << \"*** #{from_file}\\t#{from_mtime}\"\n result << \"--- #{to_file}\\t#{to_mtime}\"\n started = true\n end\n result << '*** %d,%d ****' % find_pos(sdiff, i)\n context.downto(1) do |j|\n result << ' ' + sdiff[i-j].new_element.chomp\n end\n end\n i += 1\n while i < sdiff.size && (action = sdiff[i-1].action) != '='\n element = \n if action == '+' \n sdiff[i-1].new_element\n else\n sdiff[i-1].old_element\n end\n result << action + element.chomp\n i += 1\n end\n -1.upto(context-2) do |j|\n n = i+j\n break if sdiff[n].action != '='\n result << ' ' + sdiff[n].new_element.chomp\n end\n end\n return result\n end",
"def differ\n RSpec::Expectations.differ\n end",
"def diff(scm, options={}, &block)\n scm.diff(self, options, &block)\n end",
"def patches\n \"https://gist.github.com/fredrikw/5858168/raw/e4b5899e781d5707f5c386e436b5fc7810f2010d/ob-2-3-2-patch.diff\"\n end",
"def diff(other,options={},&block)\n return enum_for(__method__,other,options) unless block\n\n if (options[:added] || options[:removed])\n tdiff_unordered(other) do |change,node|\n if (change == '+' && options[:added]) then yield change, node\n elsif (change == '-' && options[:removed]) then yield change, node\n end\n end\n else\n tdiff(other,&block)\n end\n end",
"def cmd_diff\n print_tree(DiffEditor, nil, true)\n end",
"def sdiff(other, callbacks = nil, &block)\n Diff::LCS.sdiff(self, other, callbacks, &block)\n end",
"def to_html \n PrettyDiff::HtmlGenerator.generate_diff(chunks)\n end",
"def reuse_validation_diff(other)\n original, reference = prepare_reuse_validation_diff(other)\n\n return if original == reference\n\n diff_values = original.to_a - reference.to_a\n diff_values.to_h\n end",
"def diff url\n gitlab_response = HTTParty.get \"#{url}.diff\", query: {\n private_token: @private_token\n }\n handle_response gitlab_response\n end",
"def run\n # Try to get the diff_filename and open it for the comparison\n # And if this is the first time the import is run, there wont be any diff_filename whatsoever, so we loop from the file directly =)\n get_diff_from_previous_file if @diff_filename.nil?\n \n # If this is run for the first time, we are not gonna have the diff_file, so\n # What we are doing is to read all of the lines, and put them under \"added\" section\n if (File.file? @diff_filename)\n # Parse the diff file\n parse_diff \n else\n # We read it from the file directly\n parse_file\n end\n \n # Return with the hash representation of the difference\n return self.line_diff\n end",
"def snapshot_diff(left:, right:)\n r = aptly_request('GET', \"api/snapshots/#{left}/diff/#{right}\")\n r.body\n end",
"def difference(other)\n self.class.from_a(to_a - other.to_a)\n end",
"def xml_compare a, b\n a = REXML::Document.new(a.to_s)\n b = REXML::Document.new(b.to_s)\n\n normalized = Class.new(REXML::Formatters::Pretty) do\n def write_text(node, output)\n super(node.to_s.strip, output)\n end\n end\n\n normalized.new(indentation=0,ie_hack=false).write(node=a, a_normalized='')\n normalized.new(indentation=0,ie_hack=false).write(node=b, b_normalized='')\n\n a_normalized == b_normalized\n end",
"def diff(other_variable, options={})\n Differences::Entry.compute(self, other_variable, diff_criteria(options), options)\n end",
"def test_diff\n \tassert_equal(UI.parseCommand('diff', DiffCmd1*\" \"),UI.main(DiffCmd1))\n \tassert_equal(UI.parseCommand('diff', DiffCmdInv*\" \"),UI.main(DiffCmdInv))\n end",
"def find_diffs_between_qotd_and_content_at(date_code, posting_date_time, qotd_txt, content_at_txt, collector)\n content_at_txt_without_subtitles = content_at_txt.delete('@')\n perfect_content_match = content_at_txt_without_subtitles.index(qotd_txt)\n matching_content_at_fragment = find_matching_content_at_fragment(\n qotd_txt,\n content_at_txt\n )\n if perfect_content_match\n # content is identical, check for subtitle alignment\n matching_subtitles_txt = remove_trailing_punctuation_from_content_at(\n matching_content_at_fragment.split('@').find_all { |e|\n qotd_txt.index(\n remove_trailing_punctuation_from_content_at(e.strip)\n )\n }.join.strip\n )\n\n if qotd_txt != matching_subtitles_txt\n # qotd is not aligned with subtitles, report as discrepancy\n qotd_diff, content_at_diff, diff_tokens = compute_diffs(\n qotd_txt,\n matching_subtitles_txt\n )\n collector << {\n date_code: date_code,\n posting_date_time: posting_date_time,\n qotd_content: qotd_diff,\n content_at_content: content_at_diff,\n diff_tokens: ['@'],\n }\n end\n else\n # some kind of content or style mismatch\n qotd_diff, content_at_diff, diff_tokens = compute_diffs(\n qotd_txt,\n matching_content_at_fragment.delete('@')\n )\n collector << {\n date_code: date_code,\n posting_date_time: posting_date_time,\n qotd_content: qotd_diff,\n content_at_content: content_at_diff,\n diff_tokens: diff_tokens\n }\n end\n true\n end",
"def test_ut_diff_source_code_02\n assert_equal(1,@diff_source_code_1.diff_result_id)\n assert_equal(1,@diff_source_code_1.original_file_id)\n assert_equal(1,@diff_source_code_1.diff_file_id)\n assert_equal(nil,@diff_source_code_1.added_lines)\n assert_equal(\"7;8;9;25;390;396;397;400;404\",@diff_source_code_1.deleted_lines)\n assert_equal(\"1,1;2,2;3,3;4,4;6,6;10,10;11,11;12,12;13,13;14,14;15,15;\",@diff_source_code_1.common_lines)\n end",
"def diff\n each_difference(local_resources, true, &@@diff)\n end",
"def diff (lib)\n\n new_lib = Missing::Library.new()\n dup_lib = Missing::Library.new()\n\n # loop through Library object passed\n lib.photos.each_with_index do | lib_passed_photo, index |\n UI::Progress.diff_update(index+1, lib.photos.length)\n \n # loop through this Library object photos\n @photos.each_with_index do | lib_self_photo, inner_index |\n # if matching file found (duplicate) \n if lib_passed_photo.md5 == lib_self_photo.md5 \n dup_lib.photos.push lib_passed_photo\n dup_lib.photos[-1].dup = lib_self_photo\n break \n end\n # if last iteration (i.e. no match found / new photo)\n if inner_index+1 == @photos.count\n new_lib.photos.push lib_passed_photo \n end\n end \n end\n\n # return only new/non-duplicate photo lib object\n # dup photo availabe in 'dup_lib' object\n new_lib\n end",
"def patched\n vendored.collect do |dep|\n # TODO: right now just handling git based alternate sources,\n # should be able to handle other types bundler supports\n # (path and alternate rubygems src)\n next unless dep.source.is_a?(Bundler::Source::Git)\n src = dep.source\n\n # retrieve gem\n gem = if src.version\n Polisher::Gem.new(:name => dep.name, :version => src.version)\n else\n Polisher::Gem.retrieve(dep.name)\n end\n\n # retrieve dep\n git = Polisher::Git::Repo.new :url => src.uri\n git.clone unless git.cloned?\n git.checkout src.ref if src.ref\n\n # diff gem against git\n gem.diff(git.path)\n end.compact!\n end"
] | [
"0.6789137",
"0.67606056",
"0.6752636",
"0.66995335",
"0.6696369",
"0.6584416",
"0.65363497",
"0.6480649",
"0.6407898",
"0.6405153",
"0.63680464",
"0.63475615",
"0.6333311",
"0.63078976",
"0.63058686",
"0.6257464",
"0.6254554",
"0.6252139",
"0.6249316",
"0.6248344",
"0.62229943",
"0.6212571",
"0.6195232",
"0.61574644",
"0.6141409",
"0.6124361",
"0.6120694",
"0.6118151",
"0.611499",
"0.60922897",
"0.60636324",
"0.60630226",
"0.60393655",
"0.6035538",
"0.6032362",
"0.6031262",
"0.6029826",
"0.6024209",
"0.60211504",
"0.6009423",
"0.5997166",
"0.5994989",
"0.59465176",
"0.59464693",
"0.5942883",
"0.5939588",
"0.5916468",
"0.5903772",
"0.5898204",
"0.5897168",
"0.588665",
"0.5834293",
"0.5823917",
"0.57995594",
"0.579353",
"0.5791042",
"0.5786826",
"0.57653946",
"0.57621586",
"0.57553697",
"0.5735979",
"0.5726787",
"0.5721365",
"0.57078004",
"0.56854594",
"0.5683487",
"0.56533563",
"0.56480306",
"0.5647913",
"0.56441617",
"0.5629067",
"0.5629067",
"0.56210625",
"0.56173277",
"0.56163776",
"0.5613451",
"0.56122375",
"0.56115943",
"0.5597619",
"0.55884963",
"0.5586582",
"0.5555182",
"0.55517083",
"0.55434436",
"0.5541665",
"0.55120206",
"0.5511287",
"0.5508883",
"0.5504962",
"0.5496646",
"0.5494144",
"0.5486343",
"0.5478066",
"0.5477207",
"0.5474696",
"0.5468891",
"0.5462373",
"0.5461617",
"0.5460838",
"0.54601985"
] | 0.7319598 | 0 |
The normal method retrieves a Vector3d that is perpendicular to the plane of the arc. | def normal
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal(p)\n return (p - @centre).unit\n end",
"def estimate_normal(\n p # vec3\n)\n Vec3.new(\n scene_sdf(Vec3.new(p.x + $EPSILON, p.y, p.z)) - scene_sdf(Vec3.new(p.x - $EPSILON, p.y, p.z)),\n scene_sdf(Vec3.new(p.x, p.y + $EPSILON, p.z)) - scene_sdf(Vec3.new(p.x, p.y - $EPSILON, p.z)),\n scene_sdf(Vec3.new(p.x, p.y, p.z + $EPSILON)) - scene_sdf(Vec3.new(p.x, p.y, p.z - $EPSILON))\n ).normalize\nend",
"def normalize\n f = 1.0 / length\n Normal3.new(@x * f, @y * f, @z * f)\n end",
"def normaldist(z)\r\n p_nor(z)\r\n end",
"def normal_vector a_point\n i_point = Point.new()\n i_point.add_object(self)\n plane = Plane.new.add_object(a_point).add_object([self, :normal])\n i_point.add_object(plane)\n Vector.new i_point, a_point\n end",
"def compute_normal_vector(line)\n h = line[:y2] - line[:y]\n w = line[:x2] - line[:x]\n normalize vec2(-h, w)\n end",
"def normal___x(z); 1.0 - normaldist(z); end",
"def perpendicular\n Vector2d.new(-@y, @x)\n end",
"def normal\n u = (a.subtract b).normalize\n v = (c.subtract b).normalize\n u.cross v\n end",
"def normal_vector\n return @nv unless @nv.nil? \n\n nv = self.area_vector\n length = nv.abs\n\n nvv=nv.map { |e| e/length }\n def nvv.to_s\n \"NV:=(#{self[0]}, #{self[1]}, #{self[2]})\"\n end\n @nv = nvv\n end",
"def perpendicular\n Vector2d.new(-y, x)\n end",
"def compute_proper_normal(line)\n normals = compute_normals(line)\n ball_center_x = state.ball_old_x + (state.ball[:w] / 2)\n ball_center_y = state.ball_old_y + (state.ball[:h] / 2)\n v1 = vec2(line[:x2] - line[:x], line[:y2] - line[:y])\n v2 = vec2(line[:x2] - ball_center_x, line[:y2] - ball_center_y)\n cp = v1[:x] * v2[:y] - v1[:y] * v2[:x]\n cp < 0 ? normals[0] : normals[1]\n end",
"def normalize\n mag = self.magnitude\n Vector.new @x/mag, @y/mag, @z/mag\n end",
"def unit_perpendicular_vector(options={})\n return [self[1], -self[0]].unit_vector if options[:counter_clockwise]\n [-self[1], self[0]].unit_vector\n end",
"def normalx__x(z); 2.0 - normaldist(z) * 2.0; end",
"def norm\r\n (@real * @real) + @axis.modulus\r\n end",
"def to_n\n Normal3.new(@x, @y, @z)\n end",
"def norm\n Math.sqrt((@a**2) + (@b**2) + (@c**2) + (@d**2))\n end",
"def dist point\n point = point.pos(false) if point.is_a? Atom\n (point.to_v- @p).to_a * @normal / @normal.magnitude\n end",
"def normal__X_(z); normaldist(z) - 0.5; end",
"def normal_towards(a, b, c)\n ac = a.dot(c)\n bc = b.dot(c)\n\n x = b.x * ac - a.x * bc\n y = b.y * ac - a.y * bc\n\n V.new(x, y)\n end",
"def getNormalPoint(p, a, b) \n # Vector from a to p\n ap = PVector.sub(p,a)\n # Vector from a to b\n ab = PVector.sub(b,a)\n ab.normalize # Normalize the line\n # Project vector \"diff\" onto line by using the dot product\n ab.mult(ap.dot(ab))\n normalPoint = PVector.add(a,ab)\n return normalPoint\n end",
"def norm\n m = mag\n @x /= m\n @y /= m\n self\n end",
"def direction\n self.vector.normalize\n end",
"def cross_normal(other)\n cross(other).normalize\n end",
"def div(rhs)\n f = 1.0 / rhs\n Normal3.new(@x * f, @y * f, @z * f)\n end",
"def pnormaldist(y)\r\n pnorm(y)\r\n end",
"def /(other)\n Vector3D.new(x / other, y / other, z / other)\n end",
"def norm\n Math::sqrt(data.values.inject(0) { |m,v| m+v**2})\n end",
"def normalize\n f = 1.0 / length\n Vector2.new(@x * f, @y * f)\n end",
"def unit_vector\n len = self.r\n raise Vector::ZeroOperationError if (len == 0.0)\n self * (1.0/len)\n # Mageo::Vector3D.new(@x*(1.0/len), @y*(1.0/len), @z*(1.0/len))\n end",
"def Vector3dUnitPerpendicularXY(arg0)\n ret = _invoke(1610744176, [arg0], [VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def normal\n attributes.normal\n end",
"def pnormal___x(y); pnormalxXX_(1.0 - y); end",
"def create_perpendicular\n p1dot_ = self * P1\n p2dot_ = self * P2\n p1dot_ = -p1dot_ if p1dot_ < 0\n p2dot_ = -p2dot_ if p2dot_ < 0\n p1dot_ < p2dot_ ? (self % P1) : (self % P2)\n end",
"def rayToCenter\r\n return (@camera.position + @camera.get_forward*far_plane).to_bullet\r\n end",
"def normalize\n self / self.norm\n end",
"def unit_vector\n\t\tlen = self.r\n\t\traise Vector::ZeroOperation if (len == 0)\n\t\tself * (1/len)\n\t\t# Vector3D.new(@x*(1.0/len), @y*(1.0/len), @z*(1.0/len))\n\tend",
"def sub(rhs)\n Normal3.new(@x - rhs.x, @y - rhs.y, @z - rhs.z)\n end",
"def test_normal_stays_with_length_1_regardless_of_radius\n erase_all()\n v = nil\n assert_nothing_raised do\n centerpoint = Geom::Point3d.new\n # Create a circle perpendicular to the normal or Z axis\n vector = Geom::Vector3d.new 0,0,1\n vector2 = vector.normalize!\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_circle centerpoint, vector2, 100\n edge = edgearray[0]\n arccurve = edge.curve\n v = arccurve.normal\n end\n expected_normal = Geom::Vector3d.new 0,0,1\n assert_equal(expected_normal, v,\n 'Normal length != 1.0' )\n end",
"def pnormalxXX_(z); pnormaldist(z); end",
"def test_normal_api_example\n erase_all()\n v = nil\n assert_nothing_raised do\n centerpoint = Geom::Point3d.new\n # Create a circle perpendicular to the normal or Z axis\n vector = Geom::Vector3d.new 0,0,1\n vector2 = vector.normalize!\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_circle centerpoint, vector2, 10\n edge = edgearray[0]\n arccurve = edge.curve\n v = arccurve.normal\n end\n expected_normal = Geom::Vector3d.new 0,0,1\n assert_equal(expected_normal, v,\n 'Failed in test_normal' )\n end",
"def normalxXX_(z); normaldist(z); end",
"def surfaceNormal _args\n \"surfaceNormal _args;\" \n end",
"def distance_to_plane(plane)\n plane.substitute(self).abs / (plane.find_normal_vector.length)\n end",
"def normalize!\n mag = magnitude\n return self if mag == 0\n self.x, self.y, self.z = self.x / mag, self.y / mag, self.z / mag\n self\n end",
"def calculate_norm_and_orientation\n x, y = @components.values\n @norm = Math.sqrt( x**2 + y**2 )\n @orientation = calculate_orientation\n end",
"def normal(a, b)\n [a[1]*b[2]-a[2]*b[1],\n a[2]*b[0]-a[0]*b[2],\n a[0]*b[1]-a[1]*b[0]]\nend",
"def perpendicular_line(point)\n point = Point.new(point[0], point[1]) if point.is_a?(Array)\n raise TypeError, 'Must pass only Point.' unless point.is_a?(Point)\n\n # any two lines in R^2 intersect, so blindly making\n # a line through p in an orthogonal direction will work\n Line.new(point, point + self.direction.orthogonal_direction.to_point)\n end",
"def mul(rhs)\n Normal3.new(@x * rhs, @y * rhs, @z * rhs)\n end",
"def pnormalx__x(y); pnormalxXX_(1.0 - y/2.0); end",
"def norm positions\n\t\tproduct = scalar_product( positions, positions )\n\t\treturn product > 0.0 ? Math.sqrt( product ) : 0.0\n\tend",
"def Vector3dNormalize(arg0)\n ret = _invoke(1610744180, [arg0], [VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def normal(mean: 1, standard_deviation: 1)\n theta = 2 * Math::PI * rand\n rho = Math.sqrt(-2 * Math.log(1 - rand))\n scale = standard_deviation * rho\n mean + scale * Math.cos(theta)\n end",
"def normalDistributionPValue(confidence)\n return Distribution::Normal.p_value(confidence)\n end",
"def centripetal_force_v1(mass, linear_velocity, radius)\n if radius.zero?\n raise ZeroDivisionError.new('divided by 0')\n else\n return (mass * (linear_velocity ** 2.0)) / radius\n end\n end",
"def perpendicular?(vector2)\n end",
"def abs\r\n Math.sqrt(norm)\r\n end",
"def center()\n Vector.new(x + w / 2, y + h / 2, z)\n end",
"def Point3dFromAngleDistance(arg0, arg1, arg2)\n ret = _invoke(1610744061, [arg0, arg1, arg2], [VT_R8, VT_R8, VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def udot( vector )\n unit.dot( vector.unit )\n end",
"def transform_as_normal(normal, transformation)\n normal.transform(transpose(transformation).inverse).normalize\n end",
"def norm(p = 2)\n Norm.sqnorm(self, p) ** (Float(1)/p)\n end",
"def magnitude\n Math.sqrt(@x ** 2 + @y ** 2 + @z ** 2)\n end",
"def unit_vector(p1, p2)\n x = p2[0] - p1[0]\n y = p2[1] - p1[1]\n normalize_vector([x,y])\n end",
"def surfacedirection(face)\n vect = face.normal\n hvector = Geom::Vector3d.new(0, 0, 1)\n ang = hvector.angle_between vect\n return ang\nend",
"def Vector3dFromXYAngleAndMagnitude(arg0, arg1)\n ret = _invoke(1610744189, [arg0, arg1], [VT_R8, VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def plane\n return nil if @vertices.length < 3\n Plane.three_points(*@vertices[0..2])\n end",
"def to_v\n Vector3.new(@x, @y, @z)\n end",
"def reflection\n i = self.copy\n n = self.normalized\n r = ( 2 * ((i*(-1.0)).dot(n)) * (n) ) + ( n )\n r = Vector.new(r.a)\n end",
"def pnormal__X_(y); pnormalxXX_(y + 0.5); end",
"def normalize\n divide(magnitude)\n end",
"def Vector3dAreVectorsPerpendicular(arg0, arg1)\n ret = _invoke(1610744182, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def perpendicular?( vector2 )\n if( dotProduct( vector2 ) == 0 )\n return true\n else\n return false\n end\n end",
"def distance(*vertex) v = vertex.extract_vector3i!; Math.sqrt(((v[0]-x) ** 2) + ((v[1]-y) ** 2 ) + ((v[2]-z) ** 2)) end",
"def center\n a, b, c, d = @points\n\n Geom::Point3d.new(\n (a.x + b.x + c.x + d.x) / 4,\n (a.y + b.y + c.y + d.y) / 4,\n (a.z + b.z + c.z + d.z) / 4\n )\n end",
"def magnitude(vector)\n\n Math::sqrt((vector.x**2) + (vector.y**2) + (vector.z**2))\n end",
"def Point3dAreVectorsPerpendicular(arg0, arg1)\n ret = _invoke(1610743881, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def norm(p=2.0)\n if p.to_f == 2.0\n Blas::nrm2(@storage)\n else\n case p.infinite?\n when 1\n self[amax]\n when -1\n abs.min\n else\n map{|i| i**p}.asum**(1.0/p)\n end\n end\n end",
"def normal?\n magnitude == 1\n end",
"def start_vertex_normal\n end",
"def angle_rads \n\t\t\t2.0 * Math.atan2( self.vec.mag, self.scalar ) \n\t\tend",
"def centripetal_force_v2(mass, angular_velocity, radius)\n return mass * (angular_velocity ** 2.0) * radius\n end",
"def angle_with( vector )\n Math.acos( max(min(udot(vector),MAX_UDOT_PRODUCT), MIN_UDOT_PRODUCT) )\n end",
"def distance_to(pt)\n if pt.is_valid?\n vect = GeoFunctions.point_minus_point(pt,@origin)\n GeoFunctions.vector_dot_product(vect, @z_axis)\n else\n nil\n end\n end",
"def winkel(rhs)\n n = normalen_vektor\n m = rhs.normalen_vektor\n cos = (n * m).abs / (n.norm * m.norm)\n # Floating Point Ungenauigkeiten, können dazu führen, dass cos > 1.0\n # Dieser Fall wird hier abgefangen, damit acos keine Exception wirft\n if cos > 1.0\n cos = 1.0\n end\n Math.acos( cos )\n end",
"def full_angle_between(vector1, vector2, normal = Z_AXIS)\n direction = (vector1 * vector2) % normal\n angle = vector1.angle_between(vector2)\n angle = 360.degrees - angle if direction < 0.0\n angle\n end",
"def phi_norm(n)\n primes = n.prime_division.map(&:first)\n primes.map { |p| 1.0 - 1.0 / p }.inject(:*)\nend",
"def normalize\n [@x / Math.sqrt(@x**2 + @y**2), @y / Math.sqrt(@x**2 + @y**2)]\n end",
"def test_normal_stays_with_length_1_in_arcs\n erase_all()\n v = nil\n assert_nothing_raised do\n # Create a 1/2 circle perpendicular to the normal or Z axis\n center = Geom::Point3d.new 0,0,-30\n normal = Geom::Vector3d.new 0,0,1\n xaxis = Geom::Vector3d.new 1,0,0\n start_a = -Math::PI/2\n end_a = 4.0 * Math::PI # Large enough to make a circle\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_arc center, xaxis, normal, 5, start_a, end_a\n edge = edgearray[0]\n arccurve = edge.curve\n v = arccurve.normal\n end\n expected_normal = Geom::Vector3d.new 0,0,1\n assert_equal(expected_normal, v,\n 'Normal length != 1.0' )\n end",
"def normalize_vector(v)\n d = v[0]*v[0] + v[1]*v[1]\n if d != 1\n root = Math.sqrt(d)\n v[0] /= root\n v[1] /= root\n end\n v\n end",
"def ray_direction(\n field_of_view, # float\n size, # vec2\n frag_coord # vec2\n)\n xy = frag_coord.sub(size.div_scalar(2.0)) # xy: vec2\n z = size.y / Math.tan(radians(field_of_view) / 2.0)\n return Vec3.new(xy.x, xy.y, -z).normalize\nend",
"def norm(v)\n len = Math.sqrt(v[0]**2 + v[1]**2)\n [v[0] / len, v[1] / len] \nend",
"def /(scalar)\n if z\n Vector.new(x / scalar, y / scalar, z / scalar)\n elsif x && y\n Vector.new(x / scalar, y / scalar)\n else\n Vector.new\n end\n end",
"def angle_between(other)\n raise TypeError, 'Must pass only LinearEntity objects.' unless other.is_a?(LinearEntity)\n \n v1 = self.direction\n v2 = other.direction\n\n # Convert numerator to BigDecimal for more precision.\n numerator = BigDecimal(v1.dot(v2).to_f.to_s)\n denominator = v1.to_point.abs * v2.to_point.abs\n\n return Math.acos(numerator / denominator)\n end",
"def normal_matrix_at_position(distance)\n MSPhysics::Newton::CurvySlider.get_normal_martix_at_position(@address, distance)\n end",
"def add(rhs)\n Normal3.new(@x + rhs.x, @y + rhs.y, @z + rhs.z)\n end",
"def distance_to(point3)\n Math.sqrt(((@x-point3.x)**2)+((@y-point3.y)**2)+((@z-point3.z)**2))\n end",
"def norm(a, ord=nil, axis:nil, keepdims:false)\n a = Numo::NArray.asarray(a)\n\n # check axis\n if axis\n case axis\n when Integer\n axis = [axis]\n when Array\n if axis.size < 1 || axis.size > 2\n raise ArgmentError, \"axis option should be 1- or 2-element array\"\n end\n else\n raise ArgumentError, \"invalid option for axis: #{axis}\"\n end\n # swap axes\n if a.ndim > 1\n idx = (0...a.ndim).to_a\n tmp = []\n axis.each do |i|\n x = idx[i]\n if x.nil?\n raise ArgmentError, \"axis contains same dimension\"\n end\n tmp << x\n idx[i] = nil\n end\n idx.compact!\n idx.concat(tmp)\n a = a.transpose(*idx)\n end\n else\n case a.ndim\n when 0\n raise ArgumentError, \"zero-dimensional array\"\n when 1\n axis = [-1]\n else\n axis = [-2,-1]\n end\n end\n\n # calculate norm\n case axis.size\n\n when 1 # vector\n k = keepdims\n ord ||= 2 # default\n case ord.to_s\n when \"0\"\n r = a.class.cast(a.ne(0)).sum(axis:-1, keepdims:k)\n when \"1\"\n r = a.abs.sum(axis:-1, keepdims:k)\n when \"2\"\n r = Blas.call(:nrm2, a, keepdims:k)\n when /^-?\\d+$/\n o = ord.to_i\n r = (a.abs**o).sum(axis:-1, keepdims:k)**(1.0/o)\n when /^inf(inity)?$/i\n r = a.abs.max(axis:-1, keepdims:k)\n when /^-inf(inity)?$/i\n r = a.abs.min(axis:-1, keepdims:k)\n else\n raise ArgumentError, \"ord (#{ord}) is invalid for vector norm\"\n end\n\n when 2 # matrix\n if keepdims\n fixdims = [true] * a.ndim\n axis.each do |i|\n if i < -a.ndim || i >= a.ndim\n raise ArgmentError, \"axis (%d) is out of range\", i\n end\n fixdims[i] = :new\n end\n end\n ord ||= \"fro\" # default\n case ord.to_s\n when \"1\"\n r, = Lapack.call(:lange, a, '1')\n when \"-1\"\n r = a.abs.sum(axis:-2).min(axis:-1)\n when \"2\"\n svd, = Lapack.call(:gesvd, a, jobu:'N', jobvt:'N')\n r = svd.max(axis:-1)\n when \"-2\"\n svd, = Lapack.call(:gesvd, a, jobu:'N', jobvt:'N')\n r = svd.min(axis:-1)\n when /^f(ro)?$/i\n r, = Lapack.call(:lange, a, 'F')\n when /^inf(inity)?$/i\n r, = Lapack.call(:lange, a, 'I')\n when /^-inf(inity)?$/i\n r = a.abs.sum(axis:-1).min(axis:-1)\n else\n raise ArgumentError, \"ord (#{ord}) is invalid for matrix norm\"\n end\n if keepdims\n if NArray===r\n r = r[*fixdims]\n else\n r = a.class.new(1,1).store(r)\n end\n end\n end\n return r\n end",
"def axis \n\t\t\tvlen = self.vec.mag\n\t\t\tif vlen > 0.0 \n\t\t\t\treturn self.vec/vlen\n\t\t\telse\n\t\t\t\treturn ODE::Vector::new( 0.0, 0.0, 0.0 )\n\t\t\tend\n\t\tend",
"def magnitude; Math.sqrt x*x + y*y + z*z; end"
] | [
"0.6813453",
"0.6705782",
"0.64586323",
"0.64090943",
"0.6406997",
"0.6405543",
"0.6400595",
"0.63889956",
"0.63841814",
"0.6344507",
"0.6282347",
"0.6210597",
"0.6161307",
"0.6129256",
"0.61140496",
"0.5892716",
"0.5867458",
"0.58625585",
"0.58217424",
"0.58077574",
"0.57748884",
"0.5739723",
"0.57309926",
"0.5686199",
"0.5590786",
"0.5590236",
"0.5500847",
"0.5359906",
"0.53470397",
"0.5294392",
"0.5292631",
"0.52910936",
"0.52872384",
"0.5246558",
"0.5239696",
"0.52329594",
"0.5231949",
"0.52286804",
"0.5226896",
"0.52198255",
"0.5209534",
"0.5203714",
"0.5193947",
"0.51858497",
"0.51705396",
"0.514412",
"0.51391846",
"0.51385146",
"0.5109701",
"0.50859874",
"0.50560313",
"0.5040074",
"0.50381297",
"0.5035057",
"0.50264853",
"0.50053865",
"0.5003913",
"0.5003095",
"0.5000486",
"0.4974106",
"0.49671245",
"0.49500778",
"0.49152005",
"0.4907121",
"0.49056292",
"0.49009076",
"0.48931637",
"0.489145",
"0.48599088",
"0.4839113",
"0.48357388",
"0.4833436",
"0.483335",
"0.4822003",
"0.48197895",
"0.4801223",
"0.47735927",
"0.47567338",
"0.47546756",
"0.47455016",
"0.47236833",
"0.47040322",
"0.46876296",
"0.468632",
"0.46843514",
"0.46814004",
"0.4667127",
"0.46519274",
"0.46513996",
"0.46488124",
"0.4631695",
"0.4629948",
"0.46163186",
"0.46157992",
"0.46008483",
"0.45992044",
"0.45829383",
"0.4575021",
"0.4572616",
"0.4554666",
"0.4550842"
] | 0.0 | -1 |
The plane method is used to retrieve the plane of the arc. Refer to the Geom module for instructions to create a plane. | def plane
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plane\n return nil if @vertices.length < 3\n Plane.three_points(*@vertices[0..2])\n end",
"def distance_to_plane(plane)\n end",
"def add_plane()\n planes << Plane.new(\n gen_location,\n 0,\n width,\n height,\n gen_speed(),\n true\n )\n end",
"def add_plane(plane)\n @planes << plane\n end",
"def add_section_plane(plane)\n end",
"def show \n id = params[:id] # id is part of the route so we can grab the params[:id]\n @plane = Plane.find(id)\n\n render :show\n end",
"def is_plane\n\t\t@angle == 0 || @angle == 180\n\tend",
"def project_to_plane\n end",
"def has_plane(plane)\n @planes.include?(plane)\n end",
"def distance_to_plane(plane)\n plane.substitute(self).abs / (plane.find_normal_vector.length)\n end",
"def show\n @plane = Plane.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plane }\n end\n end",
"def on_plane?(plane)\n end",
"def create\n @plane = Plane.new(params[:plane])\n\n respond_to do |format|\n if @plane.save\n format.html { redirect_to @plane, notice: 'Plane was successfully created.' }\n format.json { render json: @plane, status: :created, location: @plane }\n else\n format.html { render action: \"new\" }\n format.json { render json: @plane.errors, status: :unprocessable_entity }\n end\n end\n end",
"def is_on_plane?(plane)\n plane.substitute(self) == 0\n end",
"def acquire_new_plane(aircrafttype)\n home_airport = self.home_airport_game\n param_array = [aircrafttype,self,home_airport]\n new_plane = PlaneCreator.new(param_array).manufacture\n finalize_acquisition_and_save(new_plane)\n end",
"def active_section_plane\n end",
"def active_section_plane\n end",
"def new\n @plane = Plane.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plane }\n end\n end",
"def release(plane)\n\n end",
"def slicing_planes(segmenter)\n plane_normal = segmenter.segment.line[1]\n segmenter.points.map { |point|\n [point.clone, plane_normal.clone]\n }\n end",
"def set_plane_picture\n @plane_picture = PlanePicture.find(params[:id])\n end",
"def destroy\n @plane = Plane.find(params[:id])\n @plane.destroy\n\n respond_to do |format|\n format.html { redirect_to planes_url }\n format.json { head :no_content }\n end\n end",
"def active_section_plane\n end",
"def plane_params\n params.require(:plane).permit(:name, :model, :year, :description, :matricula, :status)\n end",
"def set_airplane\n @airplane = Airplane.find(params[:id])\n end",
"def set_airplane\n @airplane = Airplane.find(params[:id])\n end",
"def setup_add_plane\n return TSBS.error(@acts[0], 3, @used_sequence) if @acts.size < 3\n file = @acts[1]\n sox = @acts[2] # Scroll X\n soy = @acts[3] # Scroll Y \n z = (@acts[4] ? Graphics.height + 10 : 4)\n dur = @acts[5] || 2\n opac = @acts[6] || 255\n get_spriteset.battle_plane.set(file,sox,soy,z,dur,opac)\n end",
"def set_planejamento\n @planejamento = Planejamento.find(params[:id])\n end",
"def landing (plane)\n\t\tfail 'This plane has already landed' if plane.flying? == false\n\t\tfail 'The airport is full. No landings are possible.' if full?\n\t\tplane = plane.landed?\n\t\t@planes << plane\n\t\tputs 'Your flight has landed'\n\n\tend",
"def initialize (capacity=DEFAULT_CAPACITY)\n\tplane = Plane.new\n\t@planes = [] \n\t@capacity = capacity\n\tend",
"def show\n @airplane = Airplane.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @airplane }\n end\n end",
"def active_section_plane=(sec_plane)\n end",
"def update\n @plane = Plane.find(params[:id])\n\n respond_to do |format|\n if @plane.update_attributes(params[:plane])\n format.html { redirect_to @plane, notice: 'Plane was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @plane.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @plane_photo = PlanePhoto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plane_photo }\n end\n end",
"def landing_clearance_for(plane)\n\t\t@airport.open_runway_for(plane)\n\tend",
"def create_battle_planes\n @battle_plane = Battle_Plane.new(@viewport1)\n end",
"def show\n @airplane = Airplane.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @airplane }\n end\n end",
"def take_off (plane)\n\t\tfail 'This plane has already departed' if plane.flying? == true\n\t\tplane = plane.departed?\n\t\t@planes[@planes.size - 1] = true\n\t\t@planes.delete(true)\n\t\tputs 'Your flight has departed'\n\tend",
"def allow_landing(plane)\n\t\traise \"This Airport is full\" if full?\n\t\traise \"This flight cannot land due to weather conditions\" if weather_stormy?\n\t\t# check your language, landed sounds like a question rather than a command\n\t\t# what about \"land!\" ?\n\t\tplane.landed!\n\t\t@planes << plane\n\tend",
"def create\n @airplane = Airplane.new(params[:airplane])\n\n respond_to do |format|\n if @airplane.save\n format.html { redirect_to @airplane, :notice => 'Airplane was successfully created.' }\n format.json { render :json => @airplane, :status => :created, :location => @airplane }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @airplane.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def Transform3dFromMirrorPlane(arg0, arg1)\n ret = _invoke(1610744055, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def test_plane_can_take_off\n @plane.fly!\n assert @plane.flying == true\n end",
"def create\n @typeairplane = Typeairplane.new(typeairplane_params)\n\n respond_to do |format|\n if @typeairplane.save\n format.html { redirect_to @typeairplane, notice: 'Typeairplane was successfully created.' }\n format.json { render :show, status: :created, location: @typeairplane }\n else\n format.html { render :new }\n format.json { render json: @typeairplane.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @airplanes = Airplane.all\n end",
"def show\n json_response(@airline.decorate.as_json(airplanes_details: true), :ok)\n end",
"def setup_del_plane\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n fade = @acts[1]\n get_spriteset.battle_plane.fadeout(fade)\n end",
"def destroy\n @airplane = Airplane.find(params[:id])\n @airplane.destroy\n\n respond_to do |format|\n format.html { redirect_to airplanes_url }\n format.json { head :no_content }\n end\n end",
"def Transform3dIsMirrorAboutPlane(arg0, arg1, arg2)\n ret = _invoke(1610744074, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def index\n @plane_pictures = PlanePicture.all\n end",
"def all_planes\n self.planes.collect do |plane_obj|\n plane_obj.update_status_and_location\n end\n end",
"def test_plane_has_a_flying_status_after_it_is_created\n assert_equal \"flying\", @plane.status\n end",
"def create\n @plane_picture = PlanePicture.new(plane_picture_params)\n\n respond_to do |format|\n if @plane_picture.save\n format.html { redirect_to @plane_picture, notice: 'Plane picture was successfully created.' }\n format.json { render :show, status: :created, location: @plane_picture }\n else\n format.html { render :new }\n format.json { render json: @plane_picture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @airplane = Airplane.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @airplane }\n end\n end",
"def set_typeairplane\n @typeairplane = Typeairplane.find(params[:id])\n end",
"def new\n @plane_photo = PlanePhoto.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plane_photo }\n end\n end",
"def surface miller, pnt = Vector[0.5, 0.5, 0.5]\n Surface.new(surface_converter(miller), real(pnt))\n end",
"def index\n @planejamentos = Planejamento.all\n end",
"def test_that_plane_can_land_after_airport_is_full_and_a_take_off_happened\n # Add 75 planes to the airport terminal\n (Airport::DEFAULT_CAPACITY).times do |i|\n @airport.land Plane.new(i)\n end\n\n assert_equal Airport::DEFAULT_CAPACITY, @airport.plane_count\n\n # Remove a plane from terminal, therefore terminal is no longer full\n @airport.takeoff(@plane)\n refute @airport.full?\n end",
"def destroy\n @airplane.destroy\n respond_to do |format|\n format.html { redirect_to airplanes_url }\n format.json { head :no_content }\n end\n end",
"def initilize land_planes=[] #collection of planes\n\t\t@land_planes = land_planes\n\tend",
"def create\n @plane_photo = PlanePhoto.new(params[:plane_photo])\n\n respond_to do |format|\n if @plane_photo.save\n format.html { redirect_to @plane_photo, notice: 'Plane photo was successfully created.' }\n format.json { render json: @plane_photo, status: :created, location: @plane_photo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @plane_photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def Point3dProjectToPlane3d(arg0, arg1, arg2 = nil, arg3 = nil)\n ret = _invoke(1610744125, [arg0, arg1, arg2, arg3], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_VARIANT, VT_BOOL])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def destroy\n @plane_photo = PlanePhoto.find(params[:id])\n @plane_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to plane_photos_url }\n format.json { head :no_content }\n end\n end",
"def index\n @typeairplanes = Typeairplane.all\n end",
"def create\n @planejamento = Planejamento.new(planejamento_params)\n\n respond_to do |format|\n if @planejamento.save\n format.html { redirect_to @planejamento, notice: 'Planejamento was successfully created.' }\n format.json { render :show, status: :created, location: @planejamento }\n else\n format.html { render :new }\n format.json { render json: @planejamento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @typeairplane.destroy\n respond_to do |format|\n format.html { redirect_to typeairplanes_url, notice: 'Typeairplane was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def perspective(sym)\n self.class.perspective(sym)\n end",
"def intersects_plane?(inst1,t1,plane_group,t2)\n #we will perform a test intersection to see if any new edges were created.\n if @helper_group==nil\n @helper_group=Sketchup.active_model.active_entities.add_group #this group will contain the edges from the test intersection\n @helper_group.entities.add_cpoint([0,0,0]) #adding a construction point to ensure that this group contains something to avoid automatic deletion by SketchUp\n end\n ents1=get_entities(inst1)\n ents2=@helper_group.entities\n new_edges=ents1.intersect_with(false,t1,ents2,@helper_group.transformation,false,[plane_group])\n\n if new_edges.length>0 #if new edges were created by the intersection\n return true\n else\n return false\n end\n end",
"def normal_vector a_point\n i_point = Point.new()\n i_point.add_object(self)\n plane = Plane.new.add_object(a_point).add_object([self, :normal])\n i_point.add_object(plane)\n Vector.new i_point, a_point\n end",
"def Matrix3dFromAxisAndRotationAngle(arg0, arg1)\n ret = _invoke(1610743898, [arg0, arg1], [VT_I4, VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def plane(origin, destination, date)\n\tparam_date = date[0,2] + \"%2f\" + date[2,2] + \"%2f20\" + date[4,2]\n\turl = \"http://www.tripsta.co.uk/airline-tickets/results?dep=#{origin}&arr=#{destination}&passengersAdult=1&passengersChild=0&passengersInfant=0&class=&airlineCode=&directFlightsOnly=0&extendedDates=0&isRoundtrip=0&obDate=#{param_date}&obTime=&ibDate=&ibTime=\"\n\txml= Nokogiri::HTML(open(url).read)\n\n\t#get prices\n\tprice_string = xml.css(\"span.amount\").to_s\n\tprice_string.gsub!(/\\s+/, \"\")\n\tprice_string.gsub!(/[<\\/spancl=\"\"moutright>]/, \"\") #I'm sure there's a better way but...\n\tprices = price_string.split('£')\n\tprices.delete_at(0)\n\t\n\t#get durations\n\tduration_string = xml.css('td.duration>span:first-child').inner_html\n\tduration_string.gsub!(/\\s+/, \"\")\n\tduration_string = duration_string.scan(/\\d*h\\d*min/)\n\tdurations = Array.new\n\tduration_string.each do |d|\n\t\tdur = d.gsub('h', ':')\n\t\tdur = dur.gsub!('min', '')\n\t\thours = dur[0, dur.index(':')]\n\t\tmins = dur[dur.index(':')+1, dur.length]\n\t\tif mins[0,1] == \"0\"\n\t\t\tmins = mins[1,1]\n\t\tend\n\t\tdurations.push(Integer(hours)*60 + Integer(mins))\n\tend\n\n\t#prepare results\n\tresults = Array.new\n\tprices.count().times do |count|\n\t \tpair = [prices[count], durations[count]]\n\t\tresults.push(pair)\n\tend\n\treturn results, url\nend",
"def Point3dPlanarAngleBetweenVectors(arg0, arg1, arg2)\n ret = _invoke(1610743866, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def makeArc\r\n @entities.add_arc @centre, @vector2, @normal, @toolRadius, 0, Math::PI, 6\r\n end",
"def arc(center, xaxis, normal, radius, start_angle, end_angle, num_segments = 12)\n # Generate the first point.\n t = Geom::Transformation.rotation(center, normal, start_angle)\n points = []\n points << center.offset(xaxis, radius).transform(t)\n # Prepare a transformation we can repeat on the last entry in point to complete the arc.\n t = Geom::Transformation.rotation(center, normal, (end_angle - start_angle) / num_segments)\n 1.upto(num_segments) {\n points << points.last.transform(t)\n }\n points\n rescue StandardError\n p [center, xaxis, normal, radius, start_angle, end_angle, num_segments]\n raise\n end",
"def show\n @planet=Planet.find(params[:id])\n \n end",
"def get_associations_with_http_info(associated_resource_type, resource_id, resource_type, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementPlaneApiAssociationsApi.get_associations ...'\n end\n # verify the required parameter 'associated_resource_type' is set\n if @api_client.config.client_side_validation && associated_resource_type.nil?\n fail ArgumentError, \"Missing the required parameter 'associated_resource_type' when calling ManagementPlaneApiAssociationsApi.get_associations\"\n end\n # verify enum value\n if @api_client.config.client_side_validation && !['NSGroup'].include?(associated_resource_type)\n fail ArgumentError, \"invalid value for 'associated_resource_type', must be one of NSGroup\"\n end\n # verify the required parameter 'resource_id' is set\n if @api_client.config.client_side_validation && resource_id.nil?\n fail ArgumentError, \"Missing the required parameter 'resource_id' when calling ManagementPlaneApiAssociationsApi.get_associations\"\n end\n # verify the required parameter 'resource_type' is set\n if @api_client.config.client_side_validation && resource_type.nil?\n fail ArgumentError, \"Missing the required parameter 'resource_type' when calling ManagementPlaneApiAssociationsApi.get_associations\"\n end\n # verify enum value\n if @api_client.config.client_side_validation && !['NSGroup', 'IPSet', 'MACSet', 'LogicalSwitch', 'LogicalPort', 'VirtualMachine', 'DirectoryGroup', 'VirtualNetworkInterface', 'TransportNode'].include?(resource_type)\n fail ArgumentError, \"invalid value for 'resource_type', must be one of NSGroup, IPSet, MACSet, LogicalSwitch, LogicalPort, VirtualMachine, DirectoryGroup, VirtualNetworkInterface, TransportNode\"\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 ManagementPlaneApiAssociationsApi.get_associations, 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 ManagementPlaneApiAssociationsApi.get_associations, must be greater than or equal to 0.'\n end\n\n # resource path\n local_var_path = '/associations'\n\n # query parameters\n query_params = {}\n query_params[:'associated_resource_type'] = associated_resource_type\n query_params[:'resource_id'] = resource_id\n query_params[:'resource_type'] = resource_type\n query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?\n query_params[:'fetch_ancestors'] = opts[:'fetch_ancestors'] if !opts[:'fetch_ancestors'].nil?\n query_params[:'included_fields'] = opts[:'included_fields'] if !opts[:'included_fields'].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\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 => 'AssociationListResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementPlaneApiAssociationsApi#get_associations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def has_planes?\t\t\n\t\t!@planes.empty?\n\tend",
"def destroy\n @plane_picture.destroy\n respond_to do |format|\n format.html { redirect_to plane_pictures_url, notice: 'Plane picture was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def plane_seats(category_id)\n seats.where(seat_category_id: category_id)\n end",
"def get_transport_zone_with_http_info(zone_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementPlaneApiNetworkTransportTransportZonesApi.get_transport_zone ...'\n end\n # verify the required parameter 'zone_id' is set\n if @api_client.config.client_side_validation && zone_id.nil?\n fail ArgumentError, \"Missing the required parameter 'zone_id' when calling ManagementPlaneApiNetworkTransportTransportZonesApi.get_transport_zone\"\n end\n # resource path\n local_var_path = '/transport-zones/{zone-id}'.sub('{' + 'zone-id' + '}', zone_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'])\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 => 'TransportZone')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementPlaneApiNetworkTransportTransportZonesApi#get_transport_zone\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def initialize\n # create 4 faces of an octahedron that\n # lie on the near side of the x-y plane.\n\n north = Vector.new 0.0, 1.0, 0.0\n east = Vector.new 1.0, 0.0, 0.0\n south = Vector.new 0.0, -1.0, 0.0\n west = Vector.new -1.0, 0.0, 0.0\n near = Vector.new 0.0, 0.0, 1.0\n\n northeast = Triangle.new north, east, near\n southeast = Triangle.new east, south, near\n southwest = Triangle.new near, south, west\n northwest = Triangle.new north, near, west\n\n @faces = [northeast, southeast, southwest, northwest] \n end",
"def surface(pitch:, heading:, roll:)\n args = [\n degree_to_f(heading),\n degree_to_f(pitch),\n degree_to_f(roll),\n ]\n api_set(API_MAP[:surface], args)\n end",
"def Point3dFromAngleDistance(arg0, arg1, arg2)\n ret = _invoke(1610744061, [arg0, arg1, arg2], [VT_R8, VT_R8, VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def destroy\n @plan = Plan.find(params[:id])\n @plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(planes_url) }\n format.xml { head :ok }\n end\n end",
"def zrotation\n end",
"def show\n @account_movement = @investor.account_movements.find(params[:id])\n authorize @account_movement\n end",
"def get_arc(name)\n arc = @objects[@arcs[name]]\n arc.nil? ? false : arc\n end",
"def show\n authorize @airport\n end",
"def airline\n fetch('aircraft.airline')\n end",
"def add_planet\n planet = Planet.new(get_planet_name, get_planet_distance, get_planet_rotation, get_planet_moons)\n return planet\nend",
"def draw_graph\n @graph = Array.new((2 * (self.down) + 1)){Array.new((2 * (self.across) + 1),\"\")}\n for i in 0..(2 * (self.down)) do\n for j in 0..(2 * (self.across)) do\n plane[i][j] == 1? graph[i][j] = '*': graph[i][j] = ' '\n end\n end\n end",
"def CreateArcElement4(arg0, arg1, arg2)\n ret = _invoke(1610744127, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def cramers_rule(ax,ay,az,a)\n # ax = array for all coefficients of x\n # ay = array for all coefficients of y\n # az = array for all coefficients of z\n # a = array for all constants\n x = Matrix[a,ay,az].determinant/Matrix[ax,ay,az].determinant.to_f\n y = Matrix[ax,a,az].determinant/Matrix[ax,ay,az].determinant.to_f\n z = Matrix[ax,ay,a].determinant/Matrix[ax,ay,az].determinant.to_f\n p x\n p y \n p z\n end",
"def perspective(sym)\n if @perspectives\n @perspectives[sym]\n else\n self.class.perspective(sym)\n end\n end",
"def show\n @flights = Flight.find(params[:id])\n \n respond_to do |format|\n format.html \n format.json { render json: @flights, :include => :airplane} \n end\n end",
"def Transform3dFromWorldToPlane3d(arg0)\n ret = _invoke(1610744148, [arg0], [VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def rayToCenter\r\n return (@camera.position + @camera.get_forward*far_plane).to_bullet\r\n end",
"def show\n @periodo_academico = PeriodoAcademico.find(params[:id])\n\n render json: @periodo_academico\n end",
"def create\n @airline = Airline.new(airline_params)\n\n if @airline.save\n json_response(@airline.decorate.as_json(airplanes_details: true),\n :created)\n else\n json_response(@airline.errors, :unprocessable_entity)\n end\n end",
"def airplane_params\n params.require(:airplane).permit(:name, :row, :column)\n end"
] | [
"0.7409262",
"0.6844087",
"0.6587345",
"0.649445",
"0.63328856",
"0.62948936",
"0.6240347",
"0.6212489",
"0.6106073",
"0.609031",
"0.60835725",
"0.5778194",
"0.5769269",
"0.57184255",
"0.55684406",
"0.5518494",
"0.5518494",
"0.5484175",
"0.5458743",
"0.54289806",
"0.5363179",
"0.5312563",
"0.529385",
"0.52746415",
"0.52097636",
"0.52097636",
"0.51616824",
"0.5127799",
"0.51056826",
"0.5103505",
"0.5098159",
"0.5097454",
"0.50774336",
"0.4985728",
"0.48658523",
"0.4842197",
"0.48333725",
"0.47942185",
"0.4693179",
"0.4670486",
"0.46508545",
"0.46182904",
"0.4608035",
"0.46078563",
"0.46053937",
"0.45904967",
"0.45686984",
"0.45378572",
"0.45323157",
"0.45175532",
"0.45017213",
"0.449451",
"0.44798973",
"0.44747874",
"0.44611958",
"0.44566354",
"0.44318107",
"0.43794125",
"0.43388233",
"0.4321643",
"0.43128276",
"0.42920884",
"0.4276101",
"0.42450365",
"0.4227613",
"0.4223065",
"0.4219746",
"0.42134705",
"0.41738945",
"0.4173238",
"0.4170623",
"0.41412267",
"0.41292676",
"0.41240215",
"0.41119352",
"0.41038716",
"0.408584",
"0.4076166",
"0.4034168",
"0.4030441",
"0.4021802",
"0.4020905",
"0.40171376",
"0.40165922",
"0.40137",
"0.4009229",
"0.40084174",
"0.4007091",
"0.40060404",
"0.40039364",
"0.40028554",
"0.40004507",
"0.39967233",
"0.39941373",
"0.3992186",
"0.3985079",
"0.39835772",
"0.39817473",
"0.3981142",
"0.39728606"
] | 0.70926946 | 1 |
The radius method is used to retrieve the radius of the arc. | def radius
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def radius #:nodoc:\n 0\n end",
"def radius #:nodoc:\n 0\n end",
"def c_radius \n Math.sqrt((@x*@x)+(@y*@y))\n end",
"def angle_of_specified_radius\n @angle_of_radius\n end",
"def radius\n \twidth / 2\n end",
"def radius\n radius = (@cubic_root.to_f * 0.1).to_i\n radius.zero? ? 1 : radius\n end",
"def radius( r = nil )\n if r\n @size = Pos.ini( r, r )\n else\n @size.xnow\n end\n end",
"def radius\n RANDOM_RADIUS / 111300\n end",
"def circumradius\n @circumradius ||= self.vertices[0].distance(self.circumcenter)\n end",
"def circumcircle\n # Circle.new(self.circumcenter, self.circumradius)\n end",
"def calculate_circle_area(radius)\n area = PI * radius**2\n return area\nend",
"def inradius\n @inradius ||= 2 * self.area / self.perimeter\n end",
"def compute_radius radius\n angle = Math.atan(Y_DIM/X_DIM) - Math.atan( (Y_DIM - D_DIST * (OUTER - radius)) / X_DIM)\n @image = MiniMagick::Image.open(@original_path)\n crop_square\n rotate angle\n depolarize\n resize\n read_row radius\n end",
"def circumference_of_circle(radius)\n 2 * Pi * radius\nend",
"def radius=(radius)\n @elementHash[:radius] = radius\n end",
"def area_of_circle(radius)\n Math::PI*(radius*radius)\nend",
"def radius_from(x, y)\n\t\traise 'Valentine#radius_from is not implemented. Please write this method.'\n\t\t# Hint: This should be computed based on the assumption that the resulting\n\t\t# circle must pass through 12 o'clock on the base circle.\n\tend",
"def radius=(r); @@R = r; end",
"def circleArea(r)\t\t\t# Function called circleArea with parameter r\n PI * r ** 2 \t\t\t# Compute the area of the circle with the given r radius\nend",
"def test_radius_in_arcs\n radius = nil\n assert_nothing_raised do\n # Create a 1/2 circle perpendicular to the normal or Z axis\n center = Geom::Point3d.new 0,0,-30\n normal = Geom::Vector3d.new 0,0,1\n xaxis = Geom::Vector3d.new 1,0,0\n start_a = -Math::PI/2\n end_a = 4.0 * Math::PI # Large enough to make a circle\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_arc center, xaxis, normal, 5, start_a, end_a\n edge = edgearray[0]\n arccurve = edge.curve\n radius = arccurve.radius\n end\n assert_equal(5, radius,\n 'Failed in test_radius' )\n end",
"def area radius \n puts radius * 2 * PI\n end",
"def calculate_circle_area(radius)\nend",
"def calculate_circle_area(radius)\nend",
"def calculate_circumference\n\n \t circumference = 2*3.14*@radius\n end",
"def radius(treasure)\n influence = 10\n base_radius + influence * popularity(treasure)\n end",
"def area\r\n return ( Math::PI * @radius * @radius).abs\r\n end",
"def circleArea(r)\t# Declare a function named circleArea that takes a parameter r (the radius)\n PI * r ** 2 \t# Calculate the area of the circle using the given values\nend",
"def diameter\n @diameter = @radius + @radius\n end",
"def circleArea(r)\n PI * r ** 2 \nend",
"def inradius\n (area / semiperimeter).to_f.round(precision)\n end",
"def area\n\t\treturn @PI * @radius ** 2\n\tend",
"def circle_area(radius)\n 3.14 * radius ** 2\nend",
"def circumference_of_circle(r)\n puts PI * 2 * r\nend",
"def circle_area(circle)\n circle.radius**2*Math::PI\nend",
"def area\n\t\tMath::PI * (self.radius ^ 2)\n\tend",
"def arc(x, y, radius, angle1, angle2)\n [x.value, y.value, radius.value, angle1.value * (Math::PI / 180.0), angle2.value * (Math::PI / 180.0)]\n end",
"def base_radius\n 200\n end",
"def rounded_corner(radius, direction)\n r = 0.5522 * radius\n old_mode, @mode = @mode, :relative\n case direction.to_s\n when 'lu' then curve_to(-r, 0, -radius, -(radius - r), -radius, -radius)\n when 'ld' then curve_to(-r, 0, -radius, radius - r, -radius, radius)\n when 'ru' then curve_to( r, 0, radius, -(radius - r), radius, -radius)\n when 'rd' then curve_to( r, 0, radius, radius - r, radius, radius)\n when 'ur' then curve_to( 0, -r, -(r - radius), -radius, radius, -radius)\n when 'ul' then curve_to( 0, -r, r - radius, -radius, -radius, -radius)\n when 'dr' then curve_to( 0, r, -(r - radius), radius, radius, radius)\n when 'dl' then curve_to( 0, r, r - radius, radius, -radius, radius)\n else raise TypeError(\"Invalid rounded corner argument: #{direction}\")\n end\n @mode = old_mode\n return self\n end",
"def radius1=(theRadius)\n @elementHash[:radius] = theRadius\n end",
"def radius(element, transformation=nil)\n\t [40, format_value(transformation ? transformation.transform(element.radius) : element.radius)]\n\tend",
"def radian_angle\n @angle * Math::PI / 180.0\n end",
"def rad\n x = self[0]\n y = self[1]\n if x >= 0 && y >= 0\n Math.atan( y.to_f/x )\n elsif x < 0 && y >= 0\n Math::PI + Math.atan( y.to_f/x )\n elsif x < 0 && y < 0\n Math::PI + Math.atan( y.to_f/x )\n else\n 2*Math::PI + Math.atan( y.to_f/x )\n end\n end",
"def get_area\n\t\tarea = @radius * 2 * @pi\n\t\tputs \"The area of the circle is #{area}\"\n\tend",
"def radius(row)\n return nil if row.obs_lat.present?\n\n r1 = lat_radius(row)\n r2 = long_radius(row)\n return nil if !r1 || !r2\n\n [r1, r2].max.to_f.round\n end",
"def perimeter radius\n puts radius * radius * PI\n end",
"def radius=(_radius)\n reset_caches unless @radius == _radius\n @radius = _radius\n end",
"def s_radius\n modulus\n end",
"def circleArea(r)\n # return PI * r^2\n PI * r ** 2\n # set end of circleArea function\nend",
"def circleArea(r)\n PI * r ** 2 \n #a sort of function called circleArea returns pi*r^2 when given r\nend",
"def test_arc_radius_after_creation_with_negative_radius\n radius = nil\n assert_nothing_raised do\n # Create a 1/2 circle perpendicular to the normal or Z axis\n center = Geom::Point3d.new 0,0,-30\n normal = Geom::Vector3d.new 0,0,1\n xaxis = Geom::Vector3d.new 1,0,0\n start_a = -Math::PI/2\n end_a = 4.0 * Math::PI # Large enough to make a circle\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_arc center, xaxis, normal, -5, start_a, end_a\n edge = edgearray[0]\n arccurve = edge.curve\n radius = arccurve.radius\n end\n assert_equal(5, radius,\n 'Failed in test_radius' )\n end",
"def withinRadius(latitude,longitiude,radius)\n \n rad = 3963.1676\n lat1 = to_rad(latitude.to_f)\n lat2 = to_rad(self.latitude.to_f)\n lon1 = to_rad(longitiude.to_f)\n lon2 = to_rad(self.longitude.to_f)\n dLat = lat2-lat1 \n dLon = lon2-lon1\n \n a = Math::sin(dLat/2) * Math::sin(dLat/2) +\n Math::cos(lat1) * Math::cos(lat2) * \n Math::sin(dLon/2) * Math::sin(dLon/2);\n \n c = 2 * Math::atan2(Math::sqrt(a), Math::sqrt(1-a));\n \n distance = rad * c\n \n #logger.debug \"distance IS\"\n #logger.debug distance\n #logger.debug \"radius IS\"\n #logger.debug radius\n \n return distance\n end",
"def to_rad\n self * Math::PI / 180\n end",
"def get_circle_area(ch, d, dir = 0)\n return Circle.new(ch.real_x / 4 + 16, ch.real_y / 4 + 16, d * 32, dir)\n end",
"def area_of_circle(r)\n puts PI * (r**2)\nend",
"def distance\n distance_and_arc[:distance]\n end",
"def distance\n distance_and_arc[:distance]\n end",
"def get_circle(location, r)\n\t\t\tstartY = location.y - r\n\t\t\t\n\t\t\tstartX = 0\n\t\t\tendX = 0\n\t\t\tif startY % 2 == 0\n\t\t\t\tstartX = location.x - (r / 2.0).floor\n\t\t\t\tendX = location.x + r;\n\t\t\telse\n\t\t\t\tstartX = location.x - (r / 2.0).floor\n\t\t\t\tendX = location.x + r;\n\t\t\t\tif r % 2 == 0\n\t\t\t\t\tstartX+=1; endX+=1;\n\t\t\t\tend\n\t\t\tend\t\n\t\t\t\n\t\t\tendY = location.y + r;\n\t\t\tcircle_width = 2 * r + 1;\n\t\t\tdelta_y_odd = -1;\n\t\t\tdelta_y_even = -1;\n\t\t\toffset = 0;\n\t\t\tcircle = Array.new;\n\t\t\tfor y in Range.new(startY, endY)\n\t\t\t\tlength = circle_width - (y - location.y).abs;\n\t\t\t\t\n\t\t\t\tif (y % 2 == 0)\n\t\t\t\t\tif (delta_y_even == -1)\n\t\t\t\t\t\tdelta_y_even = (y - location.y).abs;\n\t\t\t\t\tend\n\t\t\t\t\toffset = ((y - location.y).abs - delta_y_even) / 2;\n\t\t\t\t\t\n\t\t\t\t\tif ((location.y - r) % 2 != 0)\n\t\t\t\t\t\toffset-=1;\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tif (delta_y_odd == -1)\n\t\t\t\t\t\tdelta_y_odd = (y - location.y).abs;\n\t\t\t\t\tend\n\t\t\t\t\toffset = (((y - location.y).abs - delta_y_odd) / 2.0).floor - 1;\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tstart = startX + offset;\n\t\t\t\t#trace(\"y = \" + y + \"location = \" + location.y + \" : \" + length);\n\t\t\t\t\n\t\t\t\ts = \"\";\n\t\t\t\tfor x in Range.new(start, start + length - 1)\n\t\t\t\t\ts += x.to_s + \" \";\n\t\t\t\t\t\t\tcircle.push(Location.new(x,y));\n\t\t\t\tend\n\t\t\t\t#trace(s);\n\t\t\tend\n\t\t\treturn circle;\n\t\tend",
"def get_player_radius\n # if in the right half of the screen\n if $game_player.screen_x > 320\n # get screen x\n x_max = $game_player.screen_x\n else\n # get other screen x\n x_max = 640 - $game_player.screen_x\n end\n # if in the lower half of the screen\n if $game_player.screen_y > 240\n # get screen y\n y_max = $game_player.screen_y\n else\n # get other screen y\n y_max = 480 - $game_player.screen_y\n end\n # return distance\n return Math.hypot(x_max, y_max) / 32\n end",
"def radius(n)\n sphere = Math::PI * 4/3 * n**3\n return sphere.round(2)\nend",
"def radius?\n if radius.nil?\n errors.add(:radius, \"can't be blank\")\n return false\n end\n return true\n end",
"def calc_inches_per_degree(radius)\r\n if (radius == 0)\r\n return 0\r\n else\r\n return calc_circumference(radius) / 360.0\r\n end\r\nend",
"def arc(x, y, radius, start_angle, end_angle)\n start_angle = radians(90-start_angle)\n end_angle = radians(90-end_angle)\n clockwise = 1 # 1 = clockwise, 0 = counterclockwise\n CGContextAddArc(@ctx, x, y, radius, start_angle, end_angle, clockwise)\n CGContextDrawPath(@ctx, KCGPathStroke)\n end",
"def area_circ(rad) # Declaring the area_circ method (area_circ is a local variable) and let it accept a local variable rad\n return $Pie*rad**2 # Returning a calculated value using a global variable and a local Variable\nend",
"def arc(x, y, radius, startAngle, endAngle, anticlockwise)\n drawCircle(x, y, radius) if startAngle == 0 && endAngle == Math::PI * 2\n\n arc = endAngle - startAngle\n\n # Calculate the start point of the path\n x1, y1 = calc_point(radius, startAngle, x, y)\n x2, y2 = calc_point(radius, endAngle, x, y)\n\n direction = anticlockwise ? SweepDirection.Counterclockwise : SweepDirection.Clockwise\n if anticlockwise\n large_arc = arc >= Math::PI ? false : true\n else\n large_arc = arc >= Math::PI ? true : false\n end\n\n drawArc(x1, y1, x2, y2, radius, large_arc, direction)\n end",
"def initialize(radius)\n @radius = radius\n end",
"def initialize(radius)\n @radius = radius\n end",
"def quarter_circle(center, options)\n case options[:quadrant]\n when 1\n start_angle = 0\n end_angle = 90\n when 2\n start_angle = 90\n end_angle = 180\n when 3\n start_angle = 180\n end_angle = 270\n when 4\n start_angle = 270\n end_angle = 360\n end\n pie_slice(center,\n :radius => options[:radius],\n :start_angle => start_angle,\n :end_angle => end_angle,\n :stroke_both_sides => options[:stroke_both_sides])\n end",
"def get_perimeter\n\t\tputs \"The perimeter of the circle is #{@radius * @radius * @pi}\"\n\tend",
"def calculate_area\n\n \tarea = 3.14*@radius*@radius\n\n end",
"def drawCircle(x, y, radius)\n x1, y1 = calc_point(radius, Math::PI * 2 - 0.0001, x, y)\n # TODO: is there a better way of expressing this?\n x2, y2 = calc_point(radius, 0, x, y)\n drawArc(x1, y1, x2, y2, radius, true, SweepDirection.Counterclockwise)\n end",
"def incircle\n # Circle.new(self.incenter, self.inradius)\n end",
"def r\n Math::sqrt(r2)\n end",
"def radius2=(theRadius)\n @elementHash[:radius2] = theRadius\n end",
"def arc_to_radius(pMill, pCent_x, pCent_y, pBeg_radius,pBeg_deg, pEnd_radius, pEnd_deg,pBegZ, pEndZ)\r\n# # # # # # # # # # # # # # # # # # # \r\n # start as center and \r\n mill = pMill\r\n \r\n if (pBegZ > 0)\r\n pBegZ = 0 - pBegZ\r\n end\r\n if (pEndZ > 0)\r\n pEndZ = 0 - pEndZ\r\n end\r\n\r\n tot_step_cnt = 0\r\n #print \"(arc_to_radius pCent_x=\", pCent_x, \" pCent_y=\", pCent_y, \"pBeg_radius\", pBeg_radius, \" pBeg_deg=\", pBeg_deg, \" pEnd_radius=\", pEnd_radius, \" pEnd_deg=\", pEnd_deg, \")\\n\"\r\n\r\n # TODO: Calculate the distance traveled along the arc\r\n # and use it to adjust the amount of depth that can be\r\n # calculated. \r\n \r\n # TODO: Add a flag which is a face on versus a incremental side cut and when face on we need to either run slower or take a more shallow cut.\r\n curr_deg = pBeg_deg\r\n radius_delta = pEnd_radius - pBeg_radius\r\n degree_delta = pEnd_deg - pBeg_deg\r\n radius_inc = pMill.cut_inc\r\n def_deg_step = degrees_for_distance(pBeg_radius, 0.02)\r\n print \"(def_deg_step = \", def_deg_step, \")\\n\"\r\n # this is the number of degrees in 0.01 inches\r\n # or 1/100 of an inch. \r\n no_steps_deg = degree_delta / def_deg_step # One degree \r\n print \"(degree_delta=\", degree_delta, \")\\n\"\r\n print \"(radius_delta=\", radius_delta, \")\\n\"\r\n print \"(radius_inc=\", radius_inc, \")\\n\"\r\n no_steps = (radius_delta / radius_inc)\r\n if (no_steps_deg > no_steps)\r\n no_steps = no_steps_deg \r\n # use what ever number of steps is greater \r\n # by degree change or radius change. \r\n end \r\n \r\n # if there are not enough calculated steps\r\n # then increase automatically to use a larger\r\n # number to get some reasonably small granulatiry\r\n # of move.\r\n if (no_steps < 1)\r\n no_steps = 5 \r\n elsif (no_steps < 10)\r\n no_steps *= 5\r\n end\r\n \r\n no_steps = no_steps.to_i\r\n no_steps_f = no_steps.to_f\r\n radius_inc = radius_delta. / no_steps_f.abs\r\n degree_inc = degree_delta / no_steps_f.abs \r\n depth_inc = (pMill.cut_depth_inc * 0.7) / (no_steps_f.abs * 2.0) # have of the cut depth one way and one half on the way back\r\n curr_depth = pBegZ \r\n cnt = 0\r\n depth_end_flag = false\r\n \r\n while (depth_end_flag == false) \r\n curr_deg = pBeg_deg \r\n curr_radius = pBeg_radius \r\n \r\n for step_cnt in (1..no_steps) \r\n cp = calc_point_from_angle(\r\n pcx=pCent_x,\r\n pcy=pCent_y, \r\n angle=curr_deg, \r\n length=curr_radius)\r\n \r\n if (tot_step_cnt == 0)\r\n pMill.retract(pBegZ + 0.1)\r\n pMill.move_fast(cp.x,cp.y)\r\n pMill.move_fast(cp.x,cp.y, pBegZ)\r\n pMill.move(cp.x,cp.y)\r\n pMill.plung(curr_depth) \r\n end\r\n \r\n pMill.move(cp.x, cp.y, curr_depth)\r\n tot_step_cnt += 1\r\n curr_radius += radius_inc\r\n curr_deg += degree_inc \r\n curr_depth -= depth_inc \r\n if (curr_depth < pEndZ)\r\n curr_depth = pEndZ\r\n end \r\n end # for\r\n\r\n if curr_depth == pEndZ \r\n depth_end_flag = true\r\n end\r\n \r\n \r\n # Arch back to start \r\n for step_cnt in (1..no_steps)\r\n cp = calc_point_from_angle(\r\n pcx=pCent_x,\r\n pcy=pCent_y, \r\n angle=curr_deg, \r\n length=curr_radius)\r\n pMill.move(cp.x, cp.y, curr_depth)\r\n tot_step_cnt += 1\r\n curr_radius -= radius_inc\r\n curr_deg -= degree_inc \r\n curr_depth -= depth_inc \r\n if (curr_depth < pEndZ)\r\n curr_depth = pEndZ\r\n end \r\n end # for\r\n end # while depth\r\n\r\n pMill.retract(pBegZ)\r\n return 1\r\n\r\nend",
"def circle(*args)\n Circle.new(self, *args)\n end",
"def radians\n self * 180 / Math::PI\n end",
"def calcPolyRadius(in_rad, num_sides)\r\n x = (Math::PI) / num_sides.to_f # number in radians\r\n return in_rad.to_f / (Math.cos(x))\r\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 getAsCircle\n @node\n end",
"def north_radius(xy, cluster)\n north_arr = []\n x, y = xy[0], xy[1]\n ny = y - 1\n in_cluster = cluster.include?([x, ny])\n while in_cluster == true\n \tnorth_arr << [x, ny]\n \tny -= 1\n \tin_cluster = false unless cluster.include?([x, ny])\n end\n radius = north_arr.length\n return radius \n end",
"def arc_around(center, options)\n open_curve(arc_vertices(center, options))\n end",
"def deg2rad\n self * (Math::PI/180)\n end",
"def circle(id, x:0, y:0, r:0.5, **attrs)\n attrs.update(width:r*2, height:r*2)\n ellipse(id, x:x, y:y, **attrs)\n end",
"def earth_radius(point)\n a = EARTH_EQUATORIAL_RADIUS\n b = EARTH_POLAR_RADIUS\n latitude = point.latitude\n\n Math.sqrt(((a**2 * Math.cos(latitude))**2 + (b**2 * Math.sin(latitude))**2) / ((a * Math.cos(latitude))**2 + (b * Math.sin(latitude))**2))\n end",
"def set_Radius(value)\n set_input(\"Radius\", value)\n end",
"def set_Radius(value)\n set_input(\"Radius\", value)\n end",
"def to_rad(n_decimals = nil)\n include Math unless defined?(Math)\n radians = self * PI / 180.0\n return radians if n_decimals.nil?\n radians.round(n_decimals)\n end",
"def radians\n Science::Angle.new(self, :radians)\n end",
"def radius_statistics\n super\n end",
"def add_arc(centerPoint: { x: 0.0, y: 0.0 }, radius: 1.0, \n startAngle: 0.0, endAngle: Math::PI * 0.25,\n isClockwise: false)\n pathElement = { elementtype: :patharc,\n centerpoint: centerPoint,\n radius: radius,\n startangle: startAngle,\n endangle: endAngle,\n clockwise: isClockwise }\n @pathArray.push(pathElement)\n @pathArray\n end",
"def within_radius_of?(center, radius)\n return false unless center\n (self.point == center.point) || (center.distance_to(self) <= radius)\n end",
"def diameter\n rim + (tire * 2)\n end",
"def degrees_for_distance(radius, desired_distance)\r\n# # # # # # # # # #\r\n degree_inc = 0.01\r\n last_degree_inc = degree_inc\r\n if (radius == 0)\r\n return nil\r\n end\r\n ci = calc_circumference(radius)\r\n ratio = desired_distance / calc_circumference(radius)\r\n answer = 360 * ratio\r\n return answer\r\n \r\n #cp = calc_point_from_angle(0,0, 0, radius)\r\n #cp2 = calc_point_from_angle(0,0, 1.0, radius)\r\n #dist_for_single_degree = calc_distance(cp.x,cp.y, cp2.x,cp2.y)\r\n #num_degrees_fit_in_distance = desired_distance / dist_for_single_degree\r\n #return num_degrees_fit_in_distance\r\nend",
"def find_radi(xy, cluster)\n north = north_radius(xy, cluster)\n south = south_radius(xy, cluster)\n east = east_radius(xy, cluster)\n west = west_radius(xy, cluster)\n ne = ne_radius(xy, cluster)\n nw = nw_radius(xy, cluster)\n se = se_radius(xy, cluster)\n sw = sw_radius(xy, cluster)\n\n all = [north, south, east, west, ne, nw, se, sw]\n return all\n end",
"def fillCircle(x, y, r)\n fillArc(x-r, y-r, 2*r, 2*r, 0, 360*64)\n end",
"def max_radius\n 4000\n end",
"def diameter\n wheel.diameter\n end",
"def diameter\n wheel.diameter\n end",
"def pie\n diameter = @options[:diameter].to_f\n background_color = @options[:background_color]\n\n create_canvas(diameter, diameter, background_color)\n\n share_color = @options[:share_color]\n remain_color = @options[:remain_color]\n percent = @norm_data[0]\n\n # Adjust the radius so there's some edge left in the pie\n r = diameter/2.0 - 2\n @draw.fill(remain_color)\n @draw.ellipse(r + 2, r + 2, r , r , 0, 360)\n @draw.fill(share_color)\n\n # Special exceptions\n if percent == 0\n # For 0% return blank\n @draw.draw(@canvas)\n return @canvas\n elsif percent == 100\n # For 100% just draw a full circle\n @draw.ellipse(r + 2, r + 2, r , r , 0, 360)\n @draw.draw(@canvas)\n return @canvas\n end\n\n # Okay, this part is as confusing as hell, so pay attention:\n # This line determines the horizontal portion of the point on the circle where the X-Axis\n # should end. It's caculated by taking the center of the on-image circle and adding that\n # to the radius multiplied by the formula for determinig the point on a unit circle that a\n # angle corresponds to. 3.6 * percent gives us that angle, but it's in degrees, so we need to\n # convert, hence the muliplication by Pi over 180\n arc_end_x = r + 2 + (r * Math.cos((3.6 * percent)*(Math::PI/180)))\n\n # The same goes for here, except it's the vertical point instead of the horizontal one\n arc_end_y = r + 2 + (r * Math.sin((3.6 * percent)*(Math::PI/180)))\n\n # Because the SVG path format is seriously screwy, we need to set the large-arc-flag to 1\n # if the angle of an arc is greater than 180 degrees. I have no idea why this is, but it is.\n percent > 50? large_arc_flag = 1: large_arc_flag = 0\n\n # This is also confusing\n # M tells us to move to an absolute point on the image. We're moving to the center of the pie\n # h tells us to move to a relative point. We're moving to the right edge of the circle.\n # A tells us to start an absolute elliptical arc. The first two values are the radii of the ellipse\n # the third value is the x-axis-rotation (how to rotate the ellipse if we wanted to [could have some fun\n # with randomizing that maybe), the fourth value is our large-arc-flag, the fifth is the sweep-flag,\n # (again, confusing), the sixth and seventh values are the end point of the arc which we calculated previously\n # More info on the SVG path string format at: http://www.w3.org/TR/SVG/paths.html\n path = \"M#{r + 2},#{r + 2} h#{r} A#{r},#{r} 0 #{large_arc_flag},1 #{arc_end_x},#{arc_end_y} z\"\n @draw.path(path)\n\n @draw.draw(@canvas)\n @canvas\n end",
"def initialize(r)\n\t\t@radius = r\n\tend"
] | [
"0.7484214",
"0.7484214",
"0.71898097",
"0.7043045",
"0.68739986",
"0.6802838",
"0.67836565",
"0.6706568",
"0.66439414",
"0.66078806",
"0.65697163",
"0.6569488",
"0.65577185",
"0.6551047",
"0.6422337",
"0.6412117",
"0.6405594",
"0.6403764",
"0.6375612",
"0.63689554",
"0.6361686",
"0.63389796",
"0.63389796",
"0.63227224",
"0.63136035",
"0.6246977",
"0.62312984",
"0.62298065",
"0.6197518",
"0.61803585",
"0.6178809",
"0.61685663",
"0.6114056",
"0.6101921",
"0.60798544",
"0.60462403",
"0.6038329",
"0.59866756",
"0.59815323",
"0.59450763",
"0.5935333",
"0.5934803",
"0.59336",
"0.59240615",
"0.59179395",
"0.58843356",
"0.58794284",
"0.5851646",
"0.58406377",
"0.58213675",
"0.58051604",
"0.57917243",
"0.5787603",
"0.57500654",
"0.5725079",
"0.5725079",
"0.5651096",
"0.56351167",
"0.56231624",
"0.55653906",
"0.5564063",
"0.55470467",
"0.55355656",
"0.5534627",
"0.5504083",
"0.5500233",
"0.54931927",
"0.54892427",
"0.54871804",
"0.54497135",
"0.54476225",
"0.5416454",
"0.5411696",
"0.54070634",
"0.54055053",
"0.5394096",
"0.5377443",
"0.5366263",
"0.5365209",
"0.5354136",
"0.5350967",
"0.5335348",
"0.53264815",
"0.5323069",
"0.5313658",
"0.5313658",
"0.53124946",
"0.52881235",
"0.5277511",
"0.5274245",
"0.5265826",
"0.5251931",
"0.52280474",
"0.52267617",
"0.5226677",
"0.52027243",
"0.5190328",
"0.5190328",
"0.51796985",
"0.5175761"
] | 0.7225848 | 2 |
The start_angle method is used to retrieve the angle of the start of the arc, measured from the X axis in radians. | def start_angle
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_angle\n MSPhysics::Newton::Hinge.get_start_angle(@address)\n end",
"def start_angle=(angle)\n MSPhysics::Newton::Hinge.set_start_angle(@address, angle)\n end",
"def test_start_angle_large_angle\n start_angle = nil\n assert_nothing_raised do\n # Create a 1/2 circle perpendicular to the normal or Z axis\n center = Geom::Point3d.new 0,0,-30\n normal = Geom::Vector3d.new 0,0,1\n xaxis = Geom::Vector3d.new 1,0,0\n start_a = 0.5\n end_a = 3.0 * Math::PI # Large enough to make a circle\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_arc center, xaxis, normal, 5, start_a, end_a\n edge = edgearray[0]\n arccurve = edge.curve\n start_angle = arccurve.start_angle\n end\n assert_equal(0.5, start_angle,\n 'Failed: start_angle != 0.0' )\n end",
"def startChangeAngle\n\t\t\t\t@startChangeAngle = Gosu::milliseconds()\n\t\t\tend",
"def arc(x, y, r, start_angle, end_angle, move_to0=false)\n cur_page.arc(x, y, r, start_angle, end_angle, move_to0)\n end",
"def test_start_angle_negative_stays_negative\n start_angle = nil\n assert_nothing_raised do\n # Create a 1/2 circle perpendicular to the normal or Z axis\n center = Geom::Point3d.new 0,0,40\n normal = Geom::Vector3d.new 0,0,1\n xaxis = Geom::Vector3d.new 1,0,0\n start_a = -Math::PI/2\n end_a = Math::PI\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_arc center, xaxis, normal, 5, start_a, end_a\n edge = edgearray[0]\n arccurve = edge.curve\n start_angle = arccurve.start_angle\n end\n assert_equal(-Math::PI/2, start_angle,\n 'Failed: start_angle != -Math::PI/2' )\n end",
"def test_start_angle_on_circle\n start_angle = nil\n assert_nothing_raised do\n centerpoint = Geom::Point3d.new\n # Create a circle perpendicular to the normal or Z axis\n vector = Geom::Vector3d.new 0,0,1\n vector2 = vector.normalize!\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_circle centerpoint, vector2, 11\n edge = edgearray[0]\n arccurve = edge.curve\n start_angle = arccurve.start_angle\n end\n assert_equal(0.0, start_angle,\n 'Failed: start_angle != PI*2' )\n end",
"def arc(center, xaxis, normal, radius, start_angle, end_angle, num_segments = 12)\n # Generate the first point.\n t = Geom::Transformation.rotation(center, normal, start_angle)\n points = []\n points << center.offset(xaxis, radius).transform(t)\n # Prepare a transformation we can repeat on the last entry in point to complete the arc.\n t = Geom::Transformation.rotation(center, normal, (end_angle - start_angle) / num_segments)\n 1.upto(num_segments) {\n points << points.last.transform(t)\n }\n points\n rescue StandardError\n p [center, xaxis, normal, radius, start_angle, end_angle, num_segments]\n raise\n end",
"def arc(x, y, radius, start_angle, end_angle)\n start_angle = radians(90-start_angle)\n end_angle = radians(90-end_angle)\n clockwise = 1 # 1 = clockwise, 0 = counterclockwise\n CGContextAddArc(@ctx, x, y, radius, start_angle, end_angle, clockwise)\n CGContextDrawPath(@ctx, KCGPathStroke)\n end",
"def angle_from_input\n\n return if @path.size < 2\n return unless @active_controller.is_a? Symbol\n\n i = @active_controller == :start ? 0 : 1\n corner = @path[-i]\n ref_vector = @path[-i] - @path[1 - 3 * i]\n input_vector = corner - @ip.position\n return unless input_vector.valid?\n return if input_vector.parallel? Z_AXIS\n return if input_vector.parallel? ref_vector\n\n angle = -(MyGeom.angle_in_plane input_vector, ref_vector)\n angle -= GRAPHICAL_ANGLES[i]\n angle = ((angle+90.degrees)%180.degrees)-90.degrees\n\n @end_angles[i] = angle\n\n end",
"def angle\n @angle\n end",
"def points_for_arc(x, y, r, start_angle, end_angle)\n cur_page.points_for_arc(x, y, r, start_angle, end_angle)\n end",
"def angle\n rad / Math::PI * 180\n end",
"def angle()\n a, c = @view__.angle, @context__\n c ? c.fromDegrees__(a) : a * Processing::GraphicsContext::DEG2RAD__\n end",
"def calculate_radians\n if x_length == 0 || y_length == 0\n angle_to_start_of_quadrant\n else\n case angle_to_end_of_quadrant\n when DEGREES_90\n angle_ignoring_quadrant\n when DEGREES_180\n DEGREES_180 - angle_ignoring_quadrant\n when DEGREES_270\n DEGREES_180 + angle_ignoring_quadrant\n else\n DEGREES_360 - angle_ignoring_quadrant\n end\n end\n end",
"def arc(x, y, radius, angle1, angle2)\n [x.value, y.value, radius.value, angle1.value * (Math::PI / 180.0), angle2.value * (Math::PI / 180.0)]\n end",
"def angle\n Math.atan2( @y, @x )\n end",
"def angle\n Math.atan2(@y, @x)\n end",
"def calc_points_for_arc(cx, cy,radius=1.0, beg_angle=0, end_angle = 360, degree_inc = 1.0)\r\n# - - - - - - - - - - - - - - - - - - - - -\r\n if beg_angle > end_angle\r\n #swap if starting point is higher than ending point\r\n tt = beg_angle\r\n end_angle = beg_angle\r\n beg_angle = tt\r\n end #if\r\n res = Array.new\r\n curr_angle = beg_angle\r\n #p2 = calc_point_rotated_relative(p2.x, p2.y,1)\r\n #print \"angle_inc = \", angle_inc, \"\\n\"\r\n #print \"pp = \", pp, \"\\n\"\r\n \r\n start_point = calc_point_from_angle(0,0,beg_angle, radius)\r\n last_point = start_point \r\n res.append(start_point)\r\n \r\n # sets up the change of the \r\n stop_angle = end_angle\r\n if (end_angle == 360) && (beg_angle == 0)\r\n stop_angle -= 1\r\n end #if\r\n\r\n cnt = 1\r\n #print \" relative rotate point = \", p2, \"\\n\"\r\n while (curr_angle <= stop_angle)\r\n curr_angle += angle_inc\r\n p2 = calc_point_rotated_relative(last_point.x, last_point.y, angle_inc)\r\n print \" relative rotate point = \", p2, \"\\n\"\r\n res.append(p2)\r\n last_point = p2\r\n end\r\n return cnt\r\nend",
"def get_arc_points(cx,cy,radius, beg_angle, end_angle, degree_inc = 1.0)\r\n# - - - - - - - - - - - - - - - - - - - -\r\n deg = beg_angle\r\n degree_inc = degree_inc.abs\r\n ares = Array.new\r\n while (deg < end_angle)\r\n #print \"(deg = \", deg, \")\\n\"\r\n cp = calc_point_from_angle(cx,cy, deg, tradius)\r\n ares.append(cp)\r\n deg += degree_inc\r\n end #while\r\nend",
"def add_arc(centerPoint: { x: 0.0, y: 0.0 }, radius: 1.0, \n startAngle: 0.0, endAngle: Math::PI * 0.25,\n isClockwise: false)\n pathElement = { elementtype: :patharc,\n centerpoint: centerPoint,\n radius: radius,\n startangle: startAngle,\n endangle: endAngle,\n clockwise: isClockwise }\n @pathArray.push(pathElement)\n @pathArray\n end",
"def angle_of_specified_radius\n @angle_of_radius\n end",
"def arc_around(center, options)\n open_curve(arc_vertices(center, options))\n end",
"def angle_from_arc(arc_length, offset_angle=0.0, precision=1.0)\n index = cumulative_distances(precision, offset_angle).closest_index(arc_length)\n @cumulative_distance_angles[index]\n end",
"def start_point\n raise Error::UnsupportedOperation, \"Method Curve#start_point not defined.\"\n end",
"def min_angle=(value)\n MSPhysics::Newton::Corkscrew.set_min_angle(@address, value)\n end",
"def cur_angle\n MSPhysics::Newton::Corkscrew.get_cur_angle(@address)\n end",
"def min_angle\n MSPhysics::Newton::Corkscrew.get_min_angle(@address)\n end",
"def arc(x, y, radius, startAngle, endAngle, anticlockwise)\n drawCircle(x, y, radius) if startAngle == 0 && endAngle == Math::PI * 2\n\n arc = endAngle - startAngle\n\n # Calculate the start point of the path\n x1, y1 = calc_point(radius, startAngle, x, y)\n x2, y2 = calc_point(radius, endAngle, x, y)\n\n direction = anticlockwise ? SweepDirection.Counterclockwise : SweepDirection.Clockwise\n if anticlockwise\n large_arc = arc >= Math::PI ? false : true\n else\n large_arc = arc >= Math::PI ? true : false\n end\n\n drawArc(x1, y1, x2, y2, radius, large_arc, direction)\n end",
"def cur_angle\n MSPhysics::Newton::Hinge.get_cur_angle(@address)\n end",
"def rotate_around_origin(angle)\n sin_of_angle = Math.sin(angle)\n cos_of_angle = Math.cos(angle)\n\n Point.new(\n x * cos_of_angle - y * sin_of_angle,\n x * sin_of_angle + y * cos_of_angle\n )\n end",
"def angle(x1, y1, x2, y2)\n end",
"def angle\n v = to_vec\n if v[1] == 0.0\n nil\n else\n v.angle\n end\n end",
"def angle x1, y1, a, m, c\n x2, y2 = project x1, y1, a, m\n line x1, y1, x2, y2, c\n end",
"def angle_a\n Angle.new(\n self,\n :a,\n (\n (\n Math.acos((b**2 + c**2 - a**2) / (2.0 * b * c)) * 180\n ) / Math::PI\n )\n )\n end",
"def angle\n ns = norm\n x_ = @x / ns\n y_ = @y / ns\n\n Math.atan2(x_, y_)\n end",
"def angle_deg\n angle * RAD_TO_DEG\n end",
"def start(begin_offset = 0)\n super\n @on = resolve(@on)\n @origin_x = resolve(@origin_x)\n @origin_y = resolve(@origin_y)\n @delta_x = resolve(@end_x) - @origin_x\n @delta_y = resolve(@end_y) - @origin_y\n end",
"def start(begin_offset = 0)\n super\n @on = resolve(@on)\n @origin_x = resolve(@origin_x)\n @origin_y = resolve(@origin_y)\n @delta_x = resolve(@end_x) - @origin_x\n @delta_y = resolve(@end_y) - @origin_y\n end",
"def angle_at(point)\n Point.angle(centre, point)\n end",
"def radians\n Science::Angle.new(self, :radians)\n end",
"def radian_angle\n @angle * Math::PI / 180.0\n end",
"def rotation(during, on, angle_start, angle_end, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE)\n ScalarAnimation.new(during, on, :angle=, angle_start, angle_end, distortion: distortion, time_source: time_source)\n end",
"def min_angle\n 6 * self.min\n end",
"def phase_angle_arcsec\n return @phase_angle_arcsec unless @phase_angle_arcsec.nil?\n @phase_angle_arcsec = (sphase / 1500)\n @phase_angle_arcsec\n end",
"def test_end_angle_negative_stays_negative\n end_angle = nil\n assert_nothing_raised do\n # Create a 1/2 circle perpendicular to the normal or Z axis\n center = Geom::Point3d.new 0,0,40\n normal = Geom::Vector3d.new 0,0,1\n xaxis = Geom::Vector3d.new 1,0,0\n start_a = 0.0\n end_a = -Math::PI\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_arc center, xaxis, normal, 5, start_a, end_a\n edge = edgearray[0]\n arccurve = edge.curve\n end_angle = arccurve.end_angle\n end\n assert_equal(-Math::PI, end_angle,\n 'Failed: end_angle != -PI' )\n end",
"def start(begin_offset = 0)\n super\n @on = resolve(@on)\n @origin = resolve(@origin)\n @delta = resolve(@end) - @origin\n end",
"def test_end_angle_on_circle\n end_angle = nil\n assert_nothing_raised do\n centerpoint = Geom::Point3d.new\n # Create a circle perpendicular to the normal or Z axis\n vector = Geom::Vector3d.new 0,0,1\n vector2 = vector.normalize!\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_circle centerpoint, vector2, 11\n edge = edgearray[0]\n arccurve = edge.curve\n end_angle = arccurve.end_angle\n end\n assert_equal(Math::PI*2, end_angle,\n 'Failed: end_angle != PI*2' )\n end",
"def test_end_angle_large_angle\n end_angle = nil\n assert_nothing_raised do\n # Create a 1/2 circle perpendicular to the normal or Z axis\n center = Geom::Point3d.new 0,0,-30\n normal = Geom::Vector3d.new 0,0,1\n xaxis = Geom::Vector3d.new 1,0,0\n start_a = 0.0\n end_a = 3.0 * Math::PI # Large enough to make a circle\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_arc center, xaxis, normal, 5, start_a, end_a\n edge = edgearray[0]\n arccurve = edge.curve\n end_angle = arccurve.end_angle\n end\n assert_equal(Math::PI*2, end_angle,\n 'Failed: end_angle != PI*2' )\n end",
"def turn_left(angle)\n @angle = @angle + angle*Math::PI / 180\n end",
"def start(begin_offset = 0)\n super\n @on = resolve(@on)\n @origin = resolve(@origin)\n @base = @origin\n @end = resolve(@end)\n @delta = resolve(@end) - @origin + 1\n @end, @origin = @origin, @end if @end < @origin\n @factor = resolve(@factor)\n end",
"def rotate(angle)\n x = x2 - x1\n y = y2 - y1\n cos_angle = Math.cos(angle)\n sin_angle = Math.sin(angle)\n new_x = (x * cos_angle) - (y * sin_angle)\n new_y = (x * sin_angle) - (y * cos_angle)\n Line.new(p1, Point.new(x1 + new_x, y1 + new_y))\n end",
"def rad\n x = self[0]\n y = self[1]\n if x >= 0 && y >= 0\n Math.atan( y.to_f/x )\n elsif x < 0 && y >= 0\n Math::PI + Math.atan( y.to_f/x )\n elsif x < 0 && y < 0\n Math::PI + Math.atan( y.to_f/x )\n else\n 2*Math::PI + Math.atan( y.to_f/x )\n end\n end",
"def angle_c\n Angle.new(\n self,\n :c,\n (\n (\n Math.acos((a**2 + b**2 - c**2) / (2.0 * a * b)) * 180\n ) / Math::PI\n )\n )\n end",
"def calculate_arc_parameters(begin_x, begin_y, end_x, end_y)\n distance = Math.sqrt(((begin_x - end_x)**2) + ((begin_y - end_y)**2))\n angle_b_o = Math.atan2(begin_y, -begin_x)\n angle_b_e = Math.atan2(begin_y - end_y, end_x - begin_x)\n angle_e_b_o = angle_b_o - angle_b_e\n if angle_e_b_o < -Math::PI\n angle_e_b_o += 2 * Math::PI\n elsif angle_e_b_o > Math::PI\n angle_e_b_o -= 2 * Math::PI\n end\n\n radius = (distance / (2.0 * Math.cos((Math::PI / 2.0) - angle_e_b_o.abs))).round(2)\n sweep = angle_e_b_o.negative? ? 0 : 1\n {\n radius: radius,\n sweep: sweep,\n }\n end",
"def angle=(angle)\n c = @context__\n @view__.angle =\n c ? c.toAngle__(angle) : angle * Processing::GraphicsContext::RAD2DEG__\n angle\n end",
"def determine_angle(angle, range)\n range.include?(angle) ? angle.to_f : angle.divmod(MAX_DEGREE_RANGE).last\nend",
"def theta_range\n theta_start = -Math::PI / 2\n theta_end = (Math::PI / 2) - @theta_res\n (theta_start..theta_end).step(@theta_res).to_a\n end",
"def x_offset angle, distance\n\t\t\tdistance * Math.sin(angle * Math::PI/180)\n\t\tend",
"def angle(*args)\n Math.acos(self.dot(*args))\n end",
"def next_to(angle, x=@x, y=@y)\n points = case angle % 360\n when 0 then\n [[x, y - 1], [x + WIDTH - 1, y - 1]]\n when 90 then\n [[x + WIDTH, y], [x + WIDTH, y + HEIGHT - 1]]\n when 180 then\n [[x, y + HEIGHT], [x + WIDTH - 1, y + HEIGHT]]\n when 270 then\n [[x - 1, y], [x - 1, y + HEIGHT - 1]]\n else puts \"Trig unimplemented\"; []\n end\n @space.entities_at_points(points)\n end",
"def next_to(angle, x=@x, y=@y)\n points = case angle % 360\n when 0 then\n [[x, y - 1], [x + WIDTH - 1, y - 1]]\n when 90 then\n [[x + WIDTH, y], [x + WIDTH, y + HEIGHT - 1]]\n when 180 then\n [[x, y + HEIGHT], [x + WIDTH - 1, y + HEIGHT]]\n when 270 then\n [[x - 1, y], [x - 1, y + HEIGHT - 1]]\n else puts \"Trig unimplemented\"; []\n end\n @space.entities_at_points(points)\n end",
"def rotate(angle) \n set RGhost::Cursor.rotate(angle)\n end",
"def radians\n self * 180 / Math::PI\n end",
"def safe_angle(angle)\n if angle < @angle_range.min\n @angle_range.min\n elsif angle > @angle_range.max\n @angle_range.max\n else\n angle\n end\n end",
"def GenSilkArc(x, y, width, height, startangle, deltaangle)\n thickness = GetDim('silkwidth')\n PcbElementArc(x, y, width, height, startangle, deltaangle, thickness)\nend",
"def x\n r * Math.cos(theta)\n end",
"def angle(current, percent)\n\n range = Quadrant.angle_range_for(@bounds.quadrant(current))\n interp = Interpolate::Points.new({\n 0 => range.begin,\n 1 => range.end\n })\n\n interp.at(percent).to_i % 360\n end",
"def angle(path)\n io_for(path).angle\n end",
"def anglecw\n 360 - angle\n end",
"def calc_point_from_angle(cx, cy, angle, length)\r\n # - - - - - - - - - - - - - - - - - - - - -\r\n #System.Convert.ToInt32(System.Convert.ToDouble(originX) * Math.Cos(radians)), originY + #System.Convert.ToInt32(System.Convert.ToDouble(originY) * Math.Sin(radians)))\r\n # radians = (90 - angle) * degree_to_radian;\r\n if (angle > 360) \r\n angle = angle % 360\r\n end #if\r\n #print \"(cx=\", cx, \" cy=\", cy, \" angle=\", angle, \", length=\", length, \")\\n\"\r\n\r\n #if (angle > 360)\r\n # angle = angle % 360.0\r\n\r\n \r\n quad = 1\r\n tang = angle\r\n\r\n## if (angle == 9999)\r\n## if (angle == 0)\r\n## return CNCPoint.new(cx, cy - length)\r\n## elsif (angle == 90)\r\n## return CNCPoint.new(cx + length, cy)\r\n## elsif(angle == 180)\r\n## return CNCPoint.new(cx, cy - length)\r\n## elsif (angle == 270)\r\n## return CNCPoint.new(cx - length, cy)\r\n## elsif(angle == 360)\r\n## return CNCPoint.new(cx, cy - length)\r\n## elsif (angle > 90)\r\n## quad = 2\r\n## tang -= 90\r\n## elsif (angle > 180)\r\n## quad = 3\r\n## tang -= 180\r\n## elsif (angle > 270)\r\n## quad = 4\r\n## tang -= 180\r\n## end #else\r\n## end # 99999\r\n## #print \"tang = \", tang, \" quad=\", quad, \"\\n\"\r\n##\r\n\r\n radians = conv_degree_to_radian(tang -90)\r\n\r\n\r\n new_x = cx + Math.cos(radians) * (length)\r\n new_y = cy + Math.sin(radians) * (length)\r\n\r\n #print \"(new_x = \", new_x, \" new_y=\", new_y, \")\\n\"\r\n##\r\n## if (angle == 9999)\r\n## case quad\r\n## when 1\r\n## # nothing needs to be done\r\n## when 2\r\n## # x is ok\r\n## #new_y = 0 - new_y\r\n## when 3\r\n## new_x = 0 - new_x\r\n## new_y = 0 - new_y\r\n## when 4\r\n## new_x = 0 - new_x\r\n## end\r\n## end # 9999\r\n##\r\n\r\n aRes = CNCPoint.new(new_x, new_y)\r\n return aRes\r\n end",
"def angle(other)\n\n # Two options here:\n #\n # 1. Math.atan2(other.cross_length(self), dot(other)) \n #\n # This is stable but slower (x 1.5)\n #\n # 2. Math.acos(dot(other) / (r * other.r)) \n #\n # This is faster but unstable around 0 and pi where the gradient of acos approaches \n # infinity. An alternative way to view this is that the gradient of cos approaches\n # zero and small differences in angle can be indistinguishable at some number of \n # decimal places.\n #\n \n # Math.acos(dot(other) / (r * other.r)) \n Math.atan2(other.cross_length(self), dot(other)) \n end",
"def coords_from_angle(theta)\n cos_theta = Math.cos(theta)\n sin_theta = Math.sin(theta)\n radius = @a * @b / Math.sqrt(@b * @b * cos_theta * cos_theta + @a * @a * sin_theta * sin_theta)\n [radius * cos_theta, radius * sin_theta]\n end",
"def angles\n [angle_a, angle_b, angle_c]\n end",
"def line_angle(p1,p2)\n v1 = RBA::DPoint.new(1,0)\n v2 = p2-p1\n return vector_angle(v1,v2)\n end",
"def to_a; [angle, axis.to_a] end",
"def calculate_heading()\n @heading[:x], @heading[:y] = Params::directional_vector @angle\n end",
"def angle_deg=( angle_deg )\n self.angle = angle_deg * DEG_TO_RAD\n self\n end",
"def start\n attributes.fetch(:start)\n end",
"def start\n attributes.fetch(:start)\n end",
"def angle\r\n self.data.map(&:angle)\r\n end",
"def angle\n equation_1 = @wind_velocity * ETA\n apparent_wind_agl = @real_wind_agl - 0.0001\n\n until @variance > equation_1 - 0.001 && @variance < equation_1 + 0.001\n equation_2 = sailboat_transform(apparent_wind_agl)\n\n apparent_wind_agl -= 0.00001\n @variance = equation_1 - equation_2\n end\n puts \"Apparent Wind Angle:\\n#{apparent_wind_agl}\"\n apparent_wind_agl\n end",
"def start\n\t\t\t@start < @end ? @start : @end\n\t\tend",
"def draw_rotate_circle_arrow(context,center, length, angle, clockwise)\n\n arrow_points = []\n if not clockwise\n arrow_points << CGPointMake(- 40, 0) << CGPointMake(0, -50)\n arrow_points << CGPointMake(40, 0)\n else\n arrow_points << CGPointMake(- 40, 0) << CGPointMake(0, 50)\n arrow_points << CGPointMake(40, 0)\n end\n\n arrow_transform_pointer = Pointer.new(CGAffineTransform.type)\n arrow_transform_pointer[0] = CGAffineTransformMakeTranslation( center.x, center.y)\n arrow_transform_pointer[0] = CGAffineTransformRotate(arrow_transform_pointer[0], angle)\n arrow_transform_pointer[0] = CGAffineTransformTranslate(arrow_transform_pointer[0],length, 0)\n\n path = CGPathCreateMutable()\n CGPathMoveToPoint(path, arrow_transform_pointer, length, 0)\n\n arrow_points.each do |point|\n CGPathAddLineToPoint(path, arrow_transform_pointer, point.x, point.y)\n end\n CGContextAddPath(context, path)\n CGContextSetFillColorWithColor(context, UIColor.redColor.CGColor)\n CGContextDrawPath(context, KCGPathFill)\n end",
"def getAngle(c1,c2)\n x = c2[0] - c1[0]\n y = c2[1] - c1[1]\n x = x <= -180 ? x + 360 : x\n x = x >= 180 ? x - 360 : x\n\n a = Math.atan2(y, x)\n rescue\n p \"Error x=#{x}, y=#{y} sq= #{Math.sqrt(x*x+y*y)} rat=#{x / Math.sqrt(x*x+y*y)}\"\n raise Error\n end",
"def calc_angle(x1, y1, x2, y2)\r\n# - - - - - - - - - - - - - - - - - - - -\r\n if (x1 == x2)\r\n if (y2 >= y1)\r\n return 0\r\n else\r\n return 180\r\n end #else\r\n elsif (y1 == y2)\r\n if (x2 >= x1)\r\n return 90\r\n else\r\n return 270\r\n end #else\r\n else\r\n x1 = x1 + 0.0 # force to be floating point\r\n x2 = x2 + 0.0 # force to floating point\r\n slope = (y2-y1) / (x2-x1)\r\n radians = Math.atan(slope)\r\n degrees = conv_radian_to_degree(radians)\r\n # Handle Adjusting Quadrent\r\n if ((x2 > x1) && (y2 > y1))\r\n # Quadrent 1;\r\n degrees = degrees\r\n elsif ((x2 > x1) && (y2 < y1))\r\n # Quadrent 2\r\n degrees = 90 - degrees;\r\n elsif ((x2 < x1) && (y2 < y1))\r\n # Quadrent 3\r\n degrees = 270 - degrees\r\n else\r\n # must be Quadrent 4\r\n degrees = 270 - degrees\r\n end # else\r\n end # else\r\n return degrees\r\nend",
"def start\n @start ||= operands.detect {|op| op.is_a?(Start)}\n end",
"def calculate_rad_angle_between(target)\n Math.atan2(target.y - y, target.x - x)\n end",
"def rotate!( angle_rad )\n self.angle += angle_rad\n self\n end",
"def rotate(angle)\n primitive 'rotate ' + sprintf('%g', angle)\n end",
"def to_radians\n self * Math::PI.fdiv(180)\n end",
"def start=(value)\n\t\t\t@start = value\n\t\tend",
"def +(other)\n return self.class.radians(@angle + other)\n end",
"def angle_b\n Angle.new(\n self,\n :b,\n (\n (\n Math.acos((a**2 + c**2 - b**2) / (2.0 * a * c)) * 180\n ) / Math::PI\n )\n )\n end",
"def initialize(angle = 0, radians = false)\n # assumes that we are getting an angle in degrees.\n @angle = if radians == true || radians == :radians\n angle.to_f # works for String, Fixed, other Angles and for Float.\n elsif angle.instance_of?(Array)\n self.class.decimal_deg(*angle).to_radians\n else\n angle.to_radians # we have a String and Numeric class version of this. Another Angle will work too.\n end\n end",
"def cur_cone_angle\n MSPhysics::Newton::BallAndSocket.get_cur_cone_angle(@address)\n end",
"def initialize(inclination_deg, period_min, swath_width_km, start_clat_deg, count=0)\n @declination_rad = nil # lazy\n @inclination_rad = inclination_deg * PI / 180.0\n @period_s = period_min * 60\n @swath_width_rad = swath_width_km * 1000 / EARTH_RADIUS_M\n @start_clat_rad = start_clat_deg * PI / 180.0\n @count = count\n end",
"def angle=(target)\n\n @target_angle = target.to_i\n\n end",
"def start_point\n o = st_start_point\n [o.y, o.x]\n end",
"def other_angle(a, b)\n 180 - (a + b)\nend"
] | [
"0.7077961",
"0.6539086",
"0.64301413",
"0.6416333",
"0.640749",
"0.6346705",
"0.62377787",
"0.62319887",
"0.6158887",
"0.61364585",
"0.60976297",
"0.59716296",
"0.58776385",
"0.5831484",
"0.57564276",
"0.57015544",
"0.5690798",
"0.5688671",
"0.56833404",
"0.5678322",
"0.5658935",
"0.5584475",
"0.5579035",
"0.55752504",
"0.5543056",
"0.5519118",
"0.5507561",
"0.5488516",
"0.5488511",
"0.5466528",
"0.54615635",
"0.5438573",
"0.5401239",
"0.5387247",
"0.53629243",
"0.5343148",
"0.5310815",
"0.5304735",
"0.5304735",
"0.52996194",
"0.5268374",
"0.52658135",
"0.52624226",
"0.5243634",
"0.5216459",
"0.5179648",
"0.5168826",
"0.5151172",
"0.51507443",
"0.51464134",
"0.5122101",
"0.5120895",
"0.5118559",
"0.5113541",
"0.51127464",
"0.51036924",
"0.5055831",
"0.5054461",
"0.5046447",
"0.5041619",
"0.5006659",
"0.5006659",
"0.50029784",
"0.49932322",
"0.49927446",
"0.49800116",
"0.497641",
"0.49614373",
"0.49568632",
"0.4938232",
"0.49316782",
"0.49267128",
"0.49227077",
"0.49190745",
"0.4906615",
"0.4901089",
"0.49007326",
"0.48876446",
"0.4886298",
"0.4886298",
"0.48768258",
"0.48731044",
"0.4866492",
"0.48631886",
"0.48487678",
"0.48451337",
"0.4828988",
"0.48153275",
"0.4809385",
"0.480868",
"0.48034123",
"0.47916526",
"0.47895727",
"0.47883132",
"0.47770703",
"0.47688127",
"0.47669968",
"0.4766391",
"0.47589558",
"0.4758203"
] | 0.7093622 | 0 |
The xaxis method is used to retrieve the X axis of the coordinate system for the curve. Note that the length of the returned vector is equal to the radius of the underlying curve. | def xaxis
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_x_axis(params = {})\n @x_axis = convert_axis_args(@x_axis, params)\n end",
"def axis\n axes = Sketchup.active_model.axes\n\n axes.axes.find do |axis|\n position.on_line?([axes.origin, axis])\n end\n end",
"def get_x_axis_labels\n 5\n end",
"def x\n @point[0]\n end",
"def print_x_axis_values(domain_x)\n x_value_lenght = determine_maximal_domainvalue_length(domain_x)\n print_x_axis_markings(domain_x)\n print_x_axis_init(domain_x)\n index = 5\n while ((x_value_lenght / 2 + index) <= domain_x.number_of_values)\n extend_x_axis_output(index, domain_x)\n index += 5\n end\n end",
"def ax\n points[0][0]\n end",
"def axes\n return @axes\n end",
"def axis \n\t\t\tvlen = self.vec.mag\n\t\t\tif vlen > 0.0 \n\t\t\t\treturn self.vec/vlen\n\t\t\telse\n\t\t\t\treturn ODE::Vector::new( 0.0, 0.0, 0.0 )\n\t\t\tend\n\t\tend",
"def axis_x=(v)\n if diagonal_2d? || !diagonal_2d_enabled?\n @no_scale_mask[NO_XY_SCALE] = !(v && axis_y?)\n @no_scale_mask[NO_XZ_SCALE] = !(v && axis_z?)\n end\n if diagonal_3d? || !diagonal_3d_enabled?\n @no_scale_mask[NO_XYZ_SCALE] = !(v && axis_y? && axis_z?)\n end\n @no_scale_mask[NO_X_SCALE] = !v\n apply\n end",
"def print_x_axis_init(domain_x)\n (@max_y_indentation).times { print \" \"}\n value = \"#{domain_x.get_coordinate_to_index(0).round(3)}\"\n print \"%#{value.length}s\" % \"#{value}\"\n end",
"def vector_x max_value = 1\n max_value * Math.cos(self.to_radians)\n end",
"def graph_x_axis_for(x_axis, date)\n case @conditions[:breakdown_type]\n when \"Quarterly\"\n x_axis.match(/-Q(.)/)\n x_axis.sub(/-Q.$/, \".\" + (($1.to_i - 1) * 25).to_s)\n when \"Weekly\"\n date = Date.parse(x_axis.sub(/Week of /, \"\"))\n other_thing = (date.cweek / 52.0)\n if other_thing >= 1.0\n other_thing = 0.999\n end\n date.cwyear.to_s + \".\" + other_thing.to_s.gsub(/0\\./, \"\")\n when \"Daily\"\n date.year + (date.yday / 365.0)\n when \"Yearly\"\n x_axis\n when \"Monthly\"\n (date.year * 12) + date.month\n else\n raise NoMethodError\n end\n end",
"def print_x_axis\n print \"%#{@entry_size}s |\" % [\"portion in %\"]\n\n axis_numbers = initialize_axis_numbers\n counter = 0.1;\n 1.upto(@width) do |i|\n if ( i % (counter * @width).round == 0)\n print \"|\"\n axis_numbers = axis_numbers[0...-1].concat((counter * 100).round.to_s)\n counter += 0.1\n else\n print \"-\"\n axis_numbers.concat(\" \")\n end\n end\n\n puts \"\\n#{axis_numbers}\"\n end",
"def test_xaxis_returns_vector3d\n centerpoint = Geom::Point3d.new\n # Create a circle perpendicular to the normal or Z axis\n vector = Geom::Vector3d.new 0,0,1\n vector2 = vector.normalize!\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_circle centerpoint, vector2, 50\n edge = edgearray[0]\n arccurve = edge.curve\n\n result = arccurve.xaxis.class\n expected = Geom::Vector3d\n assert_equal(expected, result, 'Expected does not match result.')\n end",
"def axes\n end",
"def x\n position.x if position\n end",
"def x\n position.x if position\n end",
"def fpr_axis\n axis = []\n @p.each_index do |i|\n axis << fpr(i)\n end\n axis\n end",
"def x\n @position.x\n end",
"def delete_x_axis\n self.GetXaxis.SetLabelOffset(999)\n self.GetXaxis.SetTitleOffset(999)\n end",
"def axes(origin, x_axis)\n y_axis = x_axis.axes.x\n z_axis = x_axis.axes.y\n @transformation = Geom::Transformation.axes(origin, x_axis, y_axis, z_axis)\n nil\n end",
"def axes\n @axes ||= Axes.new(:cat_axis => CatAxis, :val_axis => ValAxis)\n end",
"def x\n rect.x\n end",
"def axes\n @axes ||= Axes.new(:cat_axis => CatAxis, :val_axis => ValAxis)\n end",
"def chxp\n return nil unless show_axes?\n labels = []\n axis.values.each_with_index do |a,i|\n if a[:labels][:positions] == :auto\n l = auto_labels(a).keys\n elsif [:left, :right].include?(axis.keys[i])\n l = label_positions_by_values(a)\n else\n l = label_positions_by_data_points(a)\n end\n labels << \"#{i},\" + l.join(',')\n end\n labels.join('|')\n end",
"def date_to_x_coordinate(date) # => Numeric\n date_range_begin, date_range_end = @x_axis_tick_dates.first.jd, @x_axis_tick_dates.last.jd\n date_range_length = date_range_end - date_range_begin \n ( @x_axis_length * ( date.jd - date_range_begin ) * 1.0 ) / date_range_length \n end",
"def show_x_axis\n false\n end",
"def x\n r * Math.cos(theta)\n end",
"def x\n xe = nil\n each_element('x') { |e| xe = e }\n xe\n end",
"def gets_x_axis\n\t\t@a = gets.chomp.to_i\n\t\tif (@a < @board_size_min) || (@a >@board_size_max)\n\t\t\tputs \"sorry you went outside of the range #{@board_size_min} and #{@board_size_max}\"\n\t\t\tputs \"try again\"\n\t\t\tgets_x_axis\n\t\tend\n\tend",
"def point_x\n self.coord.split(\"_\")[0]\n end",
"def xdim\n @xdim || 1\n end",
"def xdim\n @xdim || 1\n end",
"def xdim\n @xdim || 1\n end",
"def tpr_axis\n axis = []\n @p.each_index do |i|\n axis << tpr(i)\n end\n axis\n end",
"def test_xaxis_length_matches_radius\n axis = nil\n radius = 5\n assert_nothing_raised do\n centerpoint = Geom::Point3d.new\n # Create a circle perpendicular to the normal or Z axis\n vector = Geom::Vector3d.new 0,0,1\n vector2 = vector.normalize!\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_circle centerpoint, vector2, radius\n edge = edgearray[0]\n arccurve = edge.curve\n axis = arccurve.xaxis\n end\n assert_equal(radius, axis.length,\n 'Axis length does not match radius' )\n end",
"def actual_x_position\n return adjust_x_to_zoom(@actual_x + set_adjust[0])\n end",
"def x\n @components[:x]\n end",
"def get_x\n grid_width = @window.current_map.width\n half_x = WIDTH / 2 - GRID / 2\n @x = [[@player.x - half_x, 0].max, grid_width * GRID - WIDTH].min\n end",
"def get_axis(dimension)\n nil\n end",
"def center_x\n return CENTER_X\n end",
"def x\n @x ||= SpatialStats::Queries::Variables.query_field(@scope, @x_field)\n .standardize\n end",
"def rel_x\n return x - Graphics.width/2\n end",
"def rel_x\n return x - Graphics.width/2\n end",
"def xlabel(label)\n @methods[:x_axis_label] = label\n end",
"def set_x_axis(params = {})\n @date_category = true if ptrue?(params[:date_axis])\n @x_axis.merge_with_hash(params)\n end",
"def point_x(index)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.GraphComponentState_point_x(@handle.ptr, index)\n result\n end",
"def axes=(value)\n @axes = value\n end",
"def x=(value)\n rect.x = value\n end",
"def x_end\n x_end_dependencies = [calculated_width, default_x?, !default_x? && x]\n if x_end_dependencies != @x_end_dependencies\n # avoid recalculation of dependencies\n calculated_width, is_default_x, x = @x_end_dependencies = x_end_dependencies\n shape_width = calculated_width.to_f\n shape_x = is_default_x ? 0 : x.to_f\n @x_end = shape_x + shape_width\n end\n @x_end\n end",
"def center_x\n (Graphics.width / 32 - 1) / 2.0\n end",
"def center_x\n (Graphics.width / 32 - 1) / 2.0\n end",
"def center_x\n (Graphics.width / 32 - 1) / 2.0\n end",
"def mouseX()\n @view__.mouseX\n end",
"def x(type, input_domain = nil, input_range = nil)\n\n if (type.is_a? Sol::Scale)\n scale = type\n else\n scale = Sol.scale(type)\n scale.domain(input_domain) if input_domain\n scale.range(input_range) if input_range\n end\n @properties[\"x\"] = scale.spec\n\n return self\n\n end",
"def mouse_x\n end",
"def x(value)\n fail XOutOfBounds if x_out_of_bounds?(value)\n\n attributes[:geometry][:x] = value\n end",
"def getScaleX()\n return @device.getScaleX() ;\n end",
"def axis(axis_)\n @structure.axis(axis_)\n end",
"def x\n OFFSET_FROM_LEFT + (coordinates.x * 700).to_i\n end",
"def axis(axis_)\n case axis_\n when ::Integer\n @indexes[axis_]\n else\n @names[axis_.to_s]\n end\n end",
"def x\n return nil unless @grpc.position\n @grpc.position.x\n end",
"def axes(*)\n super\n end",
"def xMax\n @origin_x + length\n end",
"def scene_x(x)\n (x.to_f / $window.width) * @scene_width\n end",
"def vx\n return (self.x + (viewport == nil ? 0 : viewport.rect.x))\n end",
"def min_x\n @pos.x\n end",
"def write_cat_axis(params) # :nodoc:\n x_axis = params[:x_axis]\n y_axis = params[:y_axis]\n axis_ids = params[:axis_ids]\n\n # if there are no axis_ids then we don't need to write this element\n return unless axis_ids\n return if axis_ids.empty?\n\n position = @cat_axis_position\n is_y_axis = @horiz_cat_axis\n\n # Overwrite the default axis position with a user supplied value.\n position = x_axis.position || position\n\n @writer.tag_elements('c:catAx') do\n write_axis_id(axis_ids[0])\n # Write the c:scaling element.\n write_scaling(x_axis.reverse)\n\n write_delete(1) unless ptrue?(x_axis.visible)\n\n # Write the c:axPos element.\n write_axis_pos(position, y_axis.reverse)\n\n # Write the c:majorGridlines element.\n write_major_gridlines(x_axis.major_gridlines)\n\n # Write the c:minorGridlines element.\n write_minor_gridlines(x_axis.minor_gridlines)\n\n # Write the axis title elements.\n if x_axis.formula\n write_title_formula(x_axis, is_y_axis, @x_axis, x_axis.layout)\n elsif x_axis.name\n write_title_rich(x_axis, is_y_axis, x_axis.name_font, x_axis.layout)\n end\n\n # Write the c:numFmt element.\n write_cat_number_format(x_axis)\n\n # Write the c:majorTickMark element.\n write_major_tick_mark(x_axis.major_tick_mark)\n\n # Write the c:minorTickMark element.\n write_minor_tick_mark(x_axis.minor_tick_mark)\n\n # Write the c:tickLblPos element.\n write_tick_label_pos(x_axis.label_position)\n\n # Write the c:spPr element for the axis line.\n write_sp_pr(x_axis)\n\n # Write the axis font elements.\n write_axis_font(x_axis.num_font)\n\n # Write the c:crossAx element.\n write_cross_axis(axis_ids[1])\n\n write_crossing(y_axis.crossing) if @show_crosses || ptrue?(x_axis.visible)\n # Write the c:auto element.\n write_auto(1) unless x_axis.text_axis\n # Write the c:labelAlign element.\n write_label_align(x_axis.label_align)\n # Write the c:labelOffset element.\n write_label_offset(100)\n # Write the c:tickLblSkip element.\n write_tick_lbl_skip(x_axis.interval_unit)\n # Write the c:tickMarkSkip element.\n write_tick_mark_skip(x_axis.interval_tick)\n end\n end",
"def x_values\n raise ArgumentError.new(\"#{self.inspect} is not a 2D numeric array\") unless is_numeric_2d_array?\n self.collect { |item| item.first }\n end",
"def semi_major_axis\r\n self.parameters[:semi_major_axis]\r\n end",
"def all_axes\n @structure.all_axes\n end",
"def write_cat_axis(params) # :nodoc:\n x_axis = params[:x_axis]\n y_axis = params[:y_axis]\n axis_ids = params[:axis_ids]\n\n # if there are no axis_ids then we don't need to write this element\n return unless axis_ids\n return if axis_ids.empty?\n\n position = @cat_axis_position\n horiz = @horiz_cat_axis\n\n # Overwrite the default axis position with a user supplied value.\n position = x_axis[:_position] || position\n\n @writer.tag_elements('c:catAx') do\n write_axis_id(axis_ids[0])\n # Write the c:scaling element.\n write_scaling(x_axis[:_reverse])\n\n write_delete(1) unless ptrue?(x_axis[:_visible])\n\n # Write the c:axPos element.\n write_axis_pos(position, y_axis[:_reverse])\n\n # Write the c:majorGridlines element.\n write_major_gridlines(x_axis[:_major_gridlines])\n\n # Write the c:minorGridlines element.\n write_minor_gridlines(x_axis[:_minor_gridlines])\n\n # Write the axis title elements.\n if title = x_axis[:_formula]\n write_title_formula(title, @x_axis[:_data_id], horiz, @x_axis[:_name_font])\n elsif title = x_axis[:_name]\n write_title_rich(title, horiz, x_axis[:_name_font])\n end\n\n # Write the c:numFmt element.\n write_cat_number_format(x_axis)\n\n # Write the c:majorTickMark element.\n write_major_tick_mark(x_axis[:_major_tick_mark])\n\n # Write the c:tickLblPos element.\n write_tick_label_pos(x_axis[:_label_position])\n\n # Write the axis font elements.\n write_axis_font(x_axis[:_num_font])\n\n # Write the c:crossAx element.\n write_cross_axis(axis_ids[1])\n\n if @show_crosses || ptrue?(x_axis[:_visible])\n write_crossing(y_axis[:_crossing])\n end\n # Write the c:auto element.\n write_auto(1)\n # Write the c:labelAlign element.\n write_label_align('ctr')\n # Write the c:labelOffset element.\n write_label_offset(100)\n end\n end",
"def write_date_axis(params) # :nodoc:\n x_axis = params[:x_axis]\n y_axis = params[:y_axis]\n axis_ids = params[:axis_ids]\n\n return unless axis_ids && !axis_ids.empty?\n\n position = @cat_axis_position\n\n # Overwrite the default axis position with a user supplied value.\n position = x_axis.position || position\n\n @writer.tag_elements('c:dateAx') do\n write_axis_id(axis_ids[0])\n # Write the c:scaling element.\n write_scaling_with_param(x_axis)\n\n write_delete(1) unless ptrue?(x_axis.visible)\n\n # Write the c:axPos element.\n write_axis_pos(position, y_axis.reverse)\n\n # Write the c:majorGridlines element.\n write_major_gridlines(x_axis.major_gridlines)\n\n # Write the c:minorGridlines element.\n write_minor_gridlines(x_axis.minor_gridlines)\n\n # Write the axis title elements.\n if x_axis.formula\n write_title_formula(x_axis, nil, nil, x_axis.layout)\n elsif x_axis.name\n write_title_rich(x_axis, nil, x_axis.name_font, x_axis.layout)\n end\n # Write the c:numFmt element.\n write_number_format(x_axis)\n # Write the c:majorTickMark element.\n write_major_tick_mark(x_axis.major_tick_mark)\n\n # Write the c:tickLblPos element.\n write_tick_label_pos(x_axis.label_position)\n # Write the c:spPr element for the axis line.\n write_sp_pr(x_axis)\n # Write the font elements.\n write_axis_font(x_axis.num_font)\n # Write the c:crossAx element.\n write_cross_axis(axis_ids[1])\n\n write_crossing(y_axis.crossing) if @show_crosses || ptrue?(x_axis.visible)\n\n # Write the c:auto element.\n write_auto(1)\n # Write the c:labelOffset element.\n write_label_offset(100)\n # Write the c:tickLblSkip element.\n write_tick_lbl_skip(x_axis.interval_unit)\n # Write the c:tickMarkSkip element.\n write_tick_mark_skip(x_axis.interval_tick)\n # Write the c:majorUnit element.\n write_c_major_unit(x_axis.major_unit)\n # Write the c:majorTimeUnit element.\n write_c_major_time_unit(x_axis.major_unit_type) if x_axis.major_unit\n # Write the c:minorUnit element.\n write_c_minor_unit(x_axis.minor_unit)\n # Write the c:minorTimeUnit element.\n write_c_minor_time_unit(x_axis.minor_unit_type) if x_axis.minor_unit\n end\n end",
"def write_cat_val_axis(params) # :nodoc:\n x_axis = params[:x_axis]\n y_axis = params[:y_axis]\n axis_ids = params[:axis_ids]\n position = params[:position] || @val_axis_position\n horiz = @horiz_val_axis\n\n return unless axis_ids && !axis_ids.empty?\n\n # Overwrite the default axis position with a user supplied value.\n position = x_axis[:_position] || position\n\n @writer.tag_elements('c:valAx') do\n write_axis_id(axis_ids[0])\n\n # Write the c:scaling element.\n write_scaling_with_param(x_axis)\n\n write_delete(1) unless ptrue?(x_axis[:_visible])\n\n # Write the c:axPos element.\n write_axis_pos(position, y_axis[:_reverse])\n\n # Write the c:majorGridlines element.\n write_major_gridlines(x_axis[:_major_gridlines])\n\n # Write the c:minorGridlines element.\n write_minor_gridlines(x_axis[:_minor_gridlines])\n\n # Write the axis title elements.\n if title = x_axis[:_formula]\n write_title_formula(title, y_axis[:_data_id], horiz, x_axis[:_name_font])\n elsif title = x_axis[:_name]\n write_title_rich(title, horiz, x_axis[:_name_font])\n end\n\n # Write the c:numberFormat element.\n write_number_format(x_axis)\n\n # Write the c:majorTickMark element.\n write_major_tick_mark(x_axis[:_major_tick_mark])\n\n # Write the c:tickLblPos element.\n write_tick_label_pos(x_axis[:_label_position])\n\n # Write the axis font elements.\n write_axis_font(x_axis[:_num_font])\n\n # Write the c:crossAx element.\n write_cross_axis(axis_ids[1])\n\n write_crossing(y_axis[:_crossing])\n\n # Write the c:crossBetween element.\n write_cross_between\n\n # Write the c:majorUnit element.\n write_c_major_unit(x_axis[:_major_unit])\n\n # Write the c:minorunit element.\n write_c_minor_unit(x_axis[:_minor_unit])\n end\n end",
"def identity_x\r\n new_point = identity\r\n new_point.y = 0\r\n return new_point\r\n end",
"def mouse_x; mouseX; end",
"def mouse_x; mouseX; end",
"def centerx; return self[0]+(self[2].div(2)); end",
"def above_x_axis?\n (oval_baseline_y + @vertical_radius).abs > (oval_baseline_y + @vertical_radius - @oval_line_height).abs\n end",
"def write_date_axis(params) # :nodoc:\n x_axis = params[:x_axis]\n y_axis = params[:y_axis]\n axis_ids = params[:axis_ids]\n\n return unless axis_ids && !axis_ids.empty?\n\n position = @cat_axis_position\n\n # Overwrite the default axis position with a user supplied value.\n position = x_axis[:_position] || position\n\n @writer.tag_elements('c:dateAx') do\n write_axis_id(axis_ids[0])\n # Write the c:scaling element.\n write_scaling_with_param(x_axis)\n\n write_delete(1) unless ptrue?(x_axis[:_visible])\n\n # Write the c:axPos element.\n write_axis_pos(position, y_axis[:reverse])\n\n # Write the c:majorGridlines element.\n write_major_gridlines(x_axis[:_major_gridlines])\n\n # Write the c:minorGridlines element.\n write_minor_gridlines(x_axis[:_minor_gridlines])\n\n # Write the axis title elements.\n if title = x_axis[:_formula]\n write_title_formula(title, x_axis[:_data_id], nil, x_axis[:_name_font])\n elsif title = x_axis[:_name]\n write_title_rich(title, nil, x_axis[:_name_font])\n end\n # Write the c:numFmt element.\n write_number_format(x_axis)\n # Write the c:majorTickMark element.\n write_major_tick_mark(x_axis[:_major_tick_mark])\n\n # Write the c:tickLblPos element.\n write_tick_label_pos(x_axis[:_label_position])\n # Write the font elements.\n write_axis_font(x_axis[:_num_font])\n # Write the c:crossAx element.\n write_cross_axis(axis_ids[1])\n\n if @show_crosses || ptrue?(x_axis[:_visible])\n write_crossing(y_axis[:_crossing])\n end\n\n # Write the c:auto element.\n write_auto(1)\n # Write the c:labelOffset element.\n write_label_offset(100)\n # Write the c:majorUnit element.\n write_c_major_unit(x_axis[:_major_unit])\n # Write the c:majorTimeUnit element.\n if !x_axis[:_major_unit].nil?\n write_c_major_time_unit(x_axis[:_major_unit_type])\n end\n # Write the c:minorUnit element.\n write_c_minor_unit(x_axis[:_minor_unit])\n # Write the c:minorTimeUnit element.\n if !x_axis[:_minor_unit].nil?\n write_c_minor_time_unit(x_axis[:_minor_unit_type])\n end\n end\n end",
"def axes\n if @axes.nil? then\n # add the normal axes\n @axes = Axes.new(:cat_axis => CatAxis, :val_axis => ValAxis)\n\n # add the secondary axes if needed\n if @series.any? {|s| !s.on_primary_axis} then\n if @axes[:sec_cat_axis].nil? then\n @axes.add_axis(:sec_cat_axis, Axlsx::CatAxis)\n sec_cat_axis = @axes[:sec_cat_axis]\n sec_cat_axis.ax_pos = :b\n sec_cat_axis.delete = 1\n sec_cat_axis.gridlines = false\n end\n if @axes[:sec_val_axis].nil? then\n @axes.add_axis(:sec_val_axis, Axlsx::ValAxis)\n sec_val_axis = @axes[:sec_val_axis]\n sec_val_axis.ax_pos = :r\n sec_val_axis.gridlines = false\n sec_val_axis.crosses = :max\n end\n end\n end\n\n # return\n @axes\n end",
"def x\n attr('x')\n end",
"def cent_x\n self.x + (@width / 2)\n end",
"def angle_to_x(v)\n case v\n when :a then 0.0\n when :b then -(t.angle(:b) + t.angle(:c))\n when :c then Math::PI - t.angle(:c)\n end\n end",
"def extend_x_axis_output(index, domain)\n value = \"#{domain.get_coordinate_to_index(index).round(3)}\"\n (10 - value.length).times { print \" \" }\n print \"%#{value.length}s\" % \"#{value}\"\n end",
"def set_axis_range\n # a passed axis_range should look like:\n # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]]\n # in the second example, 4 is the interval \n set = @calculated_axis_range ? datasets : axis_range || datasets\n\n return unless set && set.respond_to?(:each) && set.find {|o| o}.respond_to?(:each)\n\n # in the case of a line graph, the first axis range should 1\n index_increase = type.to_s == 'line' ? 1 : 0\n 'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index|\n next nil if axis_range.nil? # ignore this axis\n min, max, step = axis_range\n if axis_range.size > 3 or step && max && step > max # this is a full series\n max = axis_range.last\n step = nil\n end\n [(index + index_increase), (min_value || min || 0), (max_value || max), step].compact.join(',')\n end.compact.join(\"|\")\n end",
"def x\n @x\n end",
"def write_val_axis(params) # :nodoc:\n x_axis = params[:x_axis]\n y_axis = params[:y_axis]\n axis_ids = params[:axis_ids]\n position = params[:position] || @val_axis_position\n horiz = @horiz_val_axis\n\n return unless axis_ids && !axis_ids.empty?\n\n # OVerwrite the default axis position with a user supplied value.\n position = y_axis[:_position] || position\n\n @writer.tag_elements('c:valAx') do\n write_axis_id(axis_ids[1])\n\n # Write the c:scaling element.\n write_scaling_with_param(y_axis)\n\n write_delete(1) unless ptrue?(y_axis[:_visible])\n\n # Write the c:axPos element.\n write_axis_pos(position, x_axis[:_reverse])\n\n # Write the c:majorGridlines element.\n write_major_gridlines(y_axis[:_major_gridlines])\n\n # Write the c:minorGridlines element.\n write_minor_gridlines(y_axis[:_minor_gridlines])\n\n # Write the axis title elements.\n if title = y_axis[:_formula]\n write_title_formula(title, y_axis[:_data_id], horiz, y_axis[:_name_font])\n elsif title = y_axis[:_name]\n write_title_rich(title, horiz, y_axis[:_name_font])\n end\n\n # Write the c:numberFormat element.\n write_number_format(y_axis)\n\n # Write the c:majorTickMark element.\n write_major_tick_mark(y_axis[:_major_tick_mark])\n\n # Write the tickLblPos element.\n write_tick_label_pos(y_axis[:_label_position])\n\n # Write the axis font elements.\n write_axis_font(y_axis[:_num_font])\n\n # Write the c:crossAx element.\n write_cross_axis(axis_ids[0])\n\n write_crossing(x_axis[:_crossing])\n\n # Write the c:crossBetween element.\n write_cross_between\n\n # Write the c:majorUnit element.\n write_c_major_unit(y_axis[:_major_unit])\n\n # Write the c:minorUnit element.\n write_c_minor_unit(y_axis[:_minor_unit])\n end\n end",
"def print_x_axis_markings(domain_x)\n (@max_y_indentation).times { print \" \"}\n index = 0\n print \"\\\\/\"\n while (index < domain_x.number_of_values / 5)\n 8.times { print \"-\"}\n print \"\\\\/\"\n index += 1\n end\n puts\n end",
"def x_axis_for(date)\n case @conditions[:breakdown_type]\n when \"Weekly\"\n \"Week of \" + date.to_s\n when \"Quarterly\"\n string = date.strftime(\"%Y-Q\")\n temp = date.strftime(\"%m\").to_i\n hash = {:t1 => [1,2,3], :t2 => [4,5,6], :t3 => [7,8,9], :t4 => [10,11,12]}\n hash.each{|k,v|\n string += k.to_s.sub(/t/, \"\") if v.include?(temp)\n }\n string\n when \"Daily\"\n date.to_s\n when \"Yearly\"\n date.year.to_s\n when \"Monthly\"\n date.strftime(\"%b %y\")\n when \"Day of week\"\n Date.strptime(date.to_s, \"%w\").strftime(\"%A\")\n when \"Hour\"\n DateTime.strptime(date.to_s, \"%H\").strftime(\"%I:00 %p\")\n else\n raise NoMethodError\n end\n end",
"def axis_index(index, coordinate_system)\n case coordinate_system\n when :row_col\n index\n when :col_row\n 9 + index\n when :box\n 18 + index\n end\n end",
"def mouse_x=(value); self.set_mouse_x(value); end",
"def x_center\r\n (@x1 + (@x2 - @x1) / 2).round\r\n end",
"def event_original_x(id)\n $game_map.rpg_event(id).x\n end",
"def center_x\n\t\t\t@x = @@screen.width/2-@width/2\n\t\tend",
"def chxl\n return nil unless show_axes?\n labels = []\n axis.values.each_with_index do |a,i|\n unless a.has_key?(:labels)\n raise SmartChartError, \"Your axis settings are missing :labels\"\n end\n if a[:labels][:positions] == :auto\n labels[i] = \"#{i}:|\" + auto_labels(a).values.join(\"|\")\n else\n a[:labels].each do |pos,text|\n labels[i] ||= \"#{i}:\"\n labels[i] << \"|\" + text.to_s\n end\n end\n end\n labels.join('|')\n end",
"def pmouseX()\n @view__.pmouseX\n end",
"def delta_x(x_position, x)\n (x - x_position).abs\n end",
"def vx()\n @view__.velocity.x\n end",
"def draw_x_labels\n stagger = x_label_font_size + 5\n if show_x_labels\n label_width = field_width\n\n count = 0\n for label in get_x_labels\n if step_include_first_x_label == true then\n step = count % step_x_labels\n else\n step = (count + 1) % step_x_labels\n end\n\n if step == 0 then\n text = @graph.add_element( \"text\" )\n text.attributes[\"class\"] = \"xAxisLabels\"\n text.text = label.to_s\n\n x = count * label_width + x_label_offset( label_width )\n y = @graph_height + x_label_font_size + 3\n t = 0 - (font_size / 2)\n\n if stagger_x_labels and count % 2 == 1\n y += stagger\n @graph.add_element( \"path\", {\n \"d\" => \"M#{x} #@graph_height v#{stagger}\",\n \"class\" => \"staggerGuideLine\"\n })\n end\n\n text.attributes[\"x\"] = x.to_s\n text.attributes[\"y\"] = y.to_s\n if rotate_x_labels\n text.attributes[\"transform\"] = \n \"rotate( 90 #{x} #{y-x_label_font_size} )\"+\n \" translate( 0 -#{x_label_font_size/4} )\"\n text.attributes[\"style\"] = \"text-anchor: start\"\n else\n text.attributes[\"style\"] = \"text-anchor: middle\"\n end\n end\n\n draw_x_guidelines( label_width, count ) if show_x_guidelines\n count += 1\n end\n end\n end"
] | [
"0.62835145",
"0.60586345",
"0.59716743",
"0.5947001",
"0.5842188",
"0.5832786",
"0.58136344",
"0.57748896",
"0.5742154",
"0.571066",
"0.5696833",
"0.5691088",
"0.56574905",
"0.56332403",
"0.5585058",
"0.5582857",
"0.5582857",
"0.55502814",
"0.5471296",
"0.5453739",
"0.5433043",
"0.53881884",
"0.5387509",
"0.5387034",
"0.5348055",
"0.5331745",
"0.53305304",
"0.52901834",
"0.5288031",
"0.5277656",
"0.5271698",
"0.52358806",
"0.52358806",
"0.52358806",
"0.52355605",
"0.5203545",
"0.51795447",
"0.5161342",
"0.51464844",
"0.51447827",
"0.513384",
"0.51178145",
"0.50894254",
"0.50894254",
"0.50828946",
"0.5042982",
"0.5020317",
"0.50157255",
"0.498569",
"0.49826658",
"0.4964177",
"0.4964177",
"0.4964177",
"0.49612114",
"0.49585307",
"0.49445188",
"0.49393636",
"0.49200138",
"0.49191943",
"0.49167344",
"0.49142045",
"0.4909375",
"0.48982567",
"0.4882288",
"0.48764873",
"0.48656687",
"0.48496762",
"0.4842666",
"0.48398176",
"0.48396984",
"0.4834017",
"0.48289523",
"0.48271635",
"0.48052165",
"0.47858697",
"0.4780669",
"0.4780669",
"0.47756842",
"0.4765772",
"0.47642016",
"0.47620124",
"0.4759723",
"0.4754695",
"0.47475034",
"0.47414201",
"0.47292823",
"0.47225416",
"0.46964902",
"0.46957958",
"0.46925744",
"0.46839046",
"0.46763703",
"0.46699405",
"0.46657848",
"0.46487874",
"0.46066117",
"0.4604956",
"0.45985982",
"0.45951518",
"0.4582328"
] | 0.6580192 | 0 |
The yaxis method is used to retrieve the Y axis of the coordinate system for the curve. Note that the length of the returned vector is equal to the radius of the underlying curve. | def yaxis
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_y_axis(params = {})\n @y_axis = convert_axis_args(@y_axis, params)\n end",
"def vector_y max_value = 1\n max_value * Math.sin(self.to_radians)\n end",
"def set_y2_axis(params = {})\n @y2_axis = convert_axis_args(@y2_axis, params)\n end",
"def test_yaxis_api_example\n v = nil\n assert_nothing_raised do\n centerpoint = Geom::Point3d.new\n # Create a circle perpendicular to the normal or Z axis\n vector = Geom::Vector3d.new 0,0,1\n vector2 = vector.normalize!\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_circle centerpoint, vector2, 10\n edge = edgearray[0]\n arccurve = edge.curve\n v = arccurve.yaxis\n end\n expected_yaxis = Geom::Vector3d.new 0,10,0\n assert_equal(expected_yaxis, v,\n 'Failed in test_yaxis' )\n end",
"def get_y_axis_labels\n 5\n end",
"def get_y coords\n coords.last\n end",
"def y\n r * Math.sin(theta)\n end",
"def getScaleY()\n return @device.getScaleY() ;\n end",
"def ydim\n @ydim || xdim\n end",
"def ydim\n @ydim || xdim\n end",
"def y_values\n raise ArgumentError.new(\"#{self.inspect} is not a 2D numeric array\") unless is_numeric_2d_array?\n self.collect { |item| item.last }\n end",
"def test_yaxis_returns_vector3d\n centerpoint = Geom::Point3d.new\n # Create a circle perpendicular to the normal or Z axis\n vector = Geom::Vector3d.new 0,0,1\n vector2 = vector.normalize!\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_circle centerpoint, vector2, 50\n edge = edgearray[0]\n arccurve = edge.curve\n\n result = arccurve.yaxis.class\n expected = Geom::Vector3d\n assert_equal(expected, result, 'Expected does not match result.')\n end",
"def y\n @point[1]\n end",
"def get_secondary_axes_series\n @series.select { |s| s.y2_axis }\n end",
"def y(value)\n fail YOutOfBounds if y_out_of_bounds?(value)\n\n attributes[:geometry][:y] = value\n end",
"def y\n attr('y')\n end",
"def y\n @components[:y]\n end",
"def ylabel(label)\n @methods[:y_axis_label] = label\n end",
"def getY() @y end",
"def get_secondary_axes_series\n @series.select {|s| s[:_y2_axis]}\n end",
"def point_y(index)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.GraphComponentState_point_y(@handle.ptr, index)\n result\n end",
"def y_end\n y_end_dependencies = [calculated_height, default_y?, !default_y? && y]\n if y_end_dependencies != @y_end_dependencies\n # avoid recalculation of dependencies\n calculated_height, is_default_y, y = @y_end_dependencies = y_end_dependencies\n shape_height = calculated_height.to_f\n shape_y = is_default_y ? 0 : y.to_f\n @y_end = shape_y + shape_height\n end\n @y_end\n end",
"def y\n position.y if position\n end",
"def y\n position.y if position\n end",
"def gety\n (@lines[0...@str_idx].map(&:ymax).reduce(:+) || 0) + @str_y_idx - @start_y\n end",
"def gety\n (@lines[0...@str_idx].map(&:ymax).reduce(:+) || 0) + @str_y_idx - @start_y\n end",
"def show_y_axis\n false\n end",
"def set_y_axis(params = {})\n @date_category = true if ptrue?(params[:date_axis])\n @y_axis.merge_with_hash(params)\n end",
"def determine_y_axis_init(domain, key)\n if (key % 5 == 0 || key == domain.number_of_values)\n return \"#{domain.get_coordinate_to_index(key).round(3)}\"\n else\n return String.new()\n end\n end",
"def actual_y_position\n return adjust_y_to_zoom(@actual_y + set_adjust[1])\n end",
"def delta_y\n @delta_y ||= (@name_segments.size - 1) * LINE_HEIGHT\n end",
"def y\n @position.y\n end",
"def set_y2_axis(params = {})\n @date_category = true if ptrue?(params[:date_axis])\n @y2_axis.merge_with_hash(params)\n end",
"def y\n object[\"y\"]\n end",
"def width_limiting_y\n return (oval_baseline_y + @vertical_radius + @oval_ascender) if above_x_axis?\n (oval_baseline_y + @vertical_radius - @oval_descender)\n end",
"def y\n @y ||= SpatialStats::Queries::Variables.query_field(@scope, @y_field)\n .standardize\n end",
"def conveyor_belt_y\n center_y + center_y / 2 + 20\n end",
"def y_position(as: :units)\n keys.first.y_position(as: as)\n end",
"def get_y\n grid_height = @window.current_map.height\n half_y = HEIGHT / 2 - GRID / 2\n @y = [[@player.y - half_y, 0].max, grid_height * GRID - HEIGHT].min\n end",
"def delta_y(y_position, y)\n (y - y_position).abs\n end",
"def get_y; \t\t@y \t\t\tend",
"def y2\n y + h\n end",
"def y\n return nil unless @grpc.position\n @grpc.position.y\n end",
"def y\n @data[:y]\n end",
"def y=(value)\n rect.y = value\n end",
"def pixel_y_at(y)\n\t\t(block_size * y) + @y_offset\n\tend",
"def referenced_y_axis_names\n selected_series.map {|s| s[:y_axis]}.compact\n end",
"def y\n rect.y\n end",
"def test_yaxis_length_matches_radius\n axis = nil\n radius = 5\n assert_nothing_raised do\n centerpoint = Geom::Point3d.new\n # Create a circle perpendicular to the normal or Z axis\n vector = Geom::Vector3d.new 0,0,1\n vector2 = vector.normalize!\n model = Sketchup.active_model\n entities = model.active_entities\n edgearray = entities.add_circle centerpoint, vector2, radius\n edge = edgearray[0]\n arccurve = edge.curve\n axis = arccurve.yaxis\n end\n assert_equal(radius, axis.length,\n 'Axis length does not match radius' )\n end",
"def draw_y_labels\n stagger = y_label_font_size + 5\n if show_y_labels\n label_height = field_height\n\n count = 0\n y_offset = @graph_height + y_label_offset( label_height )\n y_offset += font_size/1.2 unless rotate_y_labels\n for label in get_y_labels\n y = y_offset - (label_height * count)\n x = rotate_y_labels ? 0 : -3\n\n if stagger_y_labels and count % 2 == 1\n x -= stagger\n @graph.add_element( \"path\", {\n \"d\" => \"M#{x} #{y} h#{stagger}\",\n \"class\" => \"staggerGuideLine\"\n })\n end\n\n text = @graph.add_element( \"text\", {\n \"x\" => x.to_s,\n \"y\" => y.to_s,\n \"class\" => \"yAxisLabels\"\n })\n text.text = label.to_s\n if rotate_y_labels\n text.attributes[\"transform\"] = \"translate( -#{font_size} 0 ) \"+\n \"rotate( 90 #{x} #{y} ) \"\n text.attributes[\"style\"] = \"text-anchor: middle\"\n else\n text.attributes[\"y\"] = (y - (y_label_font_size/2)).to_s\n text.attributes[\"style\"] = \"text-anchor: end\"\n end\n draw_y_guidelines( label_height, count ) if show_y_guidelines\n count += 1\n end\n end\n end",
"def offy(y)\n -(y - self.centery) + (self.height/2)\n end",
"def y2\n y + height\n end",
"def at_y new_y\n PIXI::Point.new(self.x ,new_y)\n end",
"def scene_y(y)\n $window.height - ((y.to_f / $window.height) * @scene_height)\n end",
"def y\n @y\n end",
"def getY\n @y\n end",
"def y=(value)\n @background.y = value\n @bar.y = value + @by\n end",
"def y=(y)\n y = y.to_f\n fail RangeError, 'Y position not between 0 and 1' unless y.between?(0.0, 1.0)\n @y = y\n end",
"def sec_val_axis\n axes[:sec_val_axis]\n end",
"def y\n OFFSET_FROM_TOP + (coordinates.y * 700).to_i\n end",
"def horizontal_line y\n line = { x: 0, y: y, w: grid.width, h: 0 }\n line.transform_values { |v| v * grid.cell_size }\n end",
"def horizontal_line y\n line = { x: 0, y: y, w: grid.width, h: 0 }\n line.transform_values { |v| v * grid.cell_size }\n end",
"def y=(new_y)\n @y = new_y.to_f if new_y\n end",
"def cent_y\n @spr_y + (@spr_h / 2)\n end",
"def rel_y\n return y - Graphics.height/2\n end",
"def rel_y\n return y - Graphics.height/2\n end",
"def rel_y\n return y - Graphics.height/2\n end",
"def y\n return @background.y\n end",
"def screen_y\n unless Layy_Meta.active\n return screen_y_mgc_lm_gtbs\n else\n y = @actor.lm_y_h0\n y -= 40\n if @actor.unit_size > 1\n y += (@actor.unit_size - 1 << 4)\n end\n return y\n end\n end",
"def y_axis_label(val = nil, padding = 12)\n return @properties[\"yAxisLabel\"] if !val\n @properties[\"yAxisLabel\"] = \"\\\"#{val}\\\"\"\n return self\n end",
"def adjust_y(y)\n if loop_vertical? and y < @display_y - @margin_y\n return y - @display_y + @map.height * 256\n else\n return y - @display_y\n end\n end",
"def axis\n axes = Sketchup.active_model.axes\n\n axes.axes.find do |axis|\n position.on_line?([axes.origin, axis])\n end\n end",
"def y=(new_y)\n @y = new_y\n @abs_y = nil\n end",
"def center_y\n return CENTER_Y\n end",
"def axes\n return @axes\n end",
"def setY(y)\n @y = y\n end",
"def y_center\r\n (@y1 + (@y2 - @y1) / 2).round\r\n end",
"def semi_minor_axis\r\n self.parameters[:semi_minor_axis]\r\n end",
"def paddle_y\n @cr[9]\n end",
"def center_y\n (Graphics.height / 32 - 1) / 2.0\n end",
"def center_y\n (Graphics.height / 32 - 1) / 2.0\n end",
"def center_y\n (Graphics.height / 32 - 1) / 2.0\n end",
"def center_y\n (Graphics.height / 32 - 1) / 2.0\n end",
"def screen_y\n tsbs_cam_screen_y - $tsbs_camera.adjust_y(self)\n end",
"def screen_y\n tsbs_cam_screen_y - $tsbs_camera.adjust_y(self)\n end",
"def print_y_line_beginning(domain, key)\n max_length = determine_maximal_domainvalue_length(domain) + 1\n\n output = determine_y_axis_init(domain, key)\n (max_length - output.length).times { output.concat(\" \") }\n @max_y_indentation = output.length if (@max_y_indentation < output.length)\n print output\n end",
"def solve_for_y(x)\n field.square_roots equation_right_hand_side x\n end",
"def orgY(y)\n return @device.orgY(y) ;\n end",
"def y2=(y2)\n self.y = y2 - height\n end",
"def mouse_y\n end",
"def screen_y(y)\n $window.height - ((y.to_f / @scene_height) * $window.height).to_i\n end",
"def y\n @location.y\n end",
"def generate_random_y(x)\n max_y = Math.sqrt(@radius**2 - x**2)\n random_range(-max_y, max_y)\n end",
"def axes\n end",
"def adjust_y(obj)\n dist = Graphics.height/2 - obj.y\n return (@y * @zoom) + (dist * (@zoom - 1.0))\n end",
"def dpi_y\n self.class.dpm_to_dpi(dpm_y)\n end",
"def semi_minor_axis_computed\r\n self.parameters[:semi_minor_axis_computed]\r\n end",
"def shifted_horizontal_line y\n line = { x: grid.width + 1, y: y, w: grid.width, h: 0 }\n line.transform_values { |v| v * grid.cell_size }\n end",
"def y_with_direction(y, direction)\n return round_y(y + (direction == 2 ? 1 : direction == 8 ? -1 : 0))\n end",
"def y_offset; end"
] | [
"0.6863317",
"0.67769736",
"0.65913993",
"0.64641255",
"0.646231",
"0.61885643",
"0.61414677",
"0.60565275",
"0.5988228",
"0.5988228",
"0.5984578",
"0.59601915",
"0.59322524",
"0.59203273",
"0.59192294",
"0.59120923",
"0.59009117",
"0.58864105",
"0.5878128",
"0.58259577",
"0.58186984",
"0.5818151",
"0.58022106",
"0.58022106",
"0.57708466",
"0.57708466",
"0.5769766",
"0.5746991",
"0.57385206",
"0.5713634",
"0.56999534",
"0.5695297",
"0.5683728",
"0.5680009",
"0.5662762",
"0.56202084",
"0.55835354",
"0.556055",
"0.5559626",
"0.5538287",
"0.5517897",
"0.55006456",
"0.5492521",
"0.5487388",
"0.5464382",
"0.5458091",
"0.545014",
"0.54484767",
"0.5444143",
"0.5435069",
"0.54155177",
"0.5393984",
"0.5376493",
"0.53688633",
"0.53638256",
"0.53628814",
"0.5355835",
"0.53476185",
"0.53438693",
"0.53425515",
"0.53339815",
"0.53339815",
"0.53266793",
"0.53106725",
"0.53043485",
"0.53043485",
"0.53043485",
"0.5279232",
"0.5276835",
"0.5275909",
"0.5262879",
"0.5252341",
"0.52180815",
"0.5198061",
"0.51929307",
"0.5185733",
"0.5183369",
"0.51794565",
"0.5171791",
"0.514595",
"0.514595",
"0.514595",
"0.514595",
"0.5127404",
"0.5127404",
"0.5094284",
"0.50863934",
"0.5086055",
"0.50763047",
"0.50761163",
"0.50700325",
"0.50407684",
"0.5034775",
"0.5001324",
"0.49795213",
"0.49737617",
"0.49716893",
"0.49538547",
"0.49532616",
"0.49516678"
] | 0.7082605 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_address
@address = Address.find_by(id: params[:id], user_profile_id: current_user.user_profile_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 |
helper for authorization_rules clarity | def is_news?
category.sysname == 'news'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorization; end",
"def authorize \n self.make 'authorization' \n end",
"def authorize_access\r\n # authorize!(action_name.to_sym, \"#{controller_name}_controller\".camelcase.constantize)\r\n end",
"def authorization(*args, &block); end",
"def authorize\n end",
"def authorize\n end",
"def access_control\n \n end",
"def authorization_mode; end",
"def authorize_users\n authorize :user\n end",
"def authorize_resource(*args); end",
"def authorization_required\n case action_name.to_s\n when /index/, /show/ then list_authorized?\n when /create/ then create_authorized?\n when /update/ then update_authorized?\n when /destroy/ then delete_authorized?\n end\n false\n end",
"def authorization_checking\n authorize!(:authorization_checking,current_user) unless current_user.role?(:livia_admin) || current_user.role?(:lawfirm_admin)\n end",
"def authorize?(_user)\n true\n end",
"def authorize?(_user)\n true\n end",
"def host_authorization; end",
"def host_authorization; end",
"def authorize?(user)\n true\n end",
"def authorization\n authorization = 'participant'\n authorization = 'reader' if !can_submit && can_review && can_take_quiz\n authorization = 'submitter' if can_submit && !can_review && !can_take_quiz\n authorization = 'reviewer' if !can_submit && can_review && !can_take_quiz\n authorization\n end",
"def authorize_admin_profiles\n authorize convention, :view_attendees?\n end",
"def authorize?(user)\n user && user.admin?\n end",
"def authorization(action, object = \"default - missing something?\")\n if action == \"create\"\n not_authorised and return unless current_user.can_create?\n elsif action == \"update\"\n not_authorised and return unless current_user.can_update?(object)\n elsif action == \"destroy\"\n not_authorised and return unless current_user.can_destroy?(object)\n elsif action == \"owner\"\n not_authorised and return unless current_user.owner?(object)\n elsif action == \"admin\"\n not_authorised and return unless current_user.admin_only\n end\n end",
"def pre_authorize_cb; end",
"def authorize?(user)\n true\n #user.login == \"administrador\"\n end",
"def authorize_admin\n redirect_to :login unless current_user.permission.manage_app ||\n current_user.permission.manage_attrs ||\n current_user.permission.manage_achievement_categories ||\n current_user.permission.manage_talent_trees ||\n current_user.permission.manage_talents ||\n current_user.permission.manage_quests ||\n current_user.permission.manage_skills ||\n current_user.permission.manage_achievements ||\n current_user.permission.manage_items ||\n current_user.permission.manage_titles\n end",
"def authorized?\n true\n end",
"def authorize_admin\n\t\tauthorize( ADMIN_USER_LEVEL ) \n\tend",
"def authorize_link usr = nil, thing = nil, typ = nil\n what_we_know = case thing.class.name\n when 'Store'\n {:target_id => thing.id, :target_type => 'Store'}\n when 'Location', 'String', 'Fixnum'\n {:target_id => (thing.is_a?(Location) ? thing.id : thing), :target_type => 'Location'}\n else\n {}\n end\n what_we_know.merge!(:user_id => usr.id) if usr\n what_we_know.merge!(:authorization_type => typ) if typ\n if usr && thing && typ\n if Authorization.find_by_authorization_type_and_target_id_and_target_type_and_user_id(typ, what_we_know[:target_id], what_we_know[:target_type], usr.id)\n \"#{usr.login} can #{Authorization.type_hash[typ]} at #{what_we_know[:target_type].constantize.send(:find, what_we_know[:target_id]).name}\"\n else\n '<span id=\"' + \"user_#{usr.id}_#{what_we_know[:target_type].downcase}_#{what_we_know[:target_id]}_#{typ}\" + '\">' + link_to_remote(\"authorize #{usr.login}#{' (' + usr.name + ') ' unless usr.name.blank?} to #{Authorization.type_hash[typ]} at {what_we_know[:target_type].constantize.send(:find, what_we_know[:target_id]).name}\",\n :url => authorizations_path(:authorization => what_we_know), :update => \"user_#{usr.id}_#{what_we_know[:target_type].downcase}_#{what_we_know[:target_id]}_#{typ}\") + '</span>'\n end\n else\n link_to \"authorize#{' ' + usr.login if usr}#{' (' + usr.name + ')' unless !usr || usr.name.blank?}#{' to ' + Authorization.type_hash[typ] if typ}#{' at ' + what_we_know[:target_type].constantize.send(:find, what_we_know[:target_id]).name if thing}\", new_authorization_path(:authorization => what_we_know)\n end\n end",
"def login_required\nauthorized? || access_denied\nend",
"def pundit_authorize\n authorize [:admin, @testimonial||:testimonial]\n end",
"def authorized?\nlogged_in?\nend",
"def verify_admin\n :authenticate_user!\n have_no_rights('restricted area') unless current_user.isAdmin?\nend",
"def authorize?(person)\n person.is_admin?\n end",
"def pre_authorize_cb=(_arg0); end",
"def authorized?(user)\n true\n end",
"def user_action_on_resource_authorized\n end",
"def authorized?(resource)\n return false unless self.active\n # return true if role_authorized?('superuser') \n #OPTIMIZE: DO WE WANT THIS? It causes you to have access to all departments in all controllers, no matter what your permissions are.\n \n # return permission_strings.include?(resource) #reduced performance\n return permission_strings_cached.include?(resource) #causes caching bug\n end",
"def needs_authorization?\n true\n end",
"def access_rule(name)\n if name.is_a?(Hash)\n authenticator name.first[0]\n access_rule name.first[1]\n else\n @controller.access_rule = name\n end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\nif current_user.admin?\n\t can [:create, :show, :add_user, :remove_user, :index], Role\n\t end\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n\n\n end",
"def authorize_user\n # simple authorization: kick out anonymous users from backend actions\n=begin\n if !current_user\n redirect_back_or_default(home_page) and return if action_name =~ /index|edit|update|destroy/\n \n # skip checking permission if user is an admin\n elsif !current_user.has_role?('Admin')\n unless current_user.has_permission?(controller_name, action_name, params)\n flash[:warning] = 'Access Denied'\n redirect_back_or_default(home_page) and return\n end\n end\n=end\n end",
"def authorize_admin!\n authorize! :manage, :all\n end",
"def is_authorized s, rdf_type, allowed_groups\n @authorizations ||= {}\n if @authorizations.has_key? [s, rdf_type, allowed_groups]\n @authorizations[s, rdf_type, allowed_groups]\n else\n\n authorized_query \"ASK WHERE { <#{s}> a <#{rdf_type}> }\", allowed_groups\n end\nend",
"def authorize(required_role)\n self.send required_role.to_sym\n end",
"def authorization_mode=(mode); end",
"def check_auth\n authorize @equipment_listing\n end",
"def check_authorization\r\n params[:table] ||= params[:t] || CmsHelper.form_param(params)\r\n # Only show menu\r\n return login if params[:id].in?(%w(login logout test))\r\n\r\n table = params[:table].to_s.strip.downcase\r\n set_default_guest_user_role if session[:user_roles].nil?\r\n # request shouldn't pass\r\n if table != 'dc_memory' and \r\n (table.size < 3 or !dc_user_can(DcPermission::CAN_VIEW))\r\n return render(action: 'error', locals: { error: t('drgcms.not_authorized')} )\r\n end\r\n dc_form_read\r\n\r\n # Permissions can be also defined on form\r\n #TODO So far only can_view is used. Think about if using other permissions has sense\r\n can_view = @form.dig('permissions','can_view')\r\n if can_view.nil? or dc_user_has_role(can_view)\r\n extend_with_control_module\r\n else\r\n render(action: 'error', locals: { error: t('drgcms.not_authorized')} )\r\n end \r\nend",
"def authorized?(controller, action=\"index\")\n\n return true if self.admin?\n\n query = <<-EOS\nSELECT DISTINCT #{UserEngine.config(:permission_table)}.* \nFROM #{UserEngine.config(:permission_table)}, #{UserEngine.config(:role_table)}, \n #{UserEngine.config(:permission_role_table)}, #{UserEngine.config(:user_role_table)},\n #{LoginEngine.config(:user_table)}\nWHERE #{LoginEngine.config(:user_table)}.id = :person\nAND #{LoginEngine.config(:user_table)}.id = #{UserEngine.config(:user_role_table)}.user_id\nAND #{UserEngine.config(:user_role_table)}.role_id = #{UserEngine.config(:role_table)}.id\nAND #{UserEngine.config(:role_table)}.id = #{UserEngine.config(:permission_role_table)}.role_id\nAND #{UserEngine.config(:permission_role_table)}.permission_id = #{UserEngine.config(:permission_table)}.id\nAND #{UserEngine.config(:permission_table)}.controller = :controller\nAND #{UserEngine.config(:permission_table)}.action = :action\nEOS\n\n result = Permission.find_by_sql([query, {:person => self.id, \n :controller => controller.to_s, :action => action.to_s}]) \n\n return (result != nil) && (!result.empty?) \n end",
"def authorized?\n %w(new create plans canceled thanks).include?(self.action_name) || \n ((self.action_name == 'dashboard') && current_user) ||\n admin?\n end",
"def authorized?\n %w(new create plans canceled thanks).include?(self.action_name) || \n ((self.action_name == 'dashboard') && current_user) ||\n admin?\n end",
"def authorize(ctrl = params[:controller], action = params[:action])\n company = current_company\n company_groups = company.groups\n current_groups = company_groups & current_user.groups\n if company.nil?\n allowed = false\n elsif current_user.groups.nil?\n allowed = false\n elsif current_groups\n allowed = current_user.allowed_to?(current_user, {:controller => ctrl, :action => action}, company)\n else\n allowed = false\n end\n\n allowed ? true : deny_access\n end",
"def skip_authorization; end",
"def authorizer\n current_ability\n end",
"def authorization\r\n@env['HTTP_AUTHORIZATION'] ||\r\n@env['X-HTTP_AUTHORIZATION'] ||\r\n@env['X_HTTP_AUTHORIZATION'] ||\r\n@env['REDIRECT_X_HTTP_AUTHORIZATION']\r\nend",
"def action_allowed?\n case params[:action]\n when 'show', 'set_priority', 'index'\n ['Instructor',\n 'Teaching Assistant',\n 'Administrator',\n 'Super-Administrator',\n 'Student'].include?(current_role_name) &&\n ((%w[list].include? action_name) ? are_needed_authorizations_present?(params[:id], 'participant', 'reader', 'submitter', 'reviewer') : true)\n else\n ['Instructor',\n 'Teaching Assistant',\n 'Administrator',\n 'Super-Administrator'].include? current_role_name\n end\n end",
"def authorize_controller!\n authorize! action_name.to_sym, full_controller_name\n end",
"def show\n authorize @account\n # if authorize @account != true\n\n # end\n end",
"def test_authorize\n object_person = people(:valid_person) # person_id 1\n subject_person_1aa = people(:person1) # person_id 1aa\n subject_person_2aa = people(:person3) # person_id 2aa\n \n assert Rule.authorize?(subject_person_1aa, object_person.id, \"view\", \"email\")\n assert !Rule.authorize?(subject_person_2aa, object_person.id, \"view\",\"email\")\n\n end",
"def profile_authorization\n #if view admins' profile, allow only admin\n return false unless(params[:id])\n user = User.find(params[:id])\n return false unless user\n return admin_authorization if user.admin?\n return true if GraderConfiguration[\"right.user_view_submission\"]\n\n #finally, we allow only admin\n admin_authorization\n end",
"def authorize(verb); send_or_default(\"authorize_#{verb}\",true) ; end",
"def test_authorize_according_to_one_rule\n rule_or = rules(:active_or_rule) # friends or members of group tkk can view name of person 1\n rule_and = rules(:active_and_rule) # friends who are members of group tkk can view email of person 1\n\n action_view_name = actions(:view_name)\n action_view_email = actions(:view_email)\n object_person = people(:valid_person) # person id 1\n subject_person_test = people(:test) # not friend, not member of group tkk\n subject_person_4 = people(:friend) # person 4 is a friend, but not a member of group tkk\n subject_person_1aa = people(:person1) # person 1aa is a friend, and also a member of group tkk\n\n assert subject_person_1aa.contacts.include? object_person\n assert subject_person_1aa.is_member_of? groups(:tkk)\n\n assert !rule_or.authorize_according_to_one_rule(subject_person_test, object_person.id, action_view_name.action_type, action_view_name.action_value)\n assert !rule_and.authorize_according_to_one_rule(subject_person_test, object_person.id, action_view_email.action_type, action_view_email.action_value)\n assert rule_or.authorize_according_to_one_rule(subject_person_4, object_person.id, action_view_name.action_type, action_view_name.action_value)\n assert !rule_and.authorize_according_to_one_rule(subject_person_4, object_person.id, action_view_email.action_type, action_view_email.action_value)\n assert rule_or.authorize_according_to_one_rule(subject_person_1aa, object_person.id, action_view_name.action_type, action_view_name.action_value)\n assert rule_and.authorize_according_to_one_rule(subject_person_1aa, object_person.id, action_view_email.action_type, action_view_email.action_value)\n end",
"def authorize?(user)\n user && user.moderator?\n end",
"def authorize_admin\n redirect_to '/librarians/denied' unless current_user && current_user.admin?\n end",
"def authorize\r\n # check if action is allowed on public projects\r\n if @project.is_public? and Permission.allowed_to_public \"%s/%s\" % [ @params[:controller], @params[:action] ]\r\n return true\r\n end \r\n # if action is not public, force login\r\n return unless require_login \r\n # admin is always authorized\r\n return true if self.logged_in_user.admin?\r\n # if not admin, check membership permission \r\n @user_membership ||= Member.find(:first, :conditions => [\"user_id=? and project_id=?\", self.logged_in_user.id, @project.id]) \r\n if @user_membership and Permission.allowed_to_role( \"%s/%s\" % [ @params[:controller], @params[:action] ], @user_membership.role_id ) \r\n return true\t\t\r\n end\t\t\r\n render :nothing => true, :status => 403\r\n false\r\n end",
"def show \n #if current_user.company_id == @user.company_id \n authorize @user \n end",
"def has_access(atts)\n atts[:controller] = atts[:controller] ? atts[:controller] : params[:controller]\n atts[:action] = atts[:action] ? atts[:action] : params[:action]\n atts[:user] = atts[:user] && atts[:user].is_a?(User) ? atts[:user] : current_user\n atts[:entity_id] = params[:id] ? params[:id] : nil\n\n logger.debug \"atts[:controller]: \" + atts[:controller]\n logger.debug \"atts[:action]: \" + atts[:action]\n logger.debug \"atts[:user]: \" + (atts[:user] ? atts[:user].username : \"\")\n logger.debug \"atts[:entity_id]: \" + (atts[:entity_id] ? atts[:entity_id].to_s : \"\")\n\n case atts[:controller]\n when \"comments\"\n @res = comments_filter(atts[:action], {\n :user => atts[:user],\n :comment_id => atts[:entity_id]\n })\n when \"users\"\n @res = users_filter(atts[:action], {\n :user => atts[:user],\n :entity_id => atts[:entity_id]\n })\n when \"players\"\n @res = players_filter(atts[:action], {\n :user => atts[:user],\n :player_id => atts[:entity_id]\n })\n when \"leagues\"\n @res = leagues_filter(atts[:action], {\n :user => atts[:user],\n :league_id => atts[:entity_id]\n })\n when \"teams\"\n @res = teams_filter(atts[:action], {\n :user => atts[:user],\n :team_id => atts[:entity_id]\n })\n when \"games\"\n @res = games_filter(atts[:action], {\n :user => atts[:user],\n :game_id => atts[:entity_id]\n })\n when \"halls\"\n @res = halls_filter(atts[:action], {\n :user => atts[:user],\n :hall_id => atts[:entity_id]\n })\n when \"images\"\n @res = images_filter(atts[:action], {\n :user => atts[:user],\n :image_id => atts[:entity_id]\n })\n when \"plugins\"\n @res = plugins_filter(atts[:action], {\n :user => atts[:user],\n })\n when \"wikis\"\n @res = wikis_filter(atts[:action], {\n :user => atts[:user],\n })\n when \"events\"\n @res = events_filter(atts[:action], {\n :user => atts[:user],\n })\n else\n @res = true\n end\n\n # kdyz nemam prava, nemam pristup\n if !@res\n access_denied\n end\n end",
"def index\n # @users = User.all\n # authorize @users \n @users = policy_scope(User)\n authorize @users\n end",
"def authorize_author\n redirect_to '/login' unless self.user_access > 1 || current_user.access == 3\n end",
"def get_acl_definition\n return @_aclize_acl\n end",
"def valid_for_params_auth?; end",
"def show\n # authorize Admin\n end",
"def permissions_policy(&block); end",
"def show\n authorize RoleCutoff\n end",
"def check_permissions\n authorize! :create, RoutingSheet\n end",
"def admin_authorize\n unless admin?\n unauthorized_access\n end\n end",
"def filter_access!\n treat_as get_current_role\n end",
"def show\n authorize User\n end",
"def show\n authorize User\n end",
"def custom_permissions\n\n campus = \"bakersfield\" if current_user.email.include?(\"bakersfield.edu\")\n campus = \"chancellor\" if current_user.email.include?(\"calstate.edu\")\n campus = \"channel\" if current_user.email.include?(\"ci.edu\")\n campus = \"chico\" if current_user.email.include?(\"chico.edu\")\n campus = \"dominguez\" if current_user.email.include?(\"dh.edu\")\n campus = \"eastbay\" if current_user.email.include?(\"eb.edu\")\n campus = \"fresno\" if current_user.email.include?(\"fresno.edu\")\n campus = \"fullerton\" if current_user.email.include?(\"fullerton.edu\")\n campus = \"humboldt\" if current_user.email.include?(\"humboldt.edu\")\n campus = \"longbeach\" if current_user.email.include?(\"lb.edu\")\n campus = \"losangeles\" if current_user.email.include?(\"la.edu\")\n campus = \"maritime\" if current_user.email.include?(\"maritime.edu\")\n campus = \"mlml\" if current_user.email.include?(\"mlml.edu\")\n campus = \"northridge\" if current_user.email.include?(\"northridge.edu\")\n campus = \"pomona\" if current_user.email.include?(\"bronco.edu\")\n campus = \"sacramento\" if current_user.email.include?(\"sacramento.edu\")\n campus = \"sanfrancisco\" if current_user.email.include?(\"sf.edu\")\n campus = \"sanmarcos\" if current_user.email.include?(\"sanmarcos.edu\")\n campus = \"sonoma\" if current_user.email.include?(\"sonoma.edu\")\n campus = \"stanislaus\" if current_user.email.include?(\"stanislaus.edu\")\n\n user_groups.push(campus)\n\n # admin\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n# if current_user.contentadmin?\n# can [:create, :destroy], GwWork\n# can [:create, :destroy], GwEtd\n# end\n end",
"def authorize\n if !current_user.has_role? :admin\n render text:\"No Access For You!!!\"\n end\n end",
"def authorization_object\n nil\n end",
"def authorization_object\n nil\n end",
"def permissions = {}",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def host_authorization=(_arg0); end",
"def host_authorization=(_arg0); end",
"def http_authorize \n redirect_to login_path, alert: 'Authorization required' if !logged_in? \n end",
"def only_authorize_admin!\n authorize!(is?(:admin))\n end",
"def eval_cancan_action(accion)\n case accion.to_s\n when \"index\"\n nombre = 'list'\n cancan_action = \"index\" #let the cancan action be the actual method name\n action_desc = I18n.t :list\n when \"new\", \"create\"\n nombre = 'create and update'\n cancan_action = \"create\"\n action_desc = I18n.t :create\n when \"show\"\n nombre = 'view'\n cancan_action = \"view\"\n action_desc = I18n.t :view\n when \"edit\", \"update\"\n nombre = 'create and update'\n cancan_action = \"update\"\n action_desc = I18n.t :update\n when \"delete\", \"destroy\"\n nombre = 'delete'\n cancan_action = \"destroy\"\n action_desc = I18n.t :destroy\n else\n #Convencion de nombre de metodos publicos del sistema\n # wf = Web Function\n if accion =~ /^wf_/i\n nombre = accion.to_s\n cancan_action = accion.to_s\n action_desc = \"Other: \" < cancan_action\n end\n end\n return nombre, cancan_action\nend",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def auth_methods; end",
"def authorized? (location, details)\n # The user is obviously not authorized if they're trying to access a location that doesn't exist\n if (valid_locations.include? location)\n # Admins have global access\n if session[:admin]\n return true\n else\n case location\n # There is no 'admin_cp' check because logged-in admins received authorization before the case statement began\n \n # Authorization check for viewing a user's control panel/profile edit\n when 'user_cp'\n # If the user is logged in as the appropriate user\n if logged_in? && userid(username) == details[:user_id]\n return true\n end\n \n # Authorization check for viewing a game \n when 'view_game'\n # Gets us the game in question\n case system = details[:system]\n when 'fate'\n game = FateGame.find(details[:game_id]) \n end\n # Everyone is authorized to view public games\n if game.is_public\n return true\n # If the game is not public, we have to check if they're allowed. If they aren't logged in, they aren't allowed\n elsif logged_in?\n # If the logged-in user is found in the list of GMs or Players for the game\n auth_viewers = game.player_ids.concat(game.gms)\n if auth_viewers.include? userid(username)\n return true\n end\n end\n \n # Authorization check for editing a game \n when 'edit_game'\n # No one who isn't logged in can edit a game\n if (logged_in?)\n # Gets us the game in question\n case system = details[:system]\n when 'fate'\n game = FateGame.find(details[:game_id]) \n end\n # Only GMs and Admins can edit a game\n if game.gms.include? userid(username)\n return true\n end\n end\n \n # Authorization check for making a character for a given game \n when 'make_char'\n case system = details[:system]\n when 'fate'\n game = FateGame.find(details[:game_id])\n end\n if game.requires_approval\n auth_character_makers = game.gms + game.player_ids\n return auth_character_makers.include?(userid(username))\n else\n return true\n end\n \n # Authorization check for viewing a character (NOT called for viewing hidden fields like secret_notes)\n when 'view_char'\n # Gets us the character and game in question\n case system = details[:system]\n when 'fate'\n char = FateCharacter.find(details[:char_id])\n game = FateGame.find(char.game_id) \n end\n # Everyone can view a publicly-viewable character\n if char.is_public\n return true\n # If you're not logged in you can't view a hidden character\n elsif logged_in?\n # Authorized viewers are game GMs and the owner of the character\n auth_viewers = game.gms << char.player_id\n return auth_viewers.include?(userid(username))\n end\n \n # Authorization check for editing a character (also called for viewing hidden fields like secret_notes) \n when 'edit_char'\n # No permission if you're not logged in\n if logged_in?\n # Gets us the character and game in question\n case system = details[:system]\n when 'fate'\n char = FateCharacter.find(details[:char_id])\n game = FateGame.find(char.game_id) \n end\n # Authorized editors are GMs and the relevant player\n auth_editors = game.gms << char.player_id\n return auth_editors.include?(userid(username))\n end \n end\n end \n end\n return false\n end",
"def access_control(object = nil)\n if object.present? && @cur_user.present?\n author = author?\n end\n perm = Permission\n perm.getReq(params[:controller], params[:action], request.request_method)\n redirect t('redirect.denied') unless perm.grant?(user_perm, author)\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n\n if user_groups.include? ['all_project_writers']\n can [:create], PulStore::Base\n can [:create], PulStore::Lae::Box\n can [:create], PulStore::Lae::Folder\n can [:create], Pulstore::Lae::HardDrive\n end\n\n if user_groups.include? ['lae_project_writers']\n can [:create], PulStore::Lae::Box\n can [:create], PulStore::Lae::Folder\n can [:create], Pulstore::Lae::HardDrive\n end \n\n if user_groups.include? ['all_project_writers']\n can [:destroy], PulStore::Base\n end\n\n if user_groups.include? ['lae_project_readers', 'all_project_readers' ]\n can [:show], PulStore::Base\n end\n end"
] | [
"0.73058826",
"0.69267124",
"0.6898613",
"0.68878627",
"0.68675417",
"0.68675417",
"0.6804562",
"0.6719275",
"0.6694463",
"0.6649856",
"0.66285",
"0.65633136",
"0.6540686",
"0.6540686",
"0.647341",
"0.647341",
"0.643564",
"0.6389",
"0.6342609",
"0.62998927",
"0.6275286",
"0.624469",
"0.6240146",
"0.622697",
"0.6206872",
"0.61895484",
"0.617964",
"0.6159024",
"0.6157472",
"0.613604",
"0.6121853",
"0.61191136",
"0.61175925",
"0.6110006",
"0.6092031",
"0.6091915",
"0.6084014",
"0.6075299",
"0.606833",
"0.6061248",
"0.6041907",
"0.60413617",
"0.60337913",
"0.6017002",
"0.60031617",
"0.5986442",
"0.5982632",
"0.5973363",
"0.5973363",
"0.5971793",
"0.5951084",
"0.5946126",
"0.593197",
"0.59296685",
"0.59277356",
"0.5927668",
"0.5927363",
"0.5926152",
"0.591888",
"0.5906268",
"0.58989525",
"0.5892235",
"0.58887494",
"0.5870825",
"0.5865212",
"0.5862772",
"0.58561033",
"0.5852775",
"0.5847717",
"0.5841731",
"0.583872",
"0.5834219",
"0.5827847",
"0.5827785",
"0.582537",
"0.5818971",
"0.5818971",
"0.5815998",
"0.5814518",
"0.58022624",
"0.57974386",
"0.57974386",
"0.57970786",
"0.578923",
"0.578923",
"0.578923",
"0.578923",
"0.578923",
"0.578923",
"0.578923",
"0.578923",
"0.57866496",
"0.57866496",
"0.5781545",
"0.57797927",
"0.5779538",
"0.5779173",
"0.5774855",
"0.57727456",
"0.5770355",
"0.5762547"
] | 0.0 | -1 |
4 5 1 3 7 1 2 My final solution | def two_d_sum(arr)
i = 0
sum=0
while i < arr.length
arr[i].each do |num|
sum += num
end
i += 1
end
return sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 solutions(a)\r\n\r\n ary = a.sort\r\n ary.each_with_index do |num, index|\r\n if ary[index+1] != num + 1 && index != ary.length-1\r\n return num + 1\r\n end\r\n end\r\n\r\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 solution(number)\r\n (3...number).each_with_object([]) { |n, arr| arr << n if (n % 3).zero? || (n % 5).zero? }.uniq.sum\r\nend",
"def given\n [6,5,3,1,8,7,2,3]\nend",
"def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend",
"def solution\n (2..(9**5 * 6)).select do |n|\n n.to_s.split(//).map do |d|\n d.to_i ** 5\n end.reduce(:+) == n\n end.reduce(:+)\nend",
"def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend",
"def solution(a)\n # write your code in Ruby 2.2\n binding.pry\n trips = Hash.new {|h,k| h[k]=0}\n start = 0\n ending = 0\n min = nil\n a.each_with_index do |trip,i|\n ending = i\n\n if trips[trip] == 0\n min = ending - start\n end\n trips[trip] += 1\n\n while start < ending\n break if trips[a[start]] - 1 == 0\n trips[start] -= 1\n start += 1\n min = ending - start if ending-start < min\n end\n end\n min\nend",
"def solution(a)\n stack = []\n\n a.each_with_index do |n, i|\n if stack.empty?\n stack << [i, n]\n next\n end\n\n last_value = stack.last[1]\n\n if n == last_value\n stack << [i, n]\n else\n stack.pop\n end\n end\n\n return -1 if stack.empty?\n\n i, cd = stack.last\n\n count = a.inject(0) do |acc, n|\n cd == n ? acc + 1 : acc\n end\n\n count > a.length / 2 ? i : -1\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend",
"def solution(size=5)\n ([1] + (3..size).select(&:odd?).map do |x|\n 4*x**2 - 6*x + 6\n end).reduce(:+)\nend",
"def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend",
"def solution(a)\r\n a.each do |num|\r\n if (a.count(num) % 2) != 0\r\n return num\r\n end\r\n end\r\nend",
"def solution(int)\n multiples_3 = []\n multiples_5 = []\n threes = 3\n fives = 5\n \n until threes >= int\n multiples_3 << threes\n threes += 3\n end\n until fives >= int\n multiples_5 << fives\n fives += 5\n end\n \n (multiples_3 | multiples_5).sum\nend",
"def solution(a)\n numbers = a.sort\n (0..numbers.length-3).each do |index|\n triplet = numbers[index..index + 2]\n max_value = triplet.max\n sum = triplet.min(2).inject(&:+)\n\n return 1 if sum > max_value\n end\n\n 0\nend",
"def solution(a)\n left = 0\n right = a.sum\n a.each_with_index do |element, index|\n right -= element\n return index if left == right\n left += element\n end\n -1\nend",
"def collapse(nums)\n (0...nums.length - 1).each do |i|\n if nums[i] + 1 == nums[i + 1] || nums[i] == nums[i + 1] + 1\n return nums[0...i] + nums[i + 2..-1]\n end\n end\n\n nums\nend",
"def solution(n)\n n.to_s.split(//).inject(1) { |a,d| a + d.to_i }\nend",
"def solution(n)\n siblings = n.to_s.chars.each_slice(1).to_a\n siblings.sort {|x,y| -(x <=> y)}.join.to_i\nend",
"def collapse(nums)\n (0...nums.length - 1).each do |i|\n if nums[i] + 1 == nums[i + 1] || nums[i] == nums[i + 1] + 1\n return nums[0...i] + nums[i + 2..-1]\n end\n end\n\n nums\nend",
"def solution(a)\n if a.count >= 3\n distances = []\n last = nil\n (1...a.count - 1).each { |i|\n if a[i] > a[i - 1] and a[i] > a[i + 1]\n distances << i - last if last\n last = i\n end\n }\n puts distances.inspect\n \n (distances.count + 1).downto(1) { |flags|\n return flags if distances.all? { |d| d >= flags }\n }\n end\n 0\nend",
"def solution(number)\n (1..number-1).select{|x| x%3==0 || x%5 ==0 }.reduce(:+)\nend",
"def minimumBribes(q)\n sum = 0\n q.each_with_index do |v,i|\n if v-(1+i) > 2\n puts \"Too chaotic\"\n return\n end\n bound = [v-2,0].max\n (bound..i-1).each do |j|\n sum+=1 if q[j] > v\n end\n end\n puts sum\nend",
"def solution(a)\n stones = 0\n stack = []\n a.each do |height|\n stack.pop while stack.any? && stack.last > height\n next if stack.any? && stack.last == height\n stack << height\n stones += 1\n end\n stones\nend",
"def solution(a)\n return 0 if a.length < 3\n a.sort.each_cons(3) { |e| return 1 if e[0] + e[1] > e[2] }\n return 0\nend",
"def solution\n (1..40).inject(:*) / (1..20).inject(:*)**2\nend",
"def solution(h)\n h.inject([1, [h.first]]) do |(blocks, stack), n|\n next [blocks+1, stack.push(n)] if stack.last < n\n stack.pop while stack.any? && stack.last > n\n next [blocks, stack] if stack.last == n\n \n [blocks+1, stack.push(n)]\n end.first\nend",
"def problem1(num)\n (1..num-1).select{|a| a%3 ==0 or a%5==0}.reduce(:+)\nend",
"def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend",
"def solution(number)\nn = 0..number\na = []\nfor i in n\n if i % 3 == 0 || i % 5 == 0\n a = a.push(i)\n end\n end\ns = 0\n# a.pop\na.each {|x| s += x}\ns\nend",
"def solve(nums)\n arr = nums.map {|num| num * num}\n arr.each_with_index do |el1, idx1|\n arr.each_with_index do |el2, idx2|\n if idx2 > idx1\n if arr.include?(el1 + el2)\n if (arr.index(el1 + el2) != idx1) && (arr.index(el1 + el2) != idx2)\n return true\n end\n end\n end\n end\n end\n false\nend",
"def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend",
"def solution(a)\n \n max = 0\n # write your code in Ruby 2.2\n max if a.nil? || a.length == 0\n \n if a.length < 4\n max = 1\n a.each do |item|\n max = max * item\n end\n max\n end\n \n # order first => nlogn + left and right edge max three\n a.sort!\n \n # - - -\n # + + +\n if a[0] >= 0 || a[-1] <= 0 || a[1] >= 0\n max = a[-1] * a[-2] * a[-3]\n max\n end\n \n # n = 4\n max = a[0] * a[1] * a[2]\n max = [max,a[0] * a[1] * a[-1]].max\n max = [max,a[0] * a[-2] * a[-1]].max\n max = [max,a[-3] * a[-2] * a[-1]].max\n max\n end",
"def solution(x, a)\n count = 1\n indices = []\n while count <= x\n indices << a.find_index(count)\n count += 1\n end\n\n if indices.include?(nil)\n -1\n else\n indices.sort.last\n end\nend",
"def four_sum(arr, target)\n arr = arr.sort\n size = arr.size\n res = []\n (0...size).each do |i|\n (i + 1...size).each do |j|\n left = j + 1\n right = size - 1\n while left < right\n sum = arr[i] + arr[j] + arr[left] + arr[right]\n res << [arr[i], arr[j], arr[left], arr[right]] if sum == target\n if sum > target\n right -= 1\n else\n left += 1\n end\n end\n end\n end\n res\nend",
"def solution(number)\n(0...number).map{|x| x % 3 == 0 || x % 5 == 0 ? x : 0}.inject{|sum, x| sum + x}\nend",
"def solution(num)\n (1..num-1).select {|x| x % 3 == 0 || x % 5 == 0 }.inject(:+)\n # inject method is like reduce \n # can take in a range or array of numbers and optionally receive a block\n # passes each element and accumulates each sequentially\nend",
"def solve(nums, target)\n nums.each_with_index do |e, i|\n nums.each_with_index do |e_, i_|\n return [i, i_] if ((e + e_ == target) && (i != i_))\n end\n end\nend",
"def solution(number)\n return (0...number).select{ |x| ((x % 3 == 0) || (x % 5 == 0))}.reduce(:+)\nend",
"def solution(number)\n ans = 0\n (3...number).step(3) {|n| ans += n}\n (5...number).step(5) {|n| n % 3 == 0 ? next : ans += n}\n return ans\nend",
"def solution a\n a.sort!\n until a.empty?\n answer = a.pop\n return answer if a.pop != answer\n end\nend",
"def solution(number)\n sum = 0\n Array(1..number-1).each do |i|\n if i % 3 == 0 || i % 5 == 0\n sum += i\n end\n end\n sum\nend",
"def solution(s, p, q)\r\n # write your code in Ruby 2.2\r\n # A -1\r\n # C -2\r\n # G -3\r\n # T -4\r\n # s - string with n charactekrs\r\n #cagccta\r\n #0123345\r\n #p,q - not empty arrays\r\n #\r\n #p[0]=2 q[0]=4 gcc 322 => 2\r\n #p[1]=5 q[1]=5 t 4 => 4\r\n \r\n \r\n arr = Array.new(q.count)\r\n \r\n \r\n\r\n \r\n arr.each_with_index{|el, i|\r\n \r\n ss = s[p[i]..q[i]]\r\n \r\n if ss.index('A') \r\n n = 1\r\n elsif ss.index('C')\r\n n=2\r\n elsif ss.index('G')\r\n n=3\r\n else \r\n n=4\r\n end\r\n \r\n arr[i] = n\r\n \r\n }\r\n \r\n \r\n \r\n arr\r\n \r\nend",
"def solution(number)\n [*1...number].select {|n| (n % 3 == 0) or (n % 5 == 0)}.sum\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 solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend",
"def solution(digits)\n result = 0\n digits.size.times do |n|\n new_number = digits[n...(n + 5)].to_i\n result = new_number if new_number > result\n end\n result\nend",
"def equil_idcs(a)\n left = 0\n sum = a.inject(:+)\n equils = []\n a.each_with_index do |num, idx|\n sum -= num\n equils << idx if left == sum\n left += num\n end\n equils.empty? ? -1 : equils\nend",
"def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend",
"def pickingNumbers(a)\n my_h = Hash.new(0)\n a.each do |elem|\n my_h[elem] = a.select {|x| (elem-x).abs < 2}\n end\n my_h.max_by {|i,v| v.size}[1].size - 1\nend",
"def solve\n return ((1..40).inject(:*) / ((1..20).inject(:*) ** 2))\nend",
"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 three_sum(nums)\n nums.sort!\n res = []\n # for each num, find the two constituent targets\n for i in 0..nums.length - 3 do\n next if i > 0 && nums[i] == nums[i - 1]\n\n partial_target = 0 - nums[i]\n j = i + 1\n k = nums.length - 1\n while j < k\n if nums[j] + nums[k] == partial_target\n res.push([nums[i], nums[j], nums[k]])\n j+=1 while j < k && nums[j] == nums[j+1]\n k-=1 while j < k && nums[k] == nums[k-1]\n j+=1\n k-=1\n elsif nums[j] + nums[k] > partial_target\n k-=1 while j < k && nums[k] == nums[k-1]\n k-=1\n else\n j+=1 while j < k && nums[j] == nums[j+1]\n j+=1\n end\n end\n end\n return res\nend",
"def solution2(a)\n\n counts = Hash.new(0)\n\n a.each do |int|\n counts[int] += 1\n end\n\n non_divisors = []\n\n a.each do |int|\n div_count = 0\n for i in 1..int do\n div_count += counts[i] if int % i == 0\n end\n non_divisors << a.length - div_count\n end\n\n non_divisors\n\nend",
"def correct(element)\n result = nil\n element.downto(0).each do |j|\n i = element - j\n if j == element && j % 3 == 0\n result = Array.new(j, 5)\n elsif i % 5 == 0 && j % 3 == 0\n result = Array.new(j, 5) + Array.new(i, 3)\n elsif i == element && i % 5 == 0\n result = Array.new(i, 3)\n end\n\n break if result\n end\n\n if result.nil?\n puts -1\n else\n puts result.join()\n end\nend",
"def single_number(nums)\n 2 * nums.uniq.reduce(:+) - nums.reduce(:+)\nend",
"def solution_one\n x = 0\n (1..999).each do |i|\n if (i % 5) == 0 || (i % 3) == 0\n x = x + i\n end\n end\n x\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 solution(a)\n return 0 if a.length < 3\n a.sort!\n\n for i in 0..(a.length - 3)\n return 1 if a[i] + a[i + 1] > a[i + 2]\n end\n return 0\nend",
"def icecreamParlor(m, arr)\n # Complete this function\n res = []\n arr.each_index do |i|\n if i + 1 !=nil\n j = i + 1\n while j <= arr.length - 1\n if arr[i]+arr[j] == m\n res.push([i+1,j+1])\n end\n j+=1\n end\n end\n end\n res\nend",
"def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end",
"def solution(number)\n number -=1 and sum = 0 and for x in number.downto(0) do x%5 == 0 ? (sum = sum+x) : if(x%3 == 0) then sum = sum+x \n end end and return sum \nend",
"def solution(a)\n # write your code in Ruby 2.2\n a.sort!\n min =1\n a.each{|x|\n if (x==min)\n min = min+1\n end\n }\n return min\nend",
"def solution(a)\n\traise ArgumentError.new(\"a has to be non empty array of max size #{MAX_LEN}\") if !a.is_a? Array or a.empty? or a.length > MAX_LEN\n\tret = 0\n\t#puts a.inspect\n\tmy_h = Hash.new\n\ta.each do |e|\n\t\tif my_h.include? e\n\t\t\tmy_h[e] += 1\n\t\telse\n\t\t\tmy_h[e] = 1\n\t\tend\n\tend\n\n\tmy_h_sort = my_h.sort_by {|k, v| -v}\n\t# -> my_h_sort[value][occurances]\n\treturn 0 if my_h_sort.first[1] < a.size/2\n\tleader_val = my_h_sort.first[0]\n\n\tocc_array = Array.new\n\toccurances = 0\n\ta.each do |e|\n\t\toccurances += 1 if e == leader_val\n\t\tocc_array.push(occurances)\n\tend\n\t#puts occ_array.inspect\n\n\tfor idx in (0...a.length-1) do\n\t\tsum1 = occ_array[idx]\n\t\tsum2 = occ_array.last - occ_array[idx]\n\n\t\t# puts \"#{idx}+1 < #{sum1*2}\"\n\t\t# puts \"#{(a.length - idx -1)} < #{(sum2*2 )} \"\n\n\t\tif (idx+1) < sum1 * 2 && (a.length - idx - 1 ) < sum2 * 2\n\t\t\t## we have a leader\n\t\t\t#puts \"YEAH #{idx}\"\n\t\t\tret += 1\n\t\tend\n\t\t\t#puts \"-------- ret: #{ret}\"\n\tend\n\treturn ret\nend",
"def problem1 limit\n (0...limit).map {|n| (n%3==0 || n%5==0) ? n : 0 }.reduce(:+)\nend",
"def solution4(a)\n left = 0\n right = a.size - 1\n distinct = 0\n\n while left <= right\n # puts \"left: #{left}, right: #{right}\"\n # puts \"a[l]: #{a[left]}, a[r]: #{a[right]}\"\n # puts \"distinct: #{distinct}\"\n if a[left].abs > a[right].abs\n begin\n left += 1\n end until a[left] != a[left - 1]\n elsif a[left].abs < a[right].abs\n begin\n right -= 1\n end until a[right] != a[right + 1]\n else\n begin\n left += 1\n end until a[left] != a[left - 1]\n begin\n right -= 1\n end until a[right] != a[right + 1] \n end\n\n distinct += 1\n end\n distinct\nend",
"def minimumBribes(q)\r\n moves = 0\r\n r = (0..q.size-1).to_a\r\n\r\n until q == (1..q.size).to_a do\r\n q.map { |a| a - 1 }\r\n .reverse_each.with_index do |person, i|\r\n i = q.size - i - 1\r\n if person - i > 2\r\n puts \"Too chaotic\"\r\n return\r\n end\r\n\r\n if person > r[i] && person > q[person] -1\r\n moves += person - r[i]\r\n q = q - [person + 1]\r\n q.insert(person, person + 1)\r\n end\r\n end\r\n end\r\n\r\n puts moves\r\nend",
"def solve (input)\n output = 0\n mult_five = 5\n curr_val = 3\n\n while curr_val < input\n if curr_val > mult_five\n output += mult_five\n mult_five += 5\n elsif curr_val == mult_five\n mult_five += 5\n end\n\n output += curr_val\n curr_val += 3\n end\n\n return output\nend",
"def three_sum(nums)\n return [] if !nums || nums.size < 3\n ans = []\n i = 0 \n size = nums.size\n nums = nums.sort\n while i < size do \n if nums[i] == nums[i - 1] && i > 0 \n i += 1\n next\n end\n\n a = nums[i]\n target = -1 * a\n two_sum(nums[(i + 1)...size], target, a, ans)\n i += 1\n end\n ans\nend",
"def solution(n)\n sum = 0\n (1...n).each do |elem|\n sum += elem if elem % 3 == 0 or elem % 5 == 0\n end\n sum\nend",
"def solveProblem lst\n big = -1\n numbers = {}\n half = lst.length / 2\n lst.each do |i|\n if numbers.has_key?(i) then\n numbers[i] += 1\n else\n numbers[i] = 1\n end\n if numbers[i] > half then return i end\n end\n return big\nend",
"def two_sum(nums, target)\n\tnum_len = nums.length\n\tdic = {}\n\ti = 0 \n while i < num_len\t\n \tnumber = nums[i]\n \tif number == target / 2 && dic[number]\n \t\treturn [dic[number],i]\n \tend\n \tdic[number] = i\n \tmaybe = dic[target-number]\n \tif maybe && maybe != i\n \t\treturn [maybe,i]\n \t\tbreak\n \tend\n i += 1\n end\nend",
"def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend",
"def 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 solution(a)\n (0..a.size - 2).map { |i| ( a[0..i].inject(:+) - a[i+1..a.size].inject(:+) ).abs }.min\nend",
"def solution(number)\n # put your solution here\n my_range = (1...number).to_a\n result_arr = my_range.select {|i| i % 3 == 0 || i % 5 == 0}\n\n return result_arr.reduce(:+)\nend",
"def problem2(num)\n f = [1,2]\n f.push(f[-2..-1].reduce(:+)) until f[-1] >= num\n f.select{|n| n.even?}.reduce(:+)\nend",
"def solution(n, a)\n # write your code in Ruby 2.2\n arr = [0] * n\n max_c = 0\n \n a.each_with_index do |value,index|\n if value == n + 1\n arr = [max_c] * n\n else\n arr[value - 1] = arr[value - 1] + 1\n max_c = (arr[value -1] > max_c ? arr[value -1] : max_c)\n end\n end\n arr\nend",
"def solution(a)\n min_val = 10_000\n min_pos = 0\n \n sums = [0]\n for i in (0..a.count - 1) \n sums << sums.last + a[i] \n end\n for p in (0..a.count - 2)\n for q in (p + 1..[p + 2, a.count - 1].min)\n s = (sums[q + 1] - sums[p]).to_f / (q - p + 1)\n if s < min_val\n min_val = s\n min_pos = p\n end\n end\n end\n min_pos\nend",
"def solution(a)\n ((1..a.size + 1).to_a - a).first\nend",
"def solution(a, b)\n a.size > b.size ? b+a+b : a+b+a\nend",
"def solution(array)\n result = Array.new(array.length, 0)\n\n array.each do |element|\n if result[element - 1]\n result[element - 1] += 1\n else\n result[element - 1] = 1\n end\n end\n\n result.uniq.size == 1 ? 1 : 0\nend",
"def solution(n, a)\n counters = Array.new(n, 0)\n max = 0\n a.each do |item|\n if item >= 1 && item <= n\n counters[item - 1] += 1\n max = counters[item - 1] if counters[item - 1] > max\n elsif item == n + 1\n counters = Array.new(n, max)\n end\n end\n\n counters\nend",
"def solution(a)\n # [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 solution(k, m, a)\n from = a.max\n to = a.inject(:+)\n min = from\n while from <= to\n mid = (from + to) / 2\n if check(mid, k, m, a)\n min = mid\n to = mid - 1\n else\n from = mid + 1\n end\n end\n min\nend",
"def ClosestEnemy(arr)\n str = arr.join\n result = []\n result += str.scan(/1.*?2/)\n result += str.reverse.scan(/1.*?2/).map(&:reverse)\n return 0 if result.empty?\n result.min_by { |el| el.size }.size - 1\nend",
"def solution(digits)\n digits.chars.each_cons(5).max_by(&:itself).join.to_i\nend",
"def solve(n, s, d, m)\n # Complete this function\n records = s;\n\n (1...n).each do |i|\n records[i] += records[i-1]\n end\n\n numberOfWays = (m <= n && records[m - 1] == d) ? 1 : 0;\n\n (m...n).each do |i|\n if records[i] - records[i - m] == d\n numberOfWays += 1\n end\n end\n\n numberOfWays\n\nend",
"def solution(n)\n x = (n**0.5).floor\n (1..x).reduce(0) { |s, i| n % i == 0 ? s += (i * i == n ? 1 : 2) : s }\nend",
"def solution3(a)\n freq = {}\n a.each do |num|\n num = num.abs\n freq[num] ? next : freq[num] = 1\n end\n freq.size\nend",
"def solution(a)\n n = a.size\n starting = Array.new(n, 0)\n ending = Array.new(n, 0)\n\n (1..n - 2).each {|i| starting[i] = [starting[i - 1] + a[i], 0].max}\n (1..n - 2).reverse_each {|i| ending[i] = [ending[i + 1] + a[i], 0].max}\n\n sum = 0\n (1..n - 2).each {|i| sum = [sum, starting[i - 1] + ending[i + 1]].max}\n sum\nend",
"def solution(a)\n return a.group_by{|n| n}.each_value{|v| return v.first if v.count.odd?}\nend",
"def minimumBribes(q)\n bribes = 0\n q.reverse.each_with_index do |n, i|\n if q[i] - (i + 1) > 2\n bribes = \"Too chaotic\"\n break\n end\n j = [0, q[i] - 2].max\n while j < i\n if q[j] > q[i]\n bribes += 1\n end\n j += 1\n end\n end\n puts bribes\nend",
"def two_sum_brute nums\n (0...nums.length).each do |i|\n ((i + 1)...nums.length).each do |j|\n if nums[i] + nums[j] == 0\n return i, j\n end\n end\n end\n nil\nend",
"def problem3 n\n 2.step(n,1).each do |x|\n return x-1 if n == 1\n n /= x if x.prime? && (n % x == 0)\n end\nend",
"def single_number(nums)\n (3 * nums.uniq.sum - nums.sum) / 2\nend",
"def Threesum(arr)\n target = arr.first\n arr.combination(3).to_a.any? {|comb| comb.reduce(0 , :+) == target}\nend",
"def sum_of_halfway_matches(nums)\n rotated = nums.rotate(nums.length / 2)\n matches = nums.zip(rotated)\n matches.reduce(0) do |total, pair|\n if pair.first == pair.last\n total + pair.first.to_i\n else\n total\n end\n end\nend",
"def solution(x, a)\n perm = (1..x).to_a\n return -1 unless (perm - a).empty?\n a.index(a.uniq.last)\nend",
"def four_sum(nums, target); end"
] | [
"0.692498",
"0.69127625",
"0.6904588",
"0.6846181",
"0.68335927",
"0.6831962",
"0.6790998",
"0.67720103",
"0.6753366",
"0.67121804",
"0.67085856",
"0.66864455",
"0.66341823",
"0.66310537",
"0.6619364",
"0.6617434",
"0.66060287",
"0.6588998",
"0.65856344",
"0.65853643",
"0.65804416",
"0.6575691",
"0.65663093",
"0.65613323",
"0.65372837",
"0.6535434",
"0.65226793",
"0.65223736",
"0.6521184",
"0.650662",
"0.65041745",
"0.6497624",
"0.64902216",
"0.64846903",
"0.6476034",
"0.6475994",
"0.6472838",
"0.6470954",
"0.6459109",
"0.6455719",
"0.6446343",
"0.6446031",
"0.6444566",
"0.6434221",
"0.64226204",
"0.6416683",
"0.6416005",
"0.6410194",
"0.64051956",
"0.6401902",
"0.6401806",
"0.63938403",
"0.63886297",
"0.6385414",
"0.63784343",
"0.6375883",
"0.6367064",
"0.63645744",
"0.6350937",
"0.63482165",
"0.63419515",
"0.63396925",
"0.6338069",
"0.63332886",
"0.63289225",
"0.6317387",
"0.6315678",
"0.6314377",
"0.63017",
"0.6299479",
"0.62976223",
"0.62955105",
"0.6293165",
"0.6292881",
"0.62881154",
"0.6285866",
"0.62782824",
"0.62712777",
"0.62689316",
"0.6264766",
"0.62584805",
"0.62533903",
"0.62506366",
"0.6247733",
"0.62436986",
"0.62386847",
"0.6237882",
"0.62345654",
"0.62320954",
"0.62240374",
"0.62206113",
"0.6216295",
"0.62114155",
"0.6210243",
"0.62084216",
"0.6208309",
"0.6208015",
"0.62047285",
"0.6202856",
"0.61992407",
"0.61972517"
] | 0.0 | -1 |
=> 1 Teacher's solution | def two_d_sum(arr)
total = 0
arr.each do |sub_array|
sub_array.each do |num|
total += num
end
end
return total
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution4(input)\n end",
"def faculty(i)\n result = 1\n i.times do |index|\n result *= (index + 1)\n end\n result\n end",
"def solve\n solution_candidate(intersections.next_people_with_similar_tastes)\n end",
"def acmTeam(topic)\n num_of_attendees = topic.count\n\n permutations = (0..(num_of_attendees - 1)).to_a.permutation(2).to_a\n unique_permutations = permutations.map do |array|\n array.sort\n end.uniq\n\n result = unique_permutations.map do |person1, person2|\n (topic[person1].to_i(2) | topic[person2].to_i(2)).to_s(2).scan('1').count\n end\n\n [max = result.max, result.count(max)]\nend",
"def solution\n return self.answers.select {|x| x.correct}[0] if solved?\n nil\n end",
"def teacher\n self.teachers.first\n end",
"def difficulty\n 1-correct.to_f/(correct+incorrect)\n end",
"def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend",
"def matching_fitness(self_survey, user_survey)\n fitness = 0\n if self_survey.sociality == user_survey.sociality then fitness += 1 end\n if self_survey.familiarity == user_survey.familiarity then fitness += 1 end\n if self_survey.awaken == user_survey.awaken then fitness += 1 end\n if self_survey.smoke == user_survey.smoke then fitness += 1 end\n if self_survey.game == user_survey.game then fitness += 1 end\n if self_survey.waketime == user_survey.waketime then fitness += 1 end\n return fitness\n end",
"def calc_fitness\n self.join.to_i(2)\n end",
"def teacher\n self.course_person.first(:type => \"teacher\").person\n end",
"def recursive_solution\n\n end",
"def solved(ans)\n\n end",
"def last_possible_exam_semester\n study_length * 2 - 2\n end",
"def student_to_teacher_ratio\n ratio = @students.length / @teachers.length\n ratio # return the ratio\n end",
"def subject(instructor, school)\n school[:instructors].each do |i|\n return i[:subject] if i[:name] == instructor\n end\nend",
"def proof_of_work(last_proof)\n proof = 0\n while valid_proof(last_proof, proof) == false\n proof += 1\n end\n\n proof\n end",
"def student_to_teacher_ratio\n numStudents = @students.length\n numTeachers = @teachers.length\n\n return (numStudents / numTeachers)\n end",
"def solution\n 971 * (-61)\nend",
"def score\n # an answer has a reference to a score. we simply can return\n # the score of that choice (which is defined by the teacher)\n choice.score\n end",
"def goals_for()\n\t self.as_regular_contestants.select{|c| c.score}.collect{|c| c.score}.inject{|gf, c| gf + c} || 0\n\tend",
"def primordial; end",
"def power_of_attorney\n claimants.first.power_of_attorney if claimants.first\n end",
"def last_done_exercise_of_greater_difficulty\n i = self.user_sequence.size() - 1\n while(!self.user_sequence[i][2]) do\n i = i - 1\n end\n return self.user_sequence[i][0]\n end",
"def teacher_number\n return @teacher_number\n end",
"def fitness\n 0 - length_penalty - spelling_penalty\n end",
"def solution() \n case @answer.type\n when String\n solution= @answer.downcase \n default \n solution= @answer\n end\n solution\n end",
"def challenge; end",
"def check_teacher_prize_eligibility\n completed_students = 0\n completed_female_students = 0\n total_students = self.students.length\n if total_students >= STUDENTS_COMPLETED_FOR_PRIZE\n self.students.each do |student|\n if student.prize_earned && student.valid_prize_teacher.try(:id) == self.id\n completed_students += 1\n if student.gender == \"f\"\n completed_female_students += 1\n end\n end\n end\n end\n\n teacher_prize = completed_students >= STUDENTS_COMPLETED_FOR_PRIZE\n teacher_bonus_prize = teacher_prize && (completed_female_students >= STUDENTS_FEMALE_FOR_BONUS)\n return teacher_prize, teacher_bonus_prize\n end",
"def last_student_by_method\n # Write a solution that returns the first student using the built in .last method\n STUDENT_NAMES.last\n # Write a solution that returns the first student in the array student_names\nend",
"def teach\n puts\"Votre animal apprend quelque chose \\n\"\n @mental += 10\n return 2\n end",
"def power_of_attorney\n claimants.first&.power_of_attorney\n end",
"def power_of_attorney\n claimants.first&.power_of_attorney\n end",
"def teachers\n @all_teachers = User.all_teachers\n @current_teachers = User.current_teachers(get_selected_project)\n @number_of_teachers_per_section = User.get_number_of_teachers_per_section(get_array_of_all_sections(get_selected_project), get_selected_project) \n end",
"def junior?\n grade <=6\n end",
"def my_solution\n res = \"\"\n choices.each do |k, v|\n res << \" * #{k}\\n\" if v\n end\n return \"(no correct answer)\" if res.blank?\n res\n end",
"def determinant\n end",
"def resolve_coeficient(student)\n case student.evaluation.to_i\n when 1\n return 1.5\n when 2\n return 1.39\n when 3\n return 1.33\n when 4\n return 0.72\n when 5\n return 0.44\n else\n return 1\n end\nend",
"def assignment_by_teacher(student_user)\n self.line_break\n puts \"Please select a teacher by typing out their full name below:\".colorize(:light_blue)\n self.all_teachers(student_user)\n self.line_break\n student_input = gets.chomp.titleize\n self.line_break\n if Teacher.find_by(name: student_input)\n puts \"Here are your assignments for Professor #{student_input}:\".colorize(:magenta)\n s = Student.find_by(name: student_user)\n t = Teacher.find_by(name: student_input)\n list = s.assignments.select do |assignment|\n assignment.teacher_id == t.id\n end\n list.each do |assignment|\n puts assignment.task\n end\n self.student_main_menu(student_user)\n else \n puts \"Invalid response!\".colorize(:yellow)\n self.assignment_by_teacher(student_user)\n end\n end",
"def proof_of_work(last_proof)\n proof = 0\n proof += 1 until self.valid_proof?(last_proof, proof)\n proof\n end",
"def solve\n end",
"def masterwork_prob_bonus; 0; end",
"def find_instructor_solution(prob,instr_dir)\n # returns [found,file,figs_dir]\n found = false\n found_file = nil\n topics = [\"intro\",\"mechanics\",\"waves\",\"em-dc\",\"em-fields\",\"em-general\",\"optics\",\"relativity\",\"quantum\"]\n topics.each { |subdir|\n found_file = \"#{instr_dir}/#{subdir}/#{prob}.tex\"\n if File.exist?(found_file) then return[true,found_file,\"#{instr_dir}/#{subdir}/figs\"] end\n }\n return [false,nil,nil]\nend",
"def course_difficulty(num)\n case num\n when 0\n 'Easy'\n when 1\n 'Intermediate'\n else\n 'Advanced'\n end\n end",
"def solve line\n letters = ('A'..'Z').map { |e| e }\n return prob_1(line, letters)\nend",
"def last_possible_defense_semester\n study_length * 2\n end",
"def youngest_person\n # ???\nend",
"def determine_education(candidate)\n\tputs \"Does a formal education matter significantly for this position(y/n)? \"\n\teducation = gets.chomp\n\tif education == \"n\"\n\t\teducation = 15 + candidate.convert_to_val(\"formal_training\")*2\n\telsif education == \"y\"\n\t\teducation = candidate.convert_to_val(\"formal_training\")*5\n\telse\n\t\tprob_found\n\t\tdetermine_education(candidate)\n\tend\t\t\nend",
"def alg; end",
"def assignment_solution(ass_id)\n self.final_completed_assignments.select{ |a| a.assignment_id == ass_id }.first\n end",
"def fitness_question2(fitness_answer2)\n if fitness_answer2 == \"I work really hard and sweat A LOT.\"\n @fitness_score2 = 0\n elsif fitness_answer2 == \"I work pretty hard but take a lot of breaks.\"\n @fitness_score2 = 1\n elsif fitness_answer2 == \"I don't sweat.\"\n @fitness_score2 = 2\n end\n @fitness_score2\nend",
"def get_user_first_score user\r\n return nil unless self.user_is_done? user\r\n correct = 0\r\n self.problems.each do |p|\r\n (correct = correct + 1) if p.user_did_correct_first?(user)\r\n end\r\n correct\r\n end",
"def goal\n 28\n end",
"def solve\n return ((1..40).inject(:*) / ((1..20).inject(:*) ** 2))\nend",
"def solved_by?(contestant)\n if solutions.where(:user_id => contestant).empty?\n return false # not solved\n else\n return true # solved\n end\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 determine_motivation(candidate)\n\tputs \"On a scale of 1 to 5 (5 being the most), how important is the candidate's motivation?\"\n\tmotivation = gets.chomp\n\tif check_number_input(motivation) == false\n\t\tprob_found\n\t\tdetermine_motivation(candidate)\n\telse\n\t\tmotivation = motivation.to_i*candidate.convert_to_val('fast_learner')\n\tend\nend",
"def super_teacher\n Teacher.first\n end",
"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 scientist; end",
"def personal_subjective_pronoun\n return @gender.personal_subjective\n end",
"def fitness individual\r\n (5 - individual).abs\r\n end",
"def best_result(triplet)\n triplet.max\nend",
"def score_seminar(seminar, members)\n result = 0.0\n \n #Sum up scores for each member\n for m in members\n value = $scores[seminar][m]\n if value != -1000\n value = (value[0].to_f.abs * $school_bouns[$user_school_number[m]]) + $user_admit[m]\n end\n result = result + value\n end\n \n #Prevents Adjustments from going negative in case all application are not rated\n if result < 0.0\n result = 1.0\n end\n \n #Adjust for number of schools in seminar\n schools = Hash.new()\n for m in members\n schools[$user_school[m]] = \"found\"\n end\n result = result * (1.0 + schools.length/100.0)\n \n #Count up school levels\n num_elm = 0\n num_mid = 0\n num_hs = 0\n for m in members\n \t\tgrades = $grades[m]\n \t\tif grades[0] == 49 or grades[1] == 49 or grades[2] == 49 or grades[3] == 49 or grades[4] == 49 or grades[5] == 49 or grades[6] == 49\n \t\t\tnum_elm += 1\n \t\tend\n \t\tif grades[6] == 49 or grades[7] == 49 or grades[8] == 49\n \t\t\tnum_mid += 1\n \t\tend\n \t\tif grades[9] == 49 or grades[10] == 49 or grades[11] == 49 or grades[12] == 49\n \t\t\tnum_hs += 1\n \t\tend\n \tend\n \t\n \t#School Level Bonuses\n \tif num_elm == $target_elm_teachers_per_seminar\n \t\tresult = result * 1.1\n \telsif (num_elm == $target_elm_teachers_per_seminar + 1) or (num_elm == $target_elm_teachers_per_seminar - 1)\n \t\tresult = result * 1.05\n \tend\n \tif num_mid == $target_mid_teachers_per_seminar\n \t\tresult = result * 1.1\n \telsif (num_mid == $target_mid_teachers_per_seminar + 1) or (num_mid == $target_mid_teachers_per_seminar - 1)\n \t\tresult = result * 1.05\n \tend\n \tif num_hs == $target_hs_teachers_per_seminar\n \t\tresult = result * 1.1\n \telsif (num_hs == $target_hs_teachers_per_seminar + 1) or (num_hs == $target_hs_teachers_per_seminar - 1)\n \t\tresult = result * 1.05\n \tend\n \n \n #Adjust for number of grade levels in seminar\n=begin\n key = \"0000000000000\"\n for m in members\n grades = $grades[m]\n for x in (0..12)\n if grades[x] == 49\n\t\t\tkey[x] = '1'\n end\n end\n end\n num_grades = 0\n for x in (0..12)\n if key[x] == 49\n num_grades += 1\n end\n end\n result = result * (1.0 + num_grades/100.0)\n=end\n \n #Adjust for ratio of new to returning applicants\n new_users = 0\n for m in members\n if new_user?(seminar,m)\n new_users += 1\n end\n end\n target = $target_num_new_users_per_seminar\n if new_users == target\n result *= 1.06\n elsif (new_users == target +1) or (new_users == target -1)\n result *= 1.05\n elsif (new_users == target +2) or (new_users == target -2)\n result *= 1.04\n elsif (new_users == target +3) or (new_users == target -3)\n result *= 1.03\n elsif (new_users == target +4) or (new_users == target -4)\n result *= 1.02\n elsif (new_users == target +5) or (new_users == target -5)\n result *= 1.01\n end\n \n #Adjust for number of members in a seminar where the max is 13\n size = members.length\n if size <= 13\n result = result * (1.1 ** size)\n else\n result = -100000.0\n end\n \n result\nend",
"def get_subject(school, instructor_name)\n school[:instructors].each do |instructor|\n if instructor_name == instructor[:name]\n puts instructor[:subject]\n end\n end\nend",
"def gradeQuestion(studentAns, keyAns )\n # Value of correctness\n score = 0\n if( studentAns == keyAns ) then\n score = 1\n end\n score\n end",
"def teachers(student)\n\tputs \"Do you want to know who your teachers are?(y/n)\"\n\tuser_input = gets.chomp\n\tif user_input == \"y\" || user_input == \"Y\"\n\t\tteacher_records = student.teachers\n\t\tteacher_records.map do |teacher|\n\t\t\tputs teacher.name\n\t\tend\n\telse\n\t\tputs \"Go to your dorm and rest well. Big day tomorrow!\"\n\tend\nend",
"def solution1(input)\n return \"Not implemented!\"\nend",
"def faculty(n)\n return (1..n).inject(1, :*)\nend",
"def gradeQuestion(studentAns, keyAns )\n # Value of correctness\n score = 0\n if studentAns == keyAns then\n score = 1\n end\n score\n end",
"def score\n verdict ? (verdict.score * problem.weight / verdict.max_score.to_f) : 0\n end",
"def valid_prize_teacher\n return self.teachers.first if self.prize_teacher_id.blank? || self.teachers.first.try(:id) == self.prize_teacher_id\n nil\n end",
"def solved?\n !!self.answers.select {|x| x.correct}[0]\n end",
"def personal_best\n personal_top_three.first\n end",
"def dean\n faculty.dean\n end",
"def getNumberOfSolutions; @solutions.length; end",
"def describe_problem(p)\n return p[0].to_s+\"-\"+p[1]\nend",
"def solution(s, p, q)\n # write your code in Ruby 2.2\n g = s.length + 1\n a = (s.length + 1)**3\n c = (s.length + 1)**2\n tmp = []\n res = []\n tmp.push 0\n o = 0\n s.split('').each do |i|\n o += if i == 'T'\n 1\n elsif i == 'G'\n g\n elsif i == 'C'\n c\n else\n a\nend\n tmp.push o\n end\n (0...p.length).each do |k|\n o = tmp[q[k] + 1] - tmp[p[k]]\n if o >= a\n res.push 1\n elsif o >= c\n res.push 2\n elsif o >= g\n res.push 3\n else\n res.push 4\n end\n end\n res\nend",
"def judge(score)\n if score > 80\n return \"Good job\"\n end\n return \"You can do better\"\nend",
"def first_puzzle a\n # write down your solution to puzzle 1 here\nend",
"def curriculum_for_teacher_with_subject_and_class( teacher, subject_name, school_class )\n subject = teacher.subjects.where(:subject_name => subject_name).first # Get subject for teacher.\n subject_qualification = teacher.qualifications.where(:subject_id => subject.id).first # Qualification for subject.\n curriculum = subject_qualification.curriculums.select do |c| # Filter curriculum\n c.school_class.class_code == school_class.class_code # ... via input class code\n end\n\n unless curriculum.empty? # If we found curriculum return it (first element in array)\n curriculum.first\n else\n nil # Then return nil, it will help to debug (i hope)\n end\n end",
"def tongue_twister; end",
"def most_interesting_man_in_the_world; end",
"def senior?\n\t\tgrade == 12\n\tend",
"def teachers_name\n teacher&.name\n end",
"def teacher_availability\n @problem.never{ \n conjunct{ [\n Timetable::Entry.asp(:course_component_id => \"C\",\n :weekday_id => \"WD\",\n :timeframe_id => \"TF\"),\n Course::Component.asp(:id => \"C\",\n :teacher_id => \"T\"),\n Teacher::Unavailability.asp(:teacher_id => \"T\",\n :weekday_id => \"WD\",\n :timeframe_id => \"TF\")\n\n ]}\n }\n end",
"def manhattan(people, target_index, ratio_index, ratio)\n (0...people.length).each do |index|\n next unless unless_true(people, index, target_index)\n\n next unless manhattan_formula(people, index, target_index) < ratio\n\n ratio = manhattan_formula(people, index, target_index)\n ratio_index = index\n end\n puts \"manhattan-Atitikmuo: #{ratio_index} asmuo, ugis:#{people[ratio_index].height}\"\nend",
"def questionOne(frustration)\n if frustration == \"Yes\"\n return 3\n end \n \n if frustration == \"Not at all\"\n return 1\n end \n \n if frustration == \"I can't tell\"\n return 2\n end\nend",
"def part2(program)\n special = 19690720\n (0..99).to_a.repeated_permutation(2).each do |noun, verb|\n input = program.dup\n input[1] = noun\n input[2] = verb\n\n output = run(input)\n puts \"noun = #{noun}, verb = #{verb}, output = #{output[0]}\"\n if output[0] == special\n return [noun, verb]\n end\n end\n puts \"fuck\"\n return [-1, -1]\nend",
"def solveProblem lst\n big = -1\n numbers = {}\n half = lst.length / 2\n lst.each do |i|\n if numbers.has_key?(i) then\n numbers[i] += 1\n else\n numbers[i] = 1\n end\n if numbers[i] > half then return i end\n end\n return big\nend",
"def main_goal()\n # TODO: replace naive implementation\n return goals.values.first\n end",
"def problem_three\n find_factors(600_851_475_143).max\n end",
"def teacher_is_super( teacher)\n teacher == Teacher.first\n end",
"def persons\n if self.infos.sex == \"Couple\"\n 2\n else\n 1\n end\n end",
"def solve!\n end",
"def solution(a)\r\n a.each do |num|\r\n if (a.count(num) % 2) != 0\r\n return num\r\n end\r\n end\r\nend",
"def first_second_and_third_students\n puts STUDENT_NAMES[0.. 2]\n # Write a solution that returns the first, second and third students\nend",
"def solution_of(problem)\n\t\tif self.seen_problems.include?(problem)\n\t\t\treturn self.user_problem_relations.find_by(seen_problem_id: problem.id).solution\n\t\tend\n\tend",
"def gram_schmidtR\n gram_schmidt[1]\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 pythag_two()\n\ta = 1\n\tb = 2\n\tc = 1\n\tlist = []\n\tdora_will_be_a_good_doctor = []\n\twhile a <= 1000\n\t\tb = 1\n\t\twhile b <= 1000\n\t\t\ttemp_c = a**2 + b**2\n\t\t\t# dora_will_be_a_good_doctor << [a**2,b**2,temp_c]\n\t\t\t# p \"#{a},#{b},#{temp_c**0.5}\"\n\t\t\tif integerizer(temp_c**0.5) == true && summer([a,b,temp_c**0.5]) <= 1000\n\t\t\t\tdora_will_be_a_good_doctor << [a,b,temp_c**0.5].sort\n\t\t\tend\n\t\t\tb += 1\n\t\tend\n\t\ta += 1\n\tend\n\t# dora_will_be_a_good_doctor.each do |mowingdora_2|\n\t# \tif summer(mowingdora_2) <= 1000**2\n\t# \t\tlist << mowingdora_2\n\t# \tend\n\t# end\n\t# list.each do |mowingdora|\n\t# \tp mowingdora\n\t# \tif mowingdora[0]**2 + mowingdora[1]**2 == mowingdora[2] #&& integerizer((mowingdora[2]**0.5)) == true\n\t# \t\tdora_will_be_a_good_doctor << [mowingdora[0], mowingdora[1], mowingdora[2]**0.5]\n\t# \tend\n\t# end\n\t# p list\n\treturn dora_will_be_a_good_doctor\n\t# p list\nend"
] | [
"0.6101889",
"0.60088825",
"0.5942575",
"0.590028",
"0.5887425",
"0.57310027",
"0.5698055",
"0.56876075",
"0.5654702",
"0.56482345",
"0.5637539",
"0.56293404",
"0.5621347",
"0.5604939",
"0.55854684",
"0.5580631",
"0.55686224",
"0.55631375",
"0.5537981",
"0.5536098",
"0.5533553",
"0.5526368",
"0.5523241",
"0.55142134",
"0.5513724",
"0.550254",
"0.54629713",
"0.545692",
"0.54443306",
"0.544242",
"0.5436497",
"0.54164857",
"0.54164857",
"0.5404189",
"0.5402461",
"0.5385115",
"0.538459",
"0.53795105",
"0.53769386",
"0.5366265",
"0.5362702",
"0.5341364",
"0.53408635",
"0.5334706",
"0.5329137",
"0.5307598",
"0.53032506",
"0.52983457",
"0.52938616",
"0.5293079",
"0.52924997",
"0.528148",
"0.5277413",
"0.5256598",
"0.52474064",
"0.5246054",
"0.5236547",
"0.5236334",
"0.52333105",
"0.5226004",
"0.5221861",
"0.5219778",
"0.52195567",
"0.521416",
"0.5212939",
"0.5210339",
"0.5209155",
"0.5207078",
"0.5196499",
"0.5193386",
"0.5191021",
"0.5188329",
"0.51873934",
"0.518092",
"0.5175531",
"0.5172574",
"0.51663214",
"0.5164862",
"0.515777",
"0.51524645",
"0.515053",
"0.5143823",
"0.51425606",
"0.51422685",
"0.51375306",
"0.5134844",
"0.51347595",
"0.5130442",
"0.51279074",
"0.51258254",
"0.51224345",
"0.5121309",
"0.51212114",
"0.5118331",
"0.5115016",
"0.5113681",
"0.51124614",
"0.51029843",
"0.51022965",
"0.5095545",
"0.50951844"
] | 0.0 | -1 |
Set the needed paths. install_dir: The gems will be temporarily installed into this directory. Caution: Before installing the directory will be delete. jar_dir: The directory where the JAR files will be put. | def setup(install_dir, jar_dir)
@install_dir = install_dir
@jar_dir = jar_dir
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bundle\n raise \"Paths not given! Call setup first.\" if @install_dir.nil? || @jar_dir.nil?\n gems_jar = File.join(jar_dir, 'gems.jar')\n default_options = { :generate_rdoc => false, \n :generate_ri => false,\n :install_dir => install_dir }\n FileUtils.rm_rf install_dir if File.exists? install_dir\n FileUtils.mkdir_p install_dir\n installer = Gem::DependencyInstaller.new(default_options)\n @gems.each do |name, version|\n puts \"Installing #{name} (#{version})\"\n installer.install(name, version || Gem::Requirement.default) \n end\n Dir.glob(\"#{install_dir}/**/*.jar\").each do |jar|\n FileUtils.mv jar, File.join(jar_dir, jar.split(\"/\").last)\n end\n FileUtils.rm gems_jar if File.exists? gems_jar\n `jar cf #{gems_jar} -C #{install_dir} .`\n end",
"def install_dir # :nodoc:\n File.join Gem.dir, 'bundler', 'gems', \"#{@name}-#{dir_shortref}\"\n end",
"def add_plugin_paths(install_dir)\n Dir.glob(File.join([install_dir, '*'])).each do |mod|\n $LOAD_PATH << File.join([mod, 'lib'])\n end\n end",
"def installdirs=(val)\n @installdirs = val\n case val.to_s\n when 'std'\n self.rbdir = '$librubyver'\n self.sodir = '$librubyverarch'\n when 'site'\n self.rbdir = '$siterubyver'\n self.sodir = '$siterubyverarch'\n when 'home'\n raise SetupError, 'HOME is not set.' unless ENV['HOME']\n self.prefix = ENV['HOME']\n self.rbdir = '$libdir/ruby'\n self.sodir = '$libdir/ruby'\n else\n raise SetupError, \"bad config: use INSTALLDIRS=(std|site|home|local) [#{val}]\"\n end\n end",
"def spec_dirs=(paths)\n # Save the closest one for me,\n my_spec_dir = paths.shift || '.'\n # and assign the rest to my parent.\n parent!.spec_dirs = paths unless paths.empty?\n self.spec_dir = my_spec_dir\n end",
"def installed_files\n Dir.chdir(@spec.gem_dir) { Dir['**/*'].reject {|fp| ::File.directory?(fp) } }\n end",
"def install_dir\n Crate.project.install_dir\n end",
"def install\n prefix.install Dir[\"*\"] \n end",
"def add_bundler_files(jar)\n pwd = Pathname.new(Dir.pwd)\n gemfile = config.bundler[:gemfile].relative_path_from(pwd).to_s\n lockfile = config.bundler[:lockfile].relative_path_from(pwd).to_s\n jar.files[jar.apply_pathmaps(config, gemfile, :application)] = config.bundler[:gemfile].to_s\n if File.exist?(lockfile)\n jar.files[jar.apply_pathmaps(config, lockfile, :application)] = config.bundler[:lockfile].to_s\n end\n end",
"def install\n # Get rid of the JRE directory so it'll use the system JRE\n system \"rm\", \"-rf\", \"jre\"\n\n # There's probably a more correct way to do this\n system \"cp\", \"-a\", \".\", \"#{libexec}\"\n\n # Link in the actual commands\n bin.install_symlink \"../libexec/IPMIView20\"\n bin.install_symlink \"../libexec/JViewerX9\"\n bin.install_symlink \"../libexec/TrapReceiver\"\n bin.install_symlink \"../libexec/iKVM\"\n end",
"def inject_jar(jar_path)\n jar_dir = tmp_app_path.join('Contents/Java')\n jar_dir.rmtree\n jar_dir.mkdir\n cp Pathname.new(jar_path), jar_dir\n end",
"def additional_classpath\r\n list = super\r\n\r\n if FileTest.exist? ext=File.join(@lib, 'ext')\r\n current = Dir.getwd\r\n Dir.chdir ext\r\n\r\n list += Dir['*.jar'].collect { |jar| File.join(ext, jar) }\r\n\r\n Dir.chdir current\r\n end\r\n list\r\n end",
"def gem_install(jruby, basedir, gemname, quiet = false)\n if gemname.include?(\",\")\n g, v = gemname.split(\",\",2)\n cmd(\"#{jruby} -S gem install -i #{basedir} #{g} -v=#{v}\", quiet)\n else\n cmd(\"#{jruby} -S gem install -i #{basedir} #{gemname}\", quiet)\n end\n end",
"def install\n prefix.install Dir[\"*\"]\n end",
"def install\n prefix.install Dir[\"*\"]\n end",
"def install_dir(plugin_dirs = [], &filter)\n\t Installer.copy_tree(File.join(Roby::ROBY_ROOT_DIR, 'app'), app.app_dir, &filter)\n\t plugin_dirs.each do |dir|\n\t\tplugin_app_dir = File.join(dir, 'app')\n\t\tnext unless File.directory?(plugin_app_dir)\n\t\tInstaller.copy_tree(plugin_app_dir, app.app_dir, &filter)\n\t end\n\tend",
"def install_dir(val = NULL)\n if null?(val)\n @install_dir || raise(MissingProjectConfiguration.new('install_dir', '/opt/chef'))\n else\n @install_dir = File.expand_path(val, Config.project_root)\n end\n end",
"def add_gem_paths; end",
"def install\n cd_and_sh( pkg_dir, install_commands )\n end",
"def install_dir\n @install_dir ||= ENV['WD_INSTALL_DIR'] || DEFAULT_INSTALL_DIR\n end",
"def install_dir # :nodoc:\n return unless File.exist? repo_cache_dir\n\n File.join base_dir, 'gems', \"#{@name}-#{dir_shortref}\"\n end",
"def install(name:, dir: nil)\r\n end",
"def install!(name:, dir: nil)\r\n end",
"def gem_install_dir\n if gems_use_tool_repo && tool_repo_install_dir && !user_install_enable\n path = eval_path(tool_repo_install_dir)\n else\n path = eval_path(find_val('user_gem_dir') || find_val('gem_install_dir') || home_dir)\n end\n\n append = find_val('append_gems')\n append = 'gems' if append == true || append.nil?\n\n if append\n unless path.end_with?(append)\n path = File.join(path, append)\n end\n end\n path\n end",
"def install\n\t install_dir(plugin_dirs) do |file|\n\t\tnext if file =~ /ROBOT/\n\t\tfile\n\t end\n\tend",
"def setup\n install_latest_ruby\n\n install_global_gems\n end",
"def install(path)\n gem 'install', '-q', path\n end",
"def install\r\n automated_install {\r\n installer = Gem::Installer.new( @gem_path,\r\n :domain => :both,\r\n :generate_rdoc => true,\r\n :generate_ri => true,\r\n :force => true,\r\n :test => false,\r\n :wrappers => true,\r\n :install_dir => Gem.dir,\r\n :security_policy => nil\r\n )\r\n installer.install\r\n }\r\n end",
"def set_code_dirs\n @directories[\"code_dirs\"] = %w(app lib).select { |dir| Dir.exist?(dir) }\n end",
"def install\n pluginpath = Pathname.new(\"#{ENV['HOME']}/.packer.d/plugins\")\n\n unless File.directory?(pluginpath)\n mkdir_p(pluginpath)\n end\n\n cp_r Dir[\"*\"], pluginpath\n bin.install Dir['*']\n end",
"def install_gem_from_src(gem_src_dir, options = {})\n raise SourcePathMissing unless File.directory?(gem_src_dir)\n raise GemPathMissing if options[:install_dir] && !File.directory?(options[:install_dir])\n \n gem_name = File.basename(gem_src_dir)\n gem_pkg_dir = File.expand_path(File.join(gem_src_dir, 'pkg'))\n\n # We need to use local bin executables if available.\n thor = which('thor')\n rake = which('rake')\n\n # Handle pure Thor installation instead of Rake\n if File.exists?(File.join(gem_src_dir, 'Thorfile'))\n # Remove any existing packages.\n FileUtils.rm_rf(gem_pkg_dir) if File.directory?(gem_pkg_dir)\n # Create the package.\n FileUtils.cd(gem_src_dir) { system(\"#{thor} :package\") }\n # Install the package using rubygems.\n if package = Dir[File.join(gem_pkg_dir, \"#{gem_name}-*.gem\")].last\n FileUtils.cd(File.dirname(package)) do\n install_gem(File.basename(package), options.dup)\n return \n end\n else\n raise Merb::GemInstallError, \"No package found for #{gem_name}\"\n end\n # Handle standard installation through Rake\n else\n # Clean and regenerate any subgems for meta gems.\n Dir[File.join(gem_src_dir, '*', 'Rakefile')].each do |rakefile|\n FileUtils.cd(File.dirname(rakefile)) { system(\"#{rake} clobber_package; #{rake} package\") } \n end\n \n # Handle the main gem install.\n if File.exists?(File.join(gem_src_dir, 'Rakefile'))\n # Remove any existing packages.\n FileUtils.cd(gem_src_dir) { system(\"#{rake} clobber_package\") }\n # Create the main gem pkg dir if it doesn't exist.\n FileUtils.mkdir_p(gem_pkg_dir) unless File.directory?(gem_pkg_dir)\n # Copy any subgems to the main gem pkg dir.\n Dir[File.join(gem_src_dir, '**', 'pkg', '*.gem')].each do |subgem_pkg|\n FileUtils.cp(subgem_pkg, gem_pkg_dir)\n end\n \n # Finally generate the main package and install it; subgems \n # (dependencies) are local to the main package.\n FileUtils.cd(gem_src_dir) do \n system(\"#{rake} package\")\n FileUtils.cd(gem_pkg_dir) do \n if package = Dir[File.join(gem_pkg_dir, \"#{gem_name}-*.gem\")].last\n # If the (meta) gem has it's own package, install it.\n install_gem(File.basename(package), options.dup) \n else\n # Otherwise install each package seperately.\n Dir[\"*.gem\"].each { |gem| install_gem(gem, options.dup) }\n end\n end\n return\n end\n end\n end\n raise Merb::GemInstallError, \"No Rakefile found for #{gem_name}\"\n end",
"def install_dir(lib)\n if fr = ENV['FAKEROOT']\n return File.join(fr, lib)\n end\n\n lib\nend",
"def install\n libexec.install \"phyutility.jar\"\n bin.write_jar_script libexec/\"phyutility.jar\", \"phyutility\"\n pkgshare.install \"examples\", \"manual.pdf\"\n end",
"def pkg_dir=( pd )\n @pkg_dir = File.join( self.build_dir, pd )\n end",
"def gems_dir\n raise NotImplementedError\n end",
"def shared_boot_jar_directory\n FilePath.new(@build_dir, \"boot-jars\")\n end",
"def install\n invoke \"totem:lodestar:install:javascripts\"\n invoke \"totem:lodestar:install:stylesheets\"\n invoke \"totem:lodestar:install:images\"\n invoke \"totem:lodestar:install:configs\", [file_name]\n invoke \"totem:lodestar:install:databases\", [file_name]\n invoke \"totem:lodestar:install:routes\"\n invoke \"totem:lodestar:install:documents\"\n invoke \"totem:lodestar:install:travis_ci\", [file_name]\n invoke \"totem:lodestar:install:views\", [file_name]\n end",
"def install(local: false)\n\tpath = self.build\n\t\n\t@helper.install_gem(path, local)\nend",
"def install\n install_gems(dependencies)\n end",
"def install_gem; end",
"def install\n #python executable files\n end",
"def load_gems_in(*spec_dirs); end",
"def installed_spec_directories; end",
"def install\n # system \"./configure\", \"--disable-debug\", \"--disable-dependency-tracking\",\n \"--prefix=#{prefix}\"\n # system \"cmake . #{std_cmake_parameters}\"\n # system \"make install\" # if this fails, try separate make/make install steps\n # system \"cp -r lib samples #{prefix}\"\n prefix.install Dir[ '*' ]\n end",
"def install_gem_from_src(gem_src_dir, options = {})\n if !File.directory?(gem_src_dir)\n raise \"Missing rubygem source path: #{gem_src_dir}\"\n end\n if options[:install_dir] && !File.directory?(options[:install_dir])\n raise \"Missing rubygems path: #{options[:install_dir]}\"\n end\n\n gem_name = File.basename(gem_src_dir)\n gem_pkg_dir = File.expand_path(File.join(gem_src_dir, 'pkg'))\n\n # We need to use local bin executables if available.\n thor = \"#{Gem.ruby} -S #{which('thor')}\"\n rake = \"#{Gem.ruby} -S #{which('rake')}\"\n\n # Handle pure Thor installation instead of Rake\n if File.exists?(File.join(gem_src_dir, 'Thorfile'))\n # Remove any existing packages.\n FileUtils.rm_rf(gem_pkg_dir) if File.directory?(gem_pkg_dir)\n # Create the package.\n FileUtils.cd(gem_src_dir) { system(\"#{thor} :package\") }\n # Install the package using rubygems.\n if package = Dir[File.join(gem_pkg_dir, \"#{gem_name}-*.gem\")].last\n FileUtils.cd(File.dirname(package)) do\n install_gem(File.basename(package), options.dup)\n return true\n end\n else\n raise Gem::InstallError, \"No package found for #{gem_name}\"\n end\n # Handle elaborate installation through Rake\n else\n # Clean and regenerate any subgems for meta gems.\n Dir[File.join(gem_src_dir, '*', 'Rakefile')].each do |rakefile|\n FileUtils.cd(File.dirname(rakefile)) do \n system(\"#{rake} clobber_package; #{rake} package\")\n end\n end\n\n # Handle the main gem install.\n if File.exists?(File.join(gem_src_dir, 'Rakefile'))\n subgems = []\n # Remove any existing packages.\n FileUtils.cd(gem_src_dir) { system(\"#{rake} clobber_package\") }\n # Create the main gem pkg dir if it doesn't exist.\n FileUtils.mkdir_p(gem_pkg_dir) unless File.directory?(gem_pkg_dir)\n # Copy any subgems to the main gem pkg dir.\n Dir[File.join(gem_src_dir, '*', 'pkg', '*.gem')].each do |subgem_pkg|\n if name = File.basename(subgem_pkg, '.gem')[/^(.*?)-([\\d\\.]+)$/, 1]\n subgems << name\n end\n dest = File.join(gem_pkg_dir, File.basename(subgem_pkg))\n FileUtils.copy_entry(subgem_pkg, dest, true, false, true) \n end\n\n # Finally generate the main package and install it; subgems\n # (dependencies) are local to the main package.\n FileUtils.cd(gem_src_dir) do \n system(\"#{rake} package\")\n FileUtils.cd(gem_pkg_dir) do\n if package = Dir[File.join(gem_pkg_dir, \"#{gem_name}-*.gem\")].last\n # If the (meta) gem has it's own package, install it.\n install_gem(File.basename(package), options.merge(:refresh => subgems))\n else\n # Otherwise install each package seperately.\n Dir[\"*.gem\"].each { |gem| install_gem(gem, options.dup) }\n end\n end\n return true\n end\n end\n end\n raise Gem::InstallError, \"No Rakefile found for #{gem_name}\"\n end",
"def init_folders(dir)\n\n FOLDER_DEFAULTS.each do |key|\n @folder=dir+\"/\"+key[:dir]\n @folder.gsub!('\\\\','/')\n if not File.directory? @folder\n File.makedirs @folder\n end\n end\n\n end",
"def set_export_dir(dir)\n @dir = dir\n FileUtils.mkdir_p(@dir) unless File.directory?(@dir)\n end",
"def lib_paths=(paths)\n case paths\n when nil\n paths = ['lib']\n when String\n paths = split_path(path)\n end\n paths[:lib] = paths\n end",
"def install_gem_from_src(gem_src_dir, options = {})\n if !File.directory?(gem_src_dir)\n raise \"Missing rubygem source path: #{gem_src_dir}\"\n end\n if options[:install_dir] && !File.directory?(options[:install_dir])\n raise \"Missing rubygems path: #{options[:install_dir]}\"\n end\n\n gem_name = File.basename(gem_src_dir)\n gem_pkg_dir = File.expand_path(File.join(gem_src_dir, 'pkg'))\n\n # We need to use local bin executables if available.\n thor = \"#{Gem.ruby} -S #{which('thor')}\"\n rake = \"#{Gem.ruby} -S #{which('rake')}\"\n\n # Handle pure Thor installation instead of Rake\n if File.exists?(File.join(gem_src_dir, 'Thorfile'))\n # Remove any existing packages.\n FileUtils.rm_rf(gem_pkg_dir) if File.directory?(gem_pkg_dir)\n # Create the package.\n FileUtils.cd(gem_src_dir) { system(\"#{thor} :package\") }\n # Install the package using rubygems.\n if package = Dir[File.join(gem_pkg_dir, \"#{gem_name}-*.gem\")].last\n FileUtils.cd(File.dirname(package)) do\n install_gem(File.basename(package), options.dup)\n return true\n end\n else\n raise Gem::InstallError, \"No package found for #{gem_name}\"\n end\n # Handle standard installation through Rake\n else\n # Clean and regenerate any subgems for meta gems.\n Dir[File.join(gem_src_dir, '*', 'Rakefile')].each do |rakefile|\n FileUtils.cd(File.dirname(rakefile)) do \n system(\"#{rake} clobber_package; #{rake} package\")\n end\n end\n\n # Handle the main gem install.\n if File.exists?(File.join(gem_src_dir, 'Rakefile'))\n # Remove any existing packages.\n FileUtils.cd(gem_src_dir) { system(\"#{rake} clobber_package\") }\n # Create the main gem pkg dir if it doesn't exist.\n FileUtils.mkdir_p(gem_pkg_dir) unless File.directory?(gem_pkg_dir)\n # Copy any subgems to the main gem pkg dir.\n Dir[File.join(gem_src_dir, '*', 'pkg', '*.gem')].each do |subgem_pkg|\n dest = File.join(gem_pkg_dir, File.basename(subgem_pkg))\n FileUtils.copy_entry(subgem_pkg, dest, true, false, true) \n end\n\n # Finally generate the main package and install it; subgems\n # (dependencies) are local to the main package.\n FileUtils.cd(gem_src_dir) do\n system(\"#{rake} package\")\n FileUtils.cd(gem_pkg_dir) do\n if package = Dir[File.join(gem_pkg_dir, \"#{gem_name}-*.gem\")].last\n # If the (meta) gem has it's own package, install it.\n install_gem(File.basename(package), options.dup)\n else\n # Otherwise install each package seperately.\n Dir[\"*.gem\"].each { |gem| install_gem(gem, options.dup) }\n end\n end\n return true\n end\n end\n end\n raise Gem::InstallError, \"No Rakefile found for #{gem_name}\"\n end",
"def setup\n require 'rubygems'\n require 'rubygems/dependency_installer'\n\n @gems.each do |name, options|\n setup_gem(name, options)\n end\n end",
"def setup\n require 'rubygems'\n require 'rubygems/dependency_installer'\n\n @gems.each do |name, options|\n setup_gem(name, options)\n end\n end",
"def install\n # # Changes log level to default value\n # inreplace \"etc/baetyl/conf.yml\" do |s|\n # s.gsub! \"level: debug\", \"\"\n # end\n\n bin.install Dir[\"bin/*\"]\n etc.install Dir[\"etc/*\"]\n end",
"def gem_dir # :nodoc:\n super\n end",
"def install_root\n self.class.install_root.join(name)\n end",
"def install_dir(val = NULL)\n if null?(val)\n @install_dir || raise(MissingRequiredAttribute.new(self, :install_dir, \"/opt/chef\"))\n else\n @install_dir = val.tr('\\\\', \"/\").squeeze(\"/\").chomp(\"/\") # rubocop:disable Style/StringLiterals\n end\n end",
"def prepare_dirs\n [@reports_dir, @cache_dir, @gems_dir].each do |dir|\n Dir.mkdir(dir) unless File.directory?(dir)\n end\n end",
"def initialize(opts, &block)\n @home_dir = opts[:home_dir].to_s\n opts[:data_dir] ||= File.join(@home_dir, 'data')\n if opts[:dist_dir] and ! opts[:jar_paths]\n # add the standard lib and dist directories to the :jar_paths\n opts[:jar_paths] = [File.join(opts[:dist_dir], 'lib'), File.join(opts[:dist_dir], 'dist')]\n end\n @opts = opts\n end",
"def installed_spec_directories\n Gem.path.collect { |dir| File.join(dir, \"specifications\") }\n end",
"def install_resources\n FileUtils.rm_rf(resources_dir)\n FileUtils.mkdir_p(resources_dir)\n resources.each { |file| install_resource(file, resources_dir) }\n end",
"def pkg_install\n return if @install.count == 0\n\n sysprint \"#{@name} install\"\n\n if @install[:bsys_install] != nil\n if @bsdstyle == true\n FileUtils::cd(@srcdir)\n else\n FileUtils::cd(@objdir)\n end\n\n unless sysexec(@install[:bsys_install])\n syserr \"Failed to install package\"\n raise\n end\n\n FileUtils::cd(BSYS_ROOTDIR)\n\n @install.delete(:bsys_install)\n end\n\n @install.each_pair do |src, dst|\n dst = File::join($project_rootdir, dst)\n if File::directory? src\n FileUtils::mkdir_p dst\n continue\n end\n\n # Create directory if it doesn't exists\n FileUtils::mkdir_p dst[0..-(File::basename(dst).length + 1)]\n\n if File::executable? src\n FileUtils::install(src, dst, :mode => 0755)\n else\n FileUtils::install(src, dst, :mode => 0644)\n end\n end\n end",
"def run_install(install_path)\n require 'fileutils'\n install_path ||= '.'\n FileUtils.mkdir_p install_path unless File.exists?(install_path)\n install_file \"#{CC_ROOT}/config/config.example.yml\", \"#{install_path}/config.yml\"\n install_file \"#{CC_ROOT}/config/config.example.ru\", \"#{install_path}/config.ru\"\n install_file \"#{CC_ROOT}/config/database.example.yml\", \"#{install_path}/database.yml\"\n install_file \"#{CC_ROOT}/actions\", \"#{install_path}/actions\", true\n end",
"def install(dir, mode, options={})\n #src = list.to_a\n #dest = localize(dest)\n fileutils.install(list, dir, mode, options)\n end",
"def install\n # Get rid of the JRE directory so it'll use the system JRE\n system \"rm\", \"-rf\", \"jre\"\n\n # There's probably a more correct way to do this\n system \"cp\", \"-a\", \".\", \"#{libexec}\"\n\n # Link in the actual commands\n bin.install_symlink \"../libexec/SMCIPMITool\"\n end",
"def install!\n STDERR.puts \"Slimerjs does not appear to be installed in #{slimerjs_path}, installing!\"\n FileUtils.mkdir_p Slimerjs.base_dir\n\n # Purge temporary directory if it is still hanging around from previous installs,\n # then re-create it.\n temp_dir = File.join(temp_path, 'slimerjs_install')\n FileUtils.rm_rf temp_dir\n FileUtils.mkdir_p temp_dir\n\n Dir.chdir temp_dir do\n unless system \"curl -O #{package_url}\" or system \"wget #{package_url}\"\n raise \"\\n\\nFailed to load slimerjs! :(\\nYou need to have cURL or wget installed on your system.\\nIf you have, the source of slimerjs might be unavailable: #{package_url}\\n\\n\"\n end\n\n case package_url.split('.').last\n when 'bz2'\n system \"bunzip2 #{File.basename(package_url)}\"\n system \"tar xf #{File.basename(package_url).sub(/\\.bz2$/, '')}\"\n when 'zip'\n system \"unzip #{File.basename(package_url)}\"\n else\n raise \"Unknown compression format for #{File.basename(package_url)}\"\n end\n\n # Find the slimerjs build we just extracted\n extracted_dir = Dir['slimerjs*'].find { |path| File.directory?(path) }\n\n # Move the extracted slimerjs build to $HOME/.slimerjs/version/platform\n if FileUtils.mv extracted_dir, File.join(Slimerjs.base_dir, platform)\n STDOUT.puts \"\\nSuccessfully installed slimerjs. Yay!\"\n end\n\n # Clean up remaining files in tmp\n if FileUtils.rm_rf temp_dir\n STDOUT.puts \"Removed temporarily downloaded files.\"\n end\n end\n\n raise \"Failed to install slimerjs. Sorry :(\" unless File.exist?(slimerjs_path)\n end",
"def with_embedded_path(env = {})\n paths = [\"#{install_dir}/bin\", \"#{install_dir}/embedded/bin\"]\n path_value = prepend_path(paths)\n env.merge(path_key => path_value)\n end",
"def create!\n FileUtils.mkdir_p(@configuration[:build_dir])\n\n Dir.mktmpdir do |tmp_dir|\n output_path = File.join(@configuration[:build_dir], @configuration[:jar_name])\n project_dir = Pathname.new(@configuration[:app_dir])\n extra_files = @configuration[:extra_files] || []\n jruby_complete_path = @configuration[:jruby_complete]\n\n if !(defined? JRubyJars) && !(jruby_complete_path && File.exists?(jruby_complete_path))\n raise PuckError, 'Cannot build Jar: jruby-jars must be installed, or :jruby_complete must be specified'\n end\n\n gem_dependencies = resolve_gem_dependencies\n create_jar_bootstrap!(tmp_dir, gem_dependencies)\n\n ant = Ant.new(output_level: 1)\n ant.jar(destfile: output_path) do\n manifest do\n attribute name: 'Main-Class', value: 'org.jruby.JarBootstrapMain'\n attribute name: 'Created-By', value: \"Puck v#{Puck::VERSION}\"\n end\n\n zipfileset dir: tmp_dir, includes: 'jar-bootstrap.rb'\n\n if jruby_complete_path\n zipfileset src: jruby_complete_path\n else\n zipfileset src: JRubyJars.core_jar_path\n zipfileset src: JRubyJars.stdlib_jar_path\n end\n\n %w[bin lib].each do |sub_dir|\n zipfileset dir: project_dir + sub_dir, prefix: File.join(JAR_APP_HOME, sub_dir)\n end\n\n extra_files.each do |ef|\n path = Pathname.new(ef).expand_path.cleanpath\n prefix = File.join(JAR_APP_HOME, path.relative_path_from(project_dir).dirname.to_s)\n zipfileset dir: path.dirname, prefix: prefix, includes: path.basename\n end\n\n gem_dependencies.each do |spec|\n zipfileset dir: spec[:base_path], prefix: spec[:jar_path]\n end\n end\n end\n end",
"def setDir _obj, _args\n \"_obj setDir _args;\" \n end",
"def prepare_gems(gems=GEMS)\n FileUtils.cd(@gems_dir) do\n listing = `gem list --local`\n missing = gems.reject{|package| listing.match(/^#{package}\\s/)}\n run \"gem install #{missing.join(' ')} --no-ri --no-rdoc\", true if missing.size > 0\n end\n end",
"def install\n Core.install(gem_name: gem_name, base: base, **options)\n Badges.install(gem_name: gem_name, base: base, **options)\n Travis.install(gem_name: gem_name, base: base, **options)\n end",
"def add_bundled_gems\n return unless bundle_gems\n\n if bundle_local\n logger.trace 'Adding bundler filer to jar locally...'\n else\n logger.trace 'Adding bundler files to jar...'\n end\n\n require 'bundler'\n begin\n gemfile_path, lockfile_path = nil\n\n # Execute Bundler commands in the app_path, not in the Dir.pwd\n Bundler::SharedHelpers.chdir app_path do\n # No need to check ENV['BUNDLE_GEMFILE'], because Bundler will\n # take care of that\n gemfile_path = Bundler.default_gemfile\n lockfile_path = Bundler.default_lockfile\n end\n rescue Bundler::GemfileNotFound\n logger.warn 'No Gemfile found - skipping gem dependencies'\n return {}\n end\n\n # We need gemfile_root to properly locate the `vendor/bundle`\n gemfile_root = gemfile_path.parent\n vendor_cache_path = gemfile_root.join('vendor/cache')\n vendor_bundle_path = gemfile_root.join('vendor/bundle')\n\n unless lockfile_path.exist?\n logger.warn 'No Gemfile.lock found — this might lead to unexpected \\\n dependency tree, please consider running `bundle install` to resolve \\\n and lock dependencies.'\n end\n\n exclude_registed_jars = TorqueBox::Jars.list.map { |j| File.basename(j) }\n bundle_source = temp_dir\n\n # No need to run bundler at all. Just copy the contents of the\n # `vendor/bundle` to the jar\n if vendor_bundle_path.exist?\n logger.info 'Using existing `vendor/bundle`. Make sure that your \\\n dependencies is up to date.'\n\n bundle_source = vendor_bundle_path\n else\n vendor_bundle_gems :lockfile_exist => lockfile_path.exist?\n end\n\n add_files :source => bundle_source.to_s,\n :destination => 'app/vendor/bundle',\n :pattern => '/{**/*,.bundle/**/*}',\n :exclude => exclude_registed_jars\n\n copy_bundler_gem\n end",
"def set_code_dirs\n if rails?\n @code_dirs = ['app', 'lib']\n else\n @code_dirs = ['lib']\n end\n end",
"def install\n print_title('Redmine installing')\n\n Dir.chdir(root) do\n # Gems can be locked on bad version\n FileUtils.rm_f('Gemfile.lock')\n\n # Install new gems\n bundle_install\n\n # Generate secret token\n rake_generate_secret_token\n\n # Ensuring database\n rake_db_create\n\n # Load database dump (if was set via CLI or attach on package)\n load_database_dump\n\n # Migrating\n rake_db_migrate\n\n # Plugin migrating\n rake_redmine_plugin_migrate\n\n # Install easyproject\n rake_easyproject_install if easyproject?\n end\n end",
"def find_jar(jar)\n oh = java.lang.System.getProperty('EPM_ORACLE_HOME') || ENV['EPM_ORACLE_HOME']\n unless oh\n raise ConfigurationError, \"No EPM_ORACLE_HOME defined. Set this as an environment \" +\n \"variable or Java system property, or else add #{jar} to the classpath.\"\n end\n log.finest \"EPM_ORACLE_HOME is #{oh}\"\n\n sub_dir = STANDARD_JAR_LOCATIONS[jar]\n if (ver_dirs = Dir[\"#{oh}/#{sub_dir}/*\"]) && !ver_dirs.empty?\n ver_dir = ver_dirs.first\n log.finest \"Adding #{ver_dir} dir to load path\"\n $LOAD_PATH << \"#{ver_dir}/lib\"\n require jar\n else\n raise ConfigurationError, \"Cannot locate #{jar} under #{oh}/#{sub_dir}\"\n end\n end",
"def install\n # ENV.java_cache\n # system \"mvn\", \"clean\", \"package\", \"-Dmaven.test.skip=true\"\n libexec.install \"swagger-codegen-cli.jar\"\n bin.write_jar_script libexec/\"swagger-codegen-cli.jar\", \"swagger-codegen-moya\"\n end",
"def install!\n\t\t\traise \"Target exists\" if target.present?\n\n\t\t\t# Directory entry - create the directory\n\t\t\ttarget.mkpath\n\t\tend",
"def install\n end",
"def connectorj_dir\n ::File.join(new_resource.base_dir, 'modules', 'system', 'layers', 'base', 'com', 'mysql', 'main')\n end",
"def install\n end",
"def installDir(src, dst, opts ={})\n dest=\"#{dst}/#{split_all(src)[-1]}\";\n if not test(?d, dest)\n mkdir_p dest;\t#TODO: change owner,group and permissions?\n end\n #FileList.new(\"#{src}/*\").each do |file|\n #installFile file, dest, opts;\n #end\n\tinstallDirContent(src, dest, opts);\nend",
"def load_lib_dirs\n lib_dirs.each do |lib|\n $LOAD_PATH << lib\n end\n end",
"def setup_remote_dirs\n @connection.create_directories([Gift::GIFT_DIR, File.join(Gift::GIFT_DIR, DELIVERIES_DIR)])\n end",
"def gem_install_args\n gem, version = config[:version].split(\"@\")\n if gem =~ /^\\d+\\.\\d+\\.\\d+/\n version = gem\n gem = \"busser\"\n end\n\n root = config[:root_path]\n gem_bin = remote_path_join(root, \"bin\")\n\n # We don't want the gems to be installed in the home directory,\n # this will force the bindir and the gem install location both\n # to be under /tmp/verifier\n args = gem\n args += \" --version #{version}\" if version\n args += \" --no-rdoc --no-ri --no-format-executable -n #{gem_bin}\"\n args += \" --no-user-install\"\n args\n end",
"def set_dir(new_dir)\n # checking for / at the end of the env variable\n new_dir = '' unless new_dir\n new_dir += '/' unless new_dir[-1, 1] == '/'\n @dir = new_dir\n end",
"def install\n FileUtils.cp_r File.join(builddir, '.'), destdir\n # Remove build cookies\n %w(build extract).each do |cookie|\n Dir.glob(\"#{destdir}/.#{cookie}-cookie-*\").each do |f|\n Log.info \"Deleting FPM Cookie #{f}\"\n File.delete(f)\n end\n end\n end",
"def bundle_install(name)\n Dir.chdir(name)\n system(\"bundle install\")\n system(\"rspec --init\")\nend",
"def install_to_directory\n # Get the current directory\n curr_dir = FileUtils::pwd + '/'\n # Use FileUtils\n fu = FileUtils\n # If we're just running as a simulation\n if $simulate\n # Use ::DryRun, that just echoes the commands, instead of the normal FileUtils\n fu = FileUtils::DryRun # ::DryRun / ::NoWrite\n end\n\n # Tell the user\n puts \"Installing the files to \".green + $install_dir.yellow\n puts \" (Keeping the .rb extensions) \".green if $keep_extensions\n\n # Go through the files\n files = ['deleteemailalias.rb','addemailalias.rb','listemailaliases.rb',\n 'deleteemaildomain.rb','addemaildomain.rb','deleteemailaccount.rb',\n 'listemailaccounts.rb','addemailaccount.rb','generate_password.rb']\n files.each { |f|\n # Remove the extenstion (unless we should keep it)\n nf = $keep_extensions ? f : f[0..-4]\n\n # Tell the user\n puts \"> Linking \".green + \"#{curr_dir}#{f}\".yellow + ' to '.green + \"#{$install_dir}#{nf}\".yellow\n\n if $force_install\n puts \"Forcing the install of #{nf}!\".red\n # Link the file\n fu.ln_sf curr_dir + f, $install_dir + nf\n else\n begin\n # Link the file\n fu.ln_s curr_dir + f, $install_dir + nf\n rescue Exception => e\n puts \"Couldn't link the file:\".pink\n puts e.message.red\n next\n end\n end\n\n puts \"> Adding 'execute permission' to the file\".green\n # adding \"execute permission\"\n fu.chmod \"a+x\", $install_dir + nf\n }\n\nend",
"def install_directory\n \"C:\\\\opscode\\\\chef\"\n end",
"def gem_dir\n @gem_dir ||= File.expand_path File.join(gems_dir, full_name)\n end",
"def install\n\n # Useful paths you can use in here:\n # - `prefix` -- where you should install stuff\n # - `bin` -- usually equals prefix/\"bin\"\n # - `lib` -- usually equals prefix/\"lib\"\n # - `libexec` -- usually equals prefix/\"libexec\"\n \n # Common shellisms have dedicated functions:\n cd \"tlatools/org.lamport.tlatools\"\n rm_r \"dir\"\n mkdir_p bin\n cp \"exe\", bin\n cp_r \"path\", lib\n chmod 0755, bin/\"exe\"\n\n # Shorthand for \"cp to bin; chmod 0555\"\n bin.install \"exe\"\n\n # You can also change the name of a file as you install it to bin:\n bin.install \"filename\" => \"exename\"\n\n # Invoking a standard autotools configure script:\n system \"./configure\", *std_configure_args\n\n # Referencing the install paths of other formulae --- this is great if you\n # want to isolate installed products from the user's environment or if you\n # need to point a configure script at some specific path.\n inreplace \"etc/settings\", \"/path/to/java/bin\", Formula[\"java\"].bin\n\n # In general, you can use:\n # - Formula[\"name\"].prefix\n # - Formula[\"name\"].bin\n # - Formula[\"name\"].lib\n\n # Create a file at build time\n (bin/exe).write(\"#!/bin/bash\\nexec java -XX:+UseParallelGC -DTLA-Library=\\\"$TLA_PATH\\\" -cp '#{lib}/tla2tools.jar' Classname \\\"$@\\\"\\n\")\n chmod 0555, bin/exe\n\n # Modifying the environment --- this affects all subsequent commands.\n ENV[\"VARIABLE_NAME\"] = \"VALUE\"\n\n # Colon-separated lists of paths are very common in environment variables\n # (e.g. PATH, CLASSPATH, etc). Homebrew offers a utility for extending\n # those lists:\n ENV.prepend_path \"OCAMLPATH\", Formula[\"coq\"].lib\n\n # Managing parallelism --- Homebrew turns on `make` parallelism by default\n # using environment variables, but some packages cannot be consistently\n # compiled in parallel.\n jobs = ENV.make_jobs # capture how much parallelism Homebrew recommends\n ENV.deparallelize # turn off parallel `make`\n\n\n # ------------------------------- Python-specific advice\n\n # Use `brew create --python [pypi url]`. This will include useful install\n # lines like:\n python = Formula[\"python@3\"]\n system python.opt_libexec/\"bin\"/\"python\", *Language::Python.setup_install_args(prefix, python)\n\n\n # ------------------------------- Java-specific advice\n\n # You'll probably want\n # depends_on \"java\"\n # depends_on \"maven\" # or \"ant\" or \"gradle\"\n # depends_on \"openjdk\" => :build\n ENV[\"JAVA_HOME\"] = Formula[\"openjdk\"].libexec/\"openjdk.jdk\"/\"Contents\"/\"Home\"\n\n end",
"def bundle_install(jruby, quiet = false, opts = {})\n ex_opts = opts.map {|k,v| [k,v] }.join(\" \")\n cmd(\"#{jruby} -S bundle install --path ./vendor/bundle/ #{ex_opts}\", quiet)\n end",
"def install\n end",
"def install\n end",
"def install(options = {})\n destination = options[:install_dir] || Gem.dir\n\n if File.exist? File.join(destination, 'specifications', spec.spec_name)\n yield nil\n return\n end\n\n super\n end",
"def setup\n switch_dir\n end",
"def setup(*_)\n require 'reaper-man'\n location = ReaperMan::Signer::HELPER_COMMAND\n if(location.include?('jar!'))\n tmp_file = Tempfile.new('reaper-man')\n new_location = File.join(Dir.home, File.basename(tmp_file.path))\n tmp_file.delete\n File.open(new_location, 'w') do |file|\n file.puts File.read(location)\n end\n File.chmod(0755, new_location)\n ReaperMan::Signer.send(:remove_const, :HELPER_COMMAND)\n ReaperMan::Signer.const_set(:HELPER_COMMAND, new_location)\n warn \"Updated ReaperMan utility script location: #{new_location}\"\n end\n end",
"def install\n # ENV.deparallelize # if your formula fails when building in parallel\n\n # Remove unrecognized options if warned by configure\n system \"git init && git submodule init && git submodule update\"\n bin.install \"install-dot-files\"\n end",
"def install!\n refresh_file_accessors\n prepare_pod_groups\n add_source_files_references\n add_frameworks_bundles\n add_vendored_libraries\n add_resources\n add_developer_files unless sandbox.development_pods.empty?\n link_headers\n end",
"def bundle\n Dir.chdir @temp_dir\n system(\"bundle install\")\n end",
"def install_sets\n announcing 'Installing Sets' do\n chroot 'install_sets'\n end\n send_to_state('build', 'install_sets')\n end",
"def default_install_dir\n @install_dir ||= CernerSplunk::PathHelpers.default_install_dirs[package][node['os'].to_sym]\n raise \"Unsupported Combination: #{package} + #{node['os']}\" unless @install_dir\n @install_dir\n end"
] | [
"0.67380136",
"0.5933493",
"0.58997345",
"0.58959854",
"0.5750506",
"0.5717784",
"0.568383",
"0.5610892",
"0.55940956",
"0.55603445",
"0.5547495",
"0.55282176",
"0.5518102",
"0.5503688",
"0.5503688",
"0.5475778",
"0.5475611",
"0.546512",
"0.5462571",
"0.544692",
"0.5440849",
"0.5429442",
"0.5366571",
"0.53654164",
"0.5362518",
"0.5351221",
"0.5332255",
"0.53149724",
"0.53083056",
"0.5290548",
"0.5263618",
"0.5254192",
"0.52452433",
"0.52438235",
"0.52043",
"0.52024573",
"0.5189182",
"0.5180346",
"0.5179284",
"0.51537997",
"0.5149627",
"0.5145786",
"0.51427376",
"0.5141417",
"0.5108009",
"0.50938195",
"0.5091942",
"0.508194",
"0.50768906",
"0.5071858",
"0.5071858",
"0.5064668",
"0.50490046",
"0.5044012",
"0.5040425",
"0.50287616",
"0.5021205",
"0.50107217",
"0.50089693",
"0.500329",
"0.5000415",
"0.49956757",
"0.49915394",
"0.49873435",
"0.498293",
"0.4979772",
"0.4969737",
"0.49654585",
"0.49599475",
"0.49500403",
"0.4948741",
"0.49447307",
"0.49418154",
"0.4941327",
"0.49403805",
"0.49384642",
"0.49370462",
"0.49362946",
"0.49256152",
"0.49005687",
"0.48987585",
"0.4897056",
"0.48915228",
"0.4882606",
"0.48687205",
"0.48623794",
"0.48563802",
"0.48443025",
"0.48315156",
"0.4831065",
"0.48279178",
"0.48279178",
"0.4823052",
"0.48207548",
"0.48181352",
"0.4816198",
"0.48145968",
"0.4813838",
"0.48116735",
"0.48098928"
] | 0.7811157 | 0 |
Adds a gem gem "activerecord", ">= 2.3.1" | def gem(name, version = Gem::Requirement.default)
@gems ||= {}
@gems[name] = version
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n optional_gem 'dbd-sqlite3', requires: 'dbd/SQLite3'\n optional_gem 'activerecord', '~> 4.0', requires: 'active_record'\n optional_gem 'dbi'\n optional_gem 'sqlite3'\n end",
"def pluggable!\n abort \"update rubygems to >= 1.3.1\" unless Gem.respond_to? :find_files\n require_rubygems_version \">= 1.3.1\"\n end",
"def gem(name, *requirements)\n self.class.gems.activate(name, *requirements)\n end",
"def require!\n super do\n gem @gem_name, @version if @version\n end\n end",
"def gem(name, requirement = nil)\n gems << Gem.new(name, requirement)\n end",
"def version_constraint(gem_name); end",
"def require_gems; end",
"def add_gem_paths; end",
"def require_gem(gem)\n dep = fetch(:required_gems)\n dep ||= []\n if gem.respond_to?(:each)\n dep += gem\n else\n dep << gem\n end\n set(:required_gems, dep)\n end",
"def gem(name, *reqs)\n @dependencies << Gem::Dependency.new(name, reqs)\n end",
"def gem(name, *reqs)\n @dependencies << Gem::Dependency.new(name, reqs)\n end",
"def depend_on( name, version = nil )\n spec = Gem::Specification.find_by_name(name)\n version = spec.version.to_s if version.nil? and !spec.nil?\n\n PROJ.gem.dependencies << case version\n when nil; [name]\n when %r/^\\d/; [name, \">= #{version}\"]\n else [name, version] end\nend",
"def depends_on(package, *version)\n dependencies << [ package, *version ]\n end",
"def require_gem gem, name = nil\n name = gem if name.nil?\n if !BBLib.gem_installed? name\n return false unless Gem.install gem\n end\n require name\n end",
"def add_gem_with_query(gem_name, gem_options={}, generator_command=nil, &block)\n if yes?(\"Would you like to install #{gem_name}? (y/n)\")\n add_gem(gem_name, gem_options, generator_command, &block)\n end\n end",
"def activate_gem(gem_name, library_name = nil)\n if !defined?(::Gem)\n begin\n require 'rubygems'\n rescue LoadError\n end\n end\n if Kernel.respond_to?(:gem, true)\n begin\n gem(gem_name)\n rescue Gem::LoadError\n end\n end\n require(library_name || gem_name)\n end",
"def add_gems\n Bundler.with_clean_env do\n run 'bundle install'\n end\n end",
"def install_gem; end",
"def merge_gem(gem_name, version=nil)\n gem_info = {:name=>gem_name}\n if version.is_a?(Hash)\n gem_info.merge!(version)\n else\n gem_info[:version] = version\n end\n @merged_gems << gem_info\n require gem_info[:require] || gem_name\n end",
"def gem_if_necessary(gem)\n grep = args = nil\n if gem =~ /(.*)-(\\d+\\.\\d+\\.\\d+)$/\n gem, version = $1, $2\n grep = \"^#{gem}.*#{version}\"\n args = \" --version #{version}\"\n else\n grep = \"^#{gem}\"\n end\n if fails?(\"gem list #{gem} | grep '#{grep}'\")\n banner \"#{gem}...\"\n run \"gem install #{gem} #{args} --no-rdoc --no-ri\"\n return true\n end\n false\n end",
"def add_development_dependency(gem, *requirements)\n add_dependency_with_type(gem, :development, requirements)\n end",
"def gem(name, *reqs)\n if dep = @dependency_names[name]\n dep.requirement.concat reqs\n else\n dep = Gem::Dependency.new name, *reqs\n @dependency_names[name] = dep\n @dependencies << dep\n end\n end",
"def gem( name, *requirements, **options )\n\t\tif options[:group] == :development ||\n\t\t\toptions[:groups]&.include?( :development ) ||\n\t\t\tself.current_groups.include?( :development )\n\n\t\t\trequirements.push( :development )\n\t\tend\n\n\t\tdependency = Gem::Dependency.new( name, *requirements )\n\n\t\tself.dependencies.add( dependency )\n\tend",
"def depend_on( name, version = nil )\n spec = Gem.source_index.find_name(name).last\n version = spec.version.to_s if version.nil? and !spec.nil?\n\n PROJ.gem.dependencies << case version\n when nil; [name]\n when %r/^\\d/; [name, \">= #{version}\"]\n else [name, version] end\nend",
"def postgresql_gem\n gem 'pg'\n end",
"def add_gem(gem)\n @gems << gem\n @gems = @gems.uniq\n true\n end",
"def gem_and_require_rails\n gem_rails\n require_rails\n display_rails_gem_used\n end",
"def active_record_at_least_4?\n defined?(::ActiveRecord) && ::ActiveRecord::VERSION::MAJOR >= 4\nend",
"def setup_gem(name, options)\n version = [options[:version]].compact\n lib_name = options[:lib] || name\n\n log \"activating #{name}\"\n\n Gem.activate(name, *version)\n rescue Gem::LoadError\n log \"activating #{name} failed, try to install\"\n\n install_gem(name, version, options)\n end",
"def install(gem)\n version = gem['version'] == '> 0' ? '' : \"#{gem['version']} \"\n Utils.message \"\\n\"\n if preinstalled?(gem)\n Utils.message \"-----> Skipping #{gem['name']} #{version} - this gem is installed by default on Heroku\\n\"\n else\n proxy = Utils.slot =~ /codex/ ? \"--http-proxy http://localhost:3128\" : \"\"\n command = [\n \"export PATH=#{@slug.ruby_path};\",\n \"export GEM_HOME=#{@slug.gems_build_dir};\",\n \"gem install\",\n escape(gem['name']),\n proxy,\n \"--no-ri\",\n \"--no-rdoc\",\n \"--version=#{escape(gem['version'])}\",\n gem['source'].map {|s| \"-s #{escape(s)}\"}.join(\" \"),\n (\"--ignore-dependencies\" if gem[\"ignore-dependencies\"])\n ].compact.join(\" \")\n Utils.message \"-----> Installing gem #{gem['name']} #{version}from #{gem['source'].join(\", \")}#{\" and ignoring dependencies\" if gem['ignore-dependencies']}\\n\"\n exec_gem_install_command(command)\n end\n end",
"def gem_version; end",
"def gem_version; end",
"def gem_version; end",
"def gem_version; end",
"def gem_version; end",
"def gem_version; end",
"def vendor_dependencies\n fetch_bundler\n bundle_install\n end",
"def activate_managed_gems_for_plugin(plugin_gem_name, version_constraint = \"> 0\")\n # TODO: enforce first-level version pinning\n plugin_deps = [Gem::Dependency.new(plugin_gem_name.to_s, version_constraint)]\n managed_gem_set = Gem::Resolver::VendorSet.new\n list_managed_gems.each { |spec| managed_gem_set.add_vendor_gem(spec.name, spec.gem_dir) }\n\n # TODO: Next two lines merge our managed gems with the other gems available\n # in our \"local universe\" - which may be the system, or it could be in a Bundler microcosm,\n # or rbenv, etc. Do we want to merge that, though?\n distrib_gem_set = Gem::Resolver::CurrentSet.new\n installed_gem_set = Gem::Resolver.compose_sets(managed_gem_set, distrib_gem_set)\n\n # So, given what we need, and what we have available, what activations are needed?\n resolver = Gem::Resolver.new(plugin_deps, installed_gem_set)\n begin\n solution = resolver.resolve\n rescue Gem::UnsatisfiableDependencyError => gem_ex\n # If you broke your install, or downgraded to a plugin with a bad gemspec, you could get here.\n ex = Inspec::Plugin::V2::LoadError.new(gem_ex.message)\n raise ex\n end\n solution.each do |activation_request|\n next if activation_request.full_spec.activated?\n\n activation_request.full_spec.activate\n # TODO: If we are under Bundler, inform it that we loaded a gem\n end\n end",
"def gem_version\n ::Gem::Version.new(VERSION::STRING)\n end",
"def db_drivers_install\n include_recipe('python::pip')\n case db_uri.scheme\n when 'mysql'\n python_pip \"#{new_resource.name} :install mysql-python\" do\n package_name 'mysql-python'\n virtualenv \"#{home}/.venv\"\n action :install\n end\n end\n end",
"def extra_gem_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_requirements - gem_reqs\n end",
"def extra_gem_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_requirements - gem_reqs\n end",
"def setup_gem(name, options)\n version = [options[:version]].compact\n lib_name = options[:lib] || name\n\n log \"activating #{name}\"\n\n Gem.activate(name, *version)\n require(lib_name)\n\n rescue LoadError\n\n install_gem(name, options)\n Gem.activate(name, *version)\n require(lib_name)\n end",
"def version_required(gem_def)\n return Gem::Dependency.instance_methods.map(&:to_sym).include?(:requirement) ? gem_def.requirement : gem_def.version_requirements\nend",
"def set_gem_version_and_file line, file, line_num\n if line =~ @gem_name_version\n @tracker.config.add_gem $1, $2, file, line_num\n end\n end",
"def gem(gem_name, *version_requirements)\n if gem_name =='i18n'\n puts \"skipping loading the i18n gem ...\"\n return\n end\n super(gem_name, *version_requirements)\nend",
"def has_gem(name, version = nil)\n version = version ? \"--version '#{version}'\" : '' \n @commands << \"gem list '#{name}' --installed #{version} > /dev/null\"\n end",
"def add_gem_names\n add_gem_names_mutex = get_mutex 'add_gem_names'\n\n add_gem_names_mutex.synchronize do\n break unless @gem_name_queue.empty?\n\n get_gem_names.each do |name|\n @gem_name_queue.enq name\n end\n end\n end",
"def add_gems\n gem 'data-confirm-modal', '~> 1.6.2'\n gem 'devise', '~> 4.4.3'\n gem 'devise-bootstrapped', github: 'excid3/devise-bootstrapped', branch: 'bootstrap4'\n gem 'devise_masquerade', '~> 0.6.0'\n gem 'font-awesome-sass', '~> 4.7'\n gem 'gravatar_image_tag', github: 'mdeering/gravatar_image_tag'\n gem 'jquery-rails', '~> 4.3.1'\n gem 'bootstrap', '~> 4.0.0.beta'\n gem 'webpacker', '~> 3.0'\n gem 'foreman', '~> 0.84.0'\n gem_group :development, :test do\n gem 'rspec-rails', '~> 3.6.0'\n gem \"factory_bot_rails\", \"~> 4.10.0\"\n gem 'spring-commands-rspec'\n end\n\n gem_group :test do\n gem 'shoulda-matchers', '~> 3.1'\n end\nend",
"def gems; end",
"def gems; end",
"def gems; end",
"def gem name, *requirements\n options = Hash === requirements.last ? requirements.pop : {}\n\n requirement = requirements.empty? ?\n Gem::Requirement.default :\n Gem::Requirement.new(requirements)\n\n entry = Entry.new name, requirement, @environments.dup, options\n\n @entries << entry\n entry\n end",
"def gem_requires(name, options) # :nodoc:\n if options.include? :require\n if requires = options.delete(:require)\n @requires[name].concat Array requires\n end\n else\n @requires[name] << name\n end\n raise ArgumentError, \"Unhandled gem options #{options.inspect}\" unless options.empty?\n end",
"def gem(name, args = {})\n add_command(:gem, name, args)\n end",
"def gemfile; end",
"def gemfile; end",
"def gemfile; end",
"def gemfile; end",
"def gemfile; end",
"def gemfile; end",
"def install_gem(gemname)\n if !Gem::Specification::find_all_by_name(gemname).any?\n gemfile(true) do\n source 'https://rubygems.org'\n gem gemname\n end\n end\n require gemname\nend",
"def install_gem\n Juwelier::Commands::InstallGem.build_for(self).run\n end",
"def add_gems\n gem 'sorbet-rails', path: '../../../.'\n\n sorbet_version = ENV[\"SORBET_VERSION\"]\n if sorbet_version\n # mostly used to test against a stable version of Sorbet in Travis.\n gem 'sorbet', sorbet_version\n gem 'sorbet-runtime', sorbet_version\n else\n # prefer to test against latest version because sorbet is updated frequently\n gem 'sorbet'\n gem 'sorbet-runtime'\n end\nend",
"def append_to_gem_group(gem_group_definition, new_line)\n append_to_block_in_file \"Gemfile\", new_line, gem_group_definition, \"end\"\nend",
"def install_gem(gem_name, options = {})\n if options[:group]\n gem gem_name, group: options[:group]\n else\n gem gem_name\n end\n run_command \"gem install #{gem_name}\"\n run_command 'bundle install --local'\nend",
"def gem_available?(name)\n Gem::Specification.find_by_name(name)\nrescue Gem::LoadError\n puts \"[*] - esearchy requires #{name}.\"\n if RUBY_PLATFORM =~ /mingw|mswin/\n \tsystem \"gem install #{name}\"\n else\n \tsystem \"sudo gem install #{name}\"\n end\nend",
"def get_db_gem(path_to_gemfilelock = gemfilelock_filepath)\n gemfilelock = File.open(path_to_gemfilelock).read\n p = Bundler::LockfileParser.new(gemfilelock)\n \n found_supported_db_gems = []\n found_unsupported_db_gems = []\n \n p.dependencies.each do |dependency|\n found_supported_db_gems << dependency if SUPPORTED_DATABASE_GEMS.include?(dependency.name)\n found_unsupported_db_gems << dependency if UNSUPPORTED_DATABASE_GEMS.include?(dependency.name)\n end\n \n unless found_unsupported_db_gems.empty? then\n puts \"Attention:\\nYour Gemfile.lock tells me that you are using at least one unsupported database gem:\\n\\n\"\n puts found_unsupported_db_gems.map {|g| \"* #{g.name}\"}.join(\"\\n\")\n puts \"\\n\"\n end\n\n if found_supported_db_gems.size == 1 then\n puts \"Everything is fine. You are using: #{found_supported_db_gems.first.name}\"\n\n elsif found_supported_db_gems.size > 1 then\n puts \"You are using more than one supported database gem. Hence I cannot uniquely identify the gem your app depends on. Please change your Gemfile and perform bundle update to update your Gemfile.lock file.\" \n raise(\"Abortet. Ambigious database gem information.\")\n else\n raise('Abortet. Please update your Gemfile to with \"gem mysql\" or \"gem mysql2\" and run \"bundle update\" to update your Gemfile.lock.')\n end\n found_supported_db_gems.first\n end",
"def patch_gem(gem, from_version, to_version)\n from_version = from_version.is_a?(Array) ? from_version : [from_version]\n desc \"Update the version of the #{gem} gem from #{from_version.inspect} to #{to_version}\"\n command(:\"patch_#{gem}_gem\") do |app|\n patch_gemfile(\"Update the version of the #{gem} gem to #{to_version}.\") do |content|\n from_version.each do |v|\n content = content.gsub(\"gem '#{gem}', '= #{v}'\", \"gem '#{gem}', '= #{to_version}'\")\n end\n content\n end\n end\n end",
"def install\r\n super\r\n automated_install {\r\n @local_gems.flush_gem_cache\r\n gem_name = @override_gem_name.nil? ? installed_as_name_for( self.gem_short_name ) : @override_gem_name\r\n installed_gem = @local_gems.find( gem_name )\r\n fails_to_load gem_name if installed_gem.nil?\r\n installed_gem.activate\r\n }\r\n end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def activate(name, *requirements)\n Gems.synchronize do\n begin\n gem(name, *requirements)\n rescue ::Gem::LoadError => e\n handle_activation_error(e, name, requirements)\n end\n end\n end",
"def extra_gem_build_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_build_requirements - gem_reqs\n end",
"def extra_gem_build_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_build_requirements - gem_reqs\n end",
"def load_gem(name, version=nil)\n # needed if your ruby version is less than 1.9\n require 'rubygems'\n\n begin\n gem name, version\n rescue LoadError\n version = \"--version '#{version}'\" unless version.nil?\n system(\"gem install #{name} #{version}\")\n Gem.clear_paths\n retry\n end\n\n require name\nend",
"def load_gem(name, version=nil)\n # needed if your ruby version is less than 1.9\n require 'rubygems'\n\n begin\n gem name, version\n rescue LoadError\n version = \"--version '#{version}'\" unless version.nil?\n system(\"gem install #{name} #{version}\")\n Gem.clear_paths\n retry\n end\n\n require name\nend",
"def load_gem(name, version=nil)\n # needed if your ruby version is less than 1.9\n require 'rubygems'\n\n begin\n gem name, version\n rescue LoadError\n version = \"--version '#{version}'\" unless version.nil?\n system(\"gem install #{name} #{version}\")\n Gem.clear_paths\n retry\n end\n\n require name\nend",
"def add_specs(*gem_specs); end",
"def gem_version_more?(name, version)\n Gem.loaded_specs[name].version >= Gem::Version.new(version)\n end",
"def gem_version(version)\n Gem::Version.create(version)\n end",
"def rails_3\n defined?(ActiveRecord::VERSION) && ActiveRecord::VERSION::MAJOR >= 3\nend",
"def has_gem(name, version=nil)\n version = version.nil? ? '' : version.gsub('.', '\\.')\n @commands << \"sudo gem list | grep -e '^#{name} (.*#{version}.*)$'\"\n end",
"def updated_gemfile_requirement(req)\n return req unless latest_resolvable_version\n return req if existing_version && no_change_in_version?\n return req if !existing_version && new_version_satisfies?(req)\n\n requirements =\n req[:requirement].split(\",\").map { |r| Gem::Requirement.new(r) }\n\n new_req =\n if requirements.any?(&:exact?)\n \"= #{latest_resolvable_version}\"\n elsif requirements.any? { |r| r.to_s.start_with?(\"~>\") }\n tw_req = requirements.find { |r| r.to_s.start_with?(\"~>\") }\n update_twiddle_version(tw_req, latest_resolvable_version).to_s\n else\n update_gemfile_range(requirements).map(&:to_s).join(\", \")\n end\n\n req.merge(requirement: new_req)\n end",
"def install_gem(name, version, options)\n installer = Gem::DependencyInstaller.new(options)\n\n temp_argv(options[:extconf]) do\n log \"installing #{name}\"\n installer.install(name, *version)\n end\n\n Gem.activate(name, *version)\n\n log \"install and final activation successful\"\n rescue Gem::GemNotFoundException => ex\n log \"installation failed: #{ex}, use normal require\"\n\n require(options[:lib] || name)\n\n log \"require successful, cannot verify version though\"\n end",
"def load_gem_plugins; end",
"def add(gemspec)\n @specs << gemspec\n end",
"def util_bake_gem(name = \"a\", *extra, &block)\n files = [\"lib/#{name}.rb\"].concat(extra)\n\n spec = if Gem::VERSION >= \"3.0.0\"\n util_spec name, \"1\", nil, files, &block\n else\n new_spec name, \"1\", nil, files, &block\n end\n\n util_build_gem spec\n\n spec.cache_file\n end",
"def requirements_for_gem(gem_name)\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| r.gem_name == gem_name }\n end",
"def gem name, *requirements\n entry = entries.find { |e| e.name == name }\n return entry.update(*requirements) if entry\n\n entries << entry = Entry.new(self, name, *requirements)\n entry\n end",
"def carrega_gem(nome, versao = nil)\n begin\n gem nome, versao\n rescue LoadError\n puts \"Instalando gem '#{nome}'...\"\n versao = \"-- version '#{versao}'\" unless versao.nil?\n system \"gem install #{nome} #{versao}\"\n Gem.clear_paths\n retry\n end\n\n require nome\nend",
"def add_gem_versions(line)\n @name, version_string = line.split(/\\s/,2)\n @versions = version_string[1..-2].split(/,\\s/)\n end",
"def util_bake_gem(name = \"a\", *extra, &block)\n files = [\"lib/#{name}.rb\"].concat(extra)\n\n spec = new_spec name, \"1\", nil, files, &block\n\n File.join @tempdir, \"gems\", \"#{spec.full_name}.gem\"\n end",
"def gemspec?; end"
] | [
"0.6080091",
"0.59166825",
"0.5808521",
"0.5752241",
"0.5741924",
"0.57120377",
"0.5498059",
"0.5481172",
"0.5466027",
"0.5450201",
"0.5450201",
"0.544846",
"0.54423153",
"0.5436339",
"0.5412091",
"0.54072344",
"0.53560114",
"0.5349064",
"0.5325636",
"0.53213996",
"0.53133416",
"0.5304856",
"0.52974355",
"0.52660525",
"0.5251453",
"0.5234634",
"0.51816976",
"0.51815003",
"0.5171748",
"0.514671",
"0.51403713",
"0.51403713",
"0.51403713",
"0.51403713",
"0.51403713",
"0.51403713",
"0.50907654",
"0.5061385",
"0.5043948",
"0.50285625",
"0.5019859",
"0.5019859",
"0.5016399",
"0.50127184",
"0.50090605",
"0.5005945",
"0.49975047",
"0.49925944",
"0.49888542",
"0.49865168",
"0.49865168",
"0.49865168",
"0.49834776",
"0.49702016",
"0.4954064",
"0.49520433",
"0.49520433",
"0.49520433",
"0.49520433",
"0.49520433",
"0.49520433",
"0.49372002",
"0.4936754",
"0.4917873",
"0.49091458",
"0.49026832",
"0.48979375",
"0.4891847",
"0.48890394",
"0.48707703",
"0.4869169",
"0.4869169",
"0.4869169",
"0.4869169",
"0.4869169",
"0.4869169",
"0.4869169",
"0.4869169",
"0.48605525",
"0.48578677",
"0.48578677",
"0.4852384",
"0.4852384",
"0.4852384",
"0.48477775",
"0.4846633",
"0.48330092",
"0.48310524",
"0.48298004",
"0.48260775",
"0.4815494",
"0.48143917",
"0.48043236",
"0.47933048",
"0.4791238",
"0.47906405",
"0.47905484",
"0.47865406",
"0.47713584",
"0.47702396"
] | 0.53928715 | 16 |
Checks if all required gems are installed and returns gems that miss. | def check_gems
@gems ||= {}
@gems.keys.select { |g| Gem.source_index.find_name(g, @gems[g]).size == 0 }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dep_check\n $gems_required.each do |current_gem|\n begin\n if current_gem.include? \",\"\n tokens = current_gem.split(\",\")\n gem tokens[0], tokens[1]\n else\n gem current_gem\n end\n rescue Gem::LoadError\n if current_gem.include? \",\"\n $gems_missing_version << current_gem\n else\n $gems_missing << current_gem\n end\n end\n end\n if $gems_missing.length == 0 && $gems_missing_version.length == 0\n return true\n else\n return false\n end\nend",
"def check_all_gems(gem_path)\n gems_not_installed = []\n Constants::GEMS.each do |gem|\n string = \"Looking for Gem \\\"#{gem}\\\"...\"\n installed = check_gem gem, gem_path\n installed ? string << green(\"Found\") : string << red(\"Not Found\")\n log_print string\n if !installed\n #if not installed append gem name to gems_not_installed list\n gems_not_installed << gem\n end #if\n end # do\n \n gems_not_installed\n end",
"def install_gems\n puts \"[Checking for missing required gems]\"\n while (gemspecs = get_requirements).any?\n gemspecs.each do |gemspec|\n install_gem(gemspec)\n end\n end\n end",
"def non_gem_requirements\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| !r.gem? }\n end",
"def packages_missing_candidates\n @packages_missing_candidates ||=\n begin\n missing = []\n each_package do |package_name, new_version, current_version, candidate_version, magic_version|\n missing.push(package_name) if magic_version.nil? && candidate_version.nil?\n end\n missing\n end\n end",
"def forced_packages_missing_candidates\n @forced_packages_missing_candidates ||=\n begin\n missing = []\n each_package do |package_name, new_version, current_version, candidate_version, magic_version|\n next if new_version.nil? || current_version.nil?\n\n if use_magic_version?\n if !magic_version && candidate_version.nil?\n missing.push(package_name)\n end\n else\n if !version_requirement_satisfied?(current_version, new_version) && candidate_version.nil?\n missing.push(package_name)\n end\n end\n end\n missing\n end\n end",
"def candidates_exist_for_all_uninstalled?\n packages_missing_candidates.empty?\n end",
"def non_gem_build_requirements\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| !r.gem? }\n end",
"def missing_deps_for(gem)\n # Comparison by name here assuming if it is in existing spec,\n # spec author will have ensured versions are correct for their purposes\n gem.deps.select { |dep| requirements_for_gem(dep.name).empty? }\n end",
"def check_all_packages\n packages_not_installed = []\n Constants::PACKAGES.each do |pkg|\n string = \"Looking for package #{pkg}...\"\n installed = check_package(pkg)\n installed ? string << green(\"Found\") : string << red(\"Not Found\")\n log_print string\n if !installed\n #if not installed append package name to packages_not_installed list\n packages_not_installed << pkg\n end #if\n end #do\n \n packages_not_installed\n end",
"def required_gem_list\n Mack::Utils::GemManager.instance.required_gem_list\n end",
"def check_for_gems\n\n OPTIONAL_GEMS.each do |gem_name|\n method_name = \"has_#{gem_name.underline}?\".to_sym\n\n (class << self; self; end).class_eval do\n instance_variable_name = \"@has_#{gem_name.underline}\".to_sym\n\n define_method method_name do\n if instance_variable_get(instance_variable_name).nil?\n gem_installed = SystemChecks.gem_available?(gem_name)\n instance_variable_set(instance_variable_name, gem_installed)\n end\n instance_variable_get(instance_variable_name)\n end # define_method\n\n end # class_eval\n\n end # OPTIONAL_GEMS\n end",
"def gem_requirements\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| r.gem? }\n end",
"def installed?(gem_name)\n !run('list', '|', 'grep', \"' #{gem_name} '\").empty?\n end",
"def missing_dev_deps_for(gem)\n # Same note as in #missing_deps_for above\n gem.dev_deps.select { |dep| build_requirements_for_gem(dep.name).empty? }\n end",
"def check_gem # --- CHECK FOR MISSING GEMS\n begin\n\t gem 'em-websocket'\n rescue Gem::LoadError\n\t puts \"IT APPEARS YOU ARE MISSING THE SOCKET GEM\"\n puts \"TO INSTALL IT TYPE 'gem install em-websocket'\"\n\telse\n\t\t#donothing\n\tend\n\n\tbegin\n\t\tgem 'net-ping', '>=1.7.8'\n\trescue Gem::LoadError\n\t\tputs \"IT APPEARS THAT YOU ARE MISSING THE NET-PING GEM\"\n puts \"TO INSTALL IT TYPE 'gem install net-ping'\"\n\telse\n\t\t#donothing\n\tend\nend",
"def get_requirements\n result = `rake gems 2>&1`\n parse_required(result) + parse_missing(result) + parse_deps(result)\n end",
"def ensure_gem_versions_defined_in_appraisal_are_used\n gems_defined_in_appraisal = retrieve_gems_from_gemfile(ENV['BUNDLE_GEMFILE'])\n gems_defined_in_gemfile = retrieve_gems_from_gemfile('Gemfile').collect(&:gem_name)\n\n gems_defined_in_appraisal.reject { |l| gems_defined_in_gemfile.include? l.gem_name }.each do |gem|\n add_gem gem.gem_name, gem.attributes.join(',')\n end\n end",
"def find_redundant_gems_with_gem(args = {})\n gems = args[:gems] || @gems\n gems_with_deps = {}\n gems.each do |gem|\n output, status = Open3.capture2e(\"gem dependency #{gem}\")\n next unless status.success?\n deps = output.split(\"\\n\").map(&:strip)\n deps = deps.reject { |g| g.include? ', development' or g.include? 'Gem ' }\n deps = deps.map { |x| x.gsub(/\\s\\(.+\\)/, '') }\n gems_with_deps[gem] = deps\n end\n redundant_gems = []\n gems_with_deps.keys.each do |gem|\n next if gems_with_deps[gem].empty?\n gems_with_deps[gem].each do |g|\n redundant_gems << g if gems_with_deps.keys.include?(g)\n end\n end\n redundant_gems.uniq.each { |gem| @redundant_gems << gem unless @redundant_gems.include?(gem) }\n @redundant_gems\n end",
"def installed_gems\n gems = []\n\n cmd = [attributes.gem_binary, 'list', '-l']\n cmd << '--prerelease' if attributes.prerelease\n\n run_command(cmd).stdout.each_line do |line|\n next unless /\\A([^ ]+) \\(([^\\)]+)\\)\\z/ =~ line.strip\n\n name = $1\n versions = $2.split(', ')\n gems << { name: name, versions: versions }\n end\n gems\n rescue Backend::CommandExecutionError\n []\n end",
"def requirements_for_gem(gem_name)\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| r.gem_name == gem_name }\n end",
"def load_dependencies\r\n @local_gems.each do |gem_info|\r\n gem_file_name = gem_info.gem_file\r\n gem_name = installed_as_name_for( short_form_of_gem_name( gem_file_name ) )\r\n @required_gem_names.delete gem_file_name\r\n end\r\n @required_gem_paths.each do |gem_path|\r\n gem_short_name = short_form_of_gem_name gem_path\r\n if @required_gem_names.include? gem_short_name\r\n puts \"installing #{gem_path}\"\r\n installer = @force_require ? PreloadingInstaller.new( gem_path, @local_gems ) : Installer.new( gem_path )\r\n installer.install\r\n end\r\n end\r\n end",
"def gem_build_requirements\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| r.gem? }\n end",
"def default_gems() \n puts \"Gems found in default gem install location:\"\n gems_in_default = self.each_value.find_all do |gce|\n gce.gemsets_containing.include? 'default'\n end\n end",
"def missing_files_for(gem)\n # we check for files in the gem for which there are no spec files\n # corresponding to gem file or directory which it resides in\n gem.file_paths.select { |gem_file| missing_gem_file?(gem_file) }\n end",
"def extra_gem_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_requirements - gem_reqs\n end",
"def extra_gem_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_requirements - gem_reqs\n end",
"def check_for_installed_software_only\n check_all_installed @options\n end",
"def gem_available?(name)\n Gem::Specification.find_by_name(name)\nrescue Gem::LoadError\n puts \"[*] - esearchy requires #{name}.\"\n if RUBY_PLATFORM =~ /mingw|mswin/\n \tsystem \"gem install #{name}\"\n else\n \tsystem \"sudo gem install #{name}\"\n end\nend",
"def required_gems\n relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir))\n [\n \"gem 'react_on_rails', path: '#{relative_gem_root}'\",\n \"gem 'shakapacker'\"\n ]\n end",
"def installed_plugins(required_plugins)\n required_plugins.reduce([]) do |missing, plugin|\n if Vagrant.has_plugin?(plugin)\n missing\n else\n puts \"#{plugin} plugin is missing. Installing...\"\n %x(set -x; vagrant plugin install #{plugin})\n missing << plugin\n end\n end\nend",
"def gem_installed?(gem_name)\n found_gem = false\n begin\n found_gem = Gem::Specification.find_by_name(gem_name)\n rescue Gem::LoadError\n return false \n else\n return true \n end\nend",
"def dependent_gems(check_dev=true)\n out = []\n Gem::Specification.each do |spec|\n deps = check_dev ? spec.dependencies : spec.runtime_dependencies\n deps.each do |dep|\n if self.satisfies_requirement?(dep)\n sats = []\n find_all_satisfiers(dep) do |sat|\n sats << sat\n end\n out << [spec, dep, sats]\n end\n end\n end\n out\n end",
"def extra_gem_build_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_build_requirements - gem_reqs\n end",
"def extra_gem_build_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_build_requirements - gem_reqs\n end",
"def gemspecs\n return [] if directory.empty? || directory == '*'\n @gemspecs ||= Dir[File.join(directory, '**/*.gemspec')].select do |gs|\n config.allow? gs\n end\n end",
"def gem_installed?(gem_name)\n !Gem::Specification.find_by_name(gem_name).nil?\n rescue Gem::LoadError\n false\n end",
"def required_if_used(*args)\n unless @required_gems\n [:included, :extended, :inherited].each do |method_name|\n define_method(method_name) do |klass|\n super if defined?(super)\n @required_gems.each { |gem| require gem.to_s }\n end\n end\n end\n @required_gems ||= []\n @required_gems |= args\n end",
"def desired_gems(list_of_gems)\n specified_gems = []\n list_of_gems.each do |g| \n if self.has_key? g\n specified_gems << self[g]\n else\n specified_gems << \"'#{g}' not found in any gemset\"\n end\n end\n\n specified_gems\n end",
"def installed_versions(name, requirement)\n if gem_installed?(name, requirement)\n Chef::Log.info \"Gem #{name} (#{requirement}) found in OpsWorks user space.\"\n # from rubygems/specification.rb#find_all_by_name\n Gem::Dependency.new(name, requirement).matching_specs\n else\n Chef::Log.debug \"Gem #{name} (#{requirement}) not found in OpsWorks user space.\"\n []\n end\n end",
"def requires\n require_items.collect(&:package)\n end",
"def gem_if_necessary(gem)\n grep = args = nil\n if gem =~ /(.*)-(\\d+\\.\\d+\\.\\d+)$/\n gem, version = $1, $2\n grep = \"^#{gem}.*#{version}\"\n args = \" --version #{version}\"\n else\n grep = \"^#{gem}\"\n end\n if fails?(\"gem list #{gem} | grep '#{grep}'\")\n banner \"#{gem}...\"\n run \"gem install #{gem} #{args} --no-rdoc --no-ri\"\n return true\n end\n false\n end",
"def has_all_requirements_for?(gem_dep)\n reqs = self.requirements_for_gem gem_dep.name\n # create a spec requirement dependency for each expanded subrequirement,\n # verify we can find a match for that\n gem_dep.requirement.to_s.split(',').all? { |greq|\n Gem2Rpm::Helpers.expand_requirement([greq.split]).all? { |ereq|\n tereq = Requirement.new :name => \"#{requirement_prefix}(#{gem_dep.name})\",\n :condition => ereq.first,\n :version => ereq.last.to_s\n reqs.any? { |req| req.matches?(tereq)}\n }\n }\n end",
"def verify_pods_are_installed!\n lockfile_roots = config.lockfile.pod_names.map { |p| Specification.root_name(p) }\n missing_pods = @pods.map { |p| Specification.root_name(p) }.select do |pod|\n !lockfile_roots.include?(pod)\n end\n\n unless missing_pods.empty?\n message = if missing_pods.length > 1\n \"Pods `#{missing_pods.join('`, `')}` are not \" \\\n 'installed and cannot be updated'\n else\n \"The `#{missing_pods.first}` Pod is not installed \" \\\n 'and cannot be updated'\n end\n raise Informative, message\n end\n end",
"def gem_available?(name)\n Gem::Specification.find_by_name(name)\nrescue Gem::LoadError\n false\nend",
"def require_gems\n Jekyll::External.require_with_graceful_fail(\n site.gems.select { |plugin| plugin_allowed?(plugin) }\n )\n end",
"def gem_available_old_rubygems?(gemname)\n\tGem.available?(gemname)\nend",
"def prepare_gems(gems=GEMS)\n FileUtils.cd(@gems_dir) do\n listing = `gem list --local`\n missing = gems.reject{|package| listing.match(/^#{package}\\s/)}\n run \"gem install #{missing.join(' ')} --no-ri --no-rdoc\", true if missing.size > 0\n end\n end",
"def incomplete_install?\n builtin_module_list = %w[aggregate canary puppetdb_fact secure_env_vars puppet_connect]\n (Dir.children(Bolt::Config::Modulepath::MODULES_PATH) - builtin_module_list).empty?\n end",
"def gem_installed?(gem_name)\n list = `gem list #{gem_name}`\n list.split(\"\\n\").any? { |line| line.include?(gem_name) }\nend",
"def install_gems(gems)\n missing = [ ]\n\n blessed_gems_dir = File.join(@cache_base_dir, \"blessed_gems\")\n FileUtils.mkdir_p(blessed_gems_dir)\n\n gems.each do |(name, version)|\n gem_filename = \"%s-%s.gem\" % [ name, version ]\n\n user_gem_path = File.join(@app_dir, \"vendor\", \"cache\", gem_filename)\n blessed_gem_path = File.join(blessed_gems_dir, gem_filename)\n\n if File.exists?(user_gem_path)\n installed_gem_path = @cache.get(user_gem_path)\n unless installed_gem_path\n @logger.debug \"Installing user gem: #{user_gem_path}\"\n tmp_gem_dir = install_gem(user_gem_path)\n installed_gem_path = @cache.put(user_gem_path, tmp_gem_dir)\n end\n @logger.info \"Adding #{gem_filename} to app...\"\n copy_gem_to_app(installed_gem_path)\n\n elsif File.exists?(blessed_gem_path)\n installed_gem_path = @cache.get(blessed_gem_path)\n unless installed_gem_path\n @logger.debug \"Installing blessed gem: #{blessed_gem_path}\"\n tmp_gem_dir = install_gem(blessed_gem_path)\n installed_gem_path = @cache.put(blessed_gem_path, tmp_gem_dir)\n end\n @logger.info \"Adding #{gem_filename} to app...\"\n copy_gem_to_app(installed_gem_path)\n\n else\n missing << [ name, version ]\n end\n end\n\n Dir.mktmpdir do |tmp_dir|\n fetch_gems(missing, tmp_dir)\n\n missing.each do |(name, version)|\n gem_filename = \"%s-%s.gem\" % [ name, version ]\n gem_path = File.join(tmp_dir, gem_filename)\n\n @logger.debug \"Installing downloaded gem: #{gem_path}\"\n tmp_gem_dir = install_gem(gem_path)\n installed_gem_path = @cache.put(gem_path, tmp_gem_dir)\n output = `cp -n #{gem_path} #{blessed_gems_dir} 2>&1`\n if $?.exitstatus != 0\n @logger.debug \"Failed adding #{gem_path} to #{blessed_gems_dir}: #{output}\"\n end\n @logger.info \"Adding #{gem_filename} to app...\"\n\n copy_gem_to_app(installed_gem_path)\n end\n end\n end",
"def gems(*args)\n gems.each{|g| gem(g) }\n end",
"def gem_available?(name)\n Gem::Specification.find_by_name(name)\nrescue Gem::LoadError\n false\nrescue\n Gem.available?(name) #for backwards compatibility\nend",
"def optimized_gems\n optimized_gems = @gems.reject { |gem| @redundant_gems.include? gem }\n optimized_gems.empty? ? false : optimized_gems.uniq.sort\n end",
"def runtime_specific_gems\n []\n end",
"def find_all_satisfiers(dep)\n Gem::Specification.each do |spec|\n yield spec if spec.satisfies_requirement? dep\n end\n end",
"def find_all(req)\n res = []\n\n dep = req.dependency\n\n return res if @ignore_dependencies and\n @always_install.none? {|spec| dep.match? spec }\n\n name = dep.name\n\n dep.matching_specs.each do |gemspec|\n next if @always_install.any? {|spec| spec.name == gemspec.name }\n\n res << Gem::Resolver::InstalledSpecification.new(self, gemspec)\n end unless @ignore_installed\n\n if consider_local?\n matching_local = @local.values.select do |spec, _|\n req.match? spec\n end.map do |spec, source|\n Gem::Resolver::LocalSpecification.new self, spec, source\n end\n\n res.concat matching_local\n\n begin\n if local_spec = @local_source.find_gem(name, dep.requirement)\n res << Gem::Resolver::IndexSpecification.new(\n self, local_spec.name, local_spec.version,\n @local_source, local_spec.platform)\n end\n rescue Gem::Package::FormatError\n # ignore\n end\n end\n\n res.delete_if do |spec|\n spec.version.prerelease? and not dep.prerelease?\n end\n\n res.concat @remote_set.find_all req if consider_remote?\n\n res\n end",
"def parse_required(input)\n gemspecs = []\n input.split(\"\\n\").grep(/^no such file to load -- (.+)\\s*$/) do |line|\n gemspecs << {:name => $1.strip}\n end\n gemspecs\n end",
"def load(needs = {})\n needs = needs.merge({\"zergrush\" => INCLUDE})\n \n Gem::Specification.each { |gem|\n # don't load gems more than once\n next if @gems.has_key? gem.name \n check = needs.dup\n\n # rolls through the depends and inverts anything it finds\n gem.dependencies.each do |dep|\n # this will fail if a gem is depended more than once\n if check.has_key? dep.name\n check[dep.name] = !check[dep.name]\n end\n end\n \n # now since excluded gems start as true, inverting them\n # makes them false so we'll skip this gem if any excludes are found\n if (check.select {|name,test| !test}).length == 0\n # looks like no needs were set to false, so it's good\n if gem.metadata[\"zergrushplugin\"] != nil\n require File.join(gem.gem_dir, \"lib\", gem.name, \"init.rb\")\n @gems[gem.name] = gem.gem_dir\n end\n end\n }\n \n return nil\n end",
"def RunSCRSwitchTest_DoNeededRPMsCheck\n ret = true\n\n # check whether all needed packages are installed\n Builtins.foreach(Builtins.sort(@needed_rpm_packages)) do |package_name|\n # Test progress\n ReportProgress(\n Builtins.sformat(\n _(\"Running complex check on package %1...\"),\n package_name\n )\n )\n # is the package installed?\n if !RunSCRSwitchTest_CheckWhetherInstalled(package_name)\n ret = false\n raise Break\n # if it is installed, check whetheris has all dependencies\n elsif !RunSCRSwitchTest_DoNeededRPMsRequire(package_name)\n ret = false\n raise Break\n end\n end\n\n ret\n end",
"def ensure_gem_installed(g)\n unless Gem.available? g\n run \"sudo gem install #{g}\"\n end\nend",
"def extra_gem_files(gem = nil)\n gem ||= upstream_gem\n pkg_extra = {}\n pkg_files.each do |pkg, files|\n extra = files.select { |spec_file| !gem.has_file_satisfied_by?(spec_file) }\n pkg_extra[pkg] = extra unless extra.empty?\n end\n pkg_extra\n end",
"def gemset_empty\n run(\"echo 'yes' | rvm\", :gemset, :empty).successful?\n end",
"def build_requirements_for_gem(gem_name)\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| r.gem_name == gem_name }\n end",
"def verify_required_files\n required = REQUIRED_FILES.map{ |f| [f, false] }.to_h\n\n each_zip_entry do |entry|\n if required.key? entry.name\n required[entry.name] = true\n\n if entry.name == \"mod.hcl\"\n load_manifest entry\n end\n end\n end\n\n REQUIRED_FILES.each do |f|\n if required[f] == false\n raise FoobarMod::Package::FormatError.new \"Missing required file '#{f}'\", @mod\n end\n end\n end",
"def gemspec?\n !gemspecs.empty?\n end",
"def packages\n # don't include go std packages\n # don't include packages under the root project that aren't vendored\n go_list_deps\n .reject { |pkg| go_std_package?(pkg) }\n .reject { |pkg| local_package?(pkg) }\n end",
"def require_without_bundler(*gems)\n unless defined?(::Bundler)\n gems.each { |g| require g }\n return\n end\n Dir.glob(\"#{Gem.path.first}/gems/*\").map { |gem_path| \n gem_name=File.basename(gem_path).gsub(/-(\\d\\.?)+$/,'')\n if gems.include?(gem_name)\n $LOAD_PATH << \"#{gem_path}/lib\"\n require gem_name\n end\n }\nend",
"def getMissingDeps(iDepsToResolve, iPossibleContextModifiers, ioAppliedContextModifiers)\n rMissingDeps = []\n\n # We might have some install environments to try\n iDepsToResolve.each do |iDepDesc|\n lDepID = iDepDesc.ID\n lCMListsToTry = iPossibleContextModifiers[lDepID]\n lDepResolved = false\n if (lCMListsToTry != nil)\n # We can try several ones. We want at least 1 of those sets to resolve the dependency.\n lCMListsToTry.each do |iCMSetToTry|\n # Try to add the locations to the context\n lAppliedCMs = []\n iCMSetToTry.each do |iContextModifierInfo|\n iName, iContent = iContextModifierInfo\n access_plugin('ContextModifiers', iName) do |ioPlugin|\n if (!ioPlugin.is_location_in_context?(iContent))\n # We try this one.\n ioPlugin.add_location_to_context(iContent)\n lAppliedCMs << iContextModifierInfo\n end\n end\n end\n # Now, test if this has resolved the dependency (don't try if nothing changed)\n if (!lAppliedCMs.empty?)\n lDepResolved = test_dependency(iDepDesc)\n # If we found it, it's ok\n if (lDepResolved)\n ioAppliedContextModifiers[iDepDesc.ID] = lAppliedCMs\n break\n else\n # Rollback those context modifications as they were useless\n lAppliedCMs.each do |iContextModifierInfo|\n iName, iContent = iContextModifierInfo\n access_plugin('ContextModifiers', iName) do |ioPlugin|\n ioPlugin.remove_location_from_context(iContent)\n end\n end\n end\n end\n end\n end\n # If none of them resolved the dependency, add the dependency to the missing ones\n if (!lDepResolved)\n rMissingDeps << iDepDesc\n end\n end\n\n return rMissingDeps\n end",
"def excluded_deps\n missing_deps_for(upstream_gem)\n end",
"def install_gems( gems )\n\t\n\tdefaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({\n\t\t:generate_rdoc => true,\n\t\t:generate_ri => true,\n\t\t:install_dir => Gem.dir,\n\t\t:format_executable => false,\n\t\t:test => false,\n\t\t:version => Gem::Requirement.default,\n\t })\n \n\t# Check for root\n\tif Process.euid != 0\n\t\t$stderr.puts \"This probably won't work, as you aren't root, but I'll try anyway\"\n\tend\n\n\tgemindex = Gem::SourceIndex.from_installed_gems\n\n\tgems.each do |gemname, reqstring|\n\t\trequirement = Gem::Requirement.new( reqstring )\n\t\ttrace \"requirement is: %p\" % [ requirement ]\n\t\t\n\t\ttrace \"Searching for an installed #{gemname}...\"\n\t\tspecs = gemindex.find_name( gemname )\n\t\ttrace \"...found %d specs: %s\" %\n\t\t\t[ specs.length, specs.collect {|s| \"%s %s\" % [s.name, s.version] }.join(', ') ]\n\t\t\n\t\tif spec = specs.find {|spec| requirement.satisfied_by?(spec.version) }\n\t\t\tlog \"Version %s of %s is already installed (needs %s); skipping...\" % \n\t\t\t\t[ spec.version, spec.name, requirement ]\n\t\t\tnext\n\t\tend\n\n\t\trgv = Gem::Version.new( Gem::RubyGemsVersion )\n\t\tinstaller = nil\n\t\t\n\t\tlog \"Trying to install #{gemname.inspect} #{requirement}...\"\n\t\tif rgv >= Gem::Version.new( '1.1.1' )\n\t\t\tinstaller = Gem::DependencyInstaller.new\n\t\t\tinstaller.install( gemname, requirement )\n\t\telse\n\t\t\tinstaller = Gem::DependencyInstaller.new( gemname )\n\t\t\tinstaller.install\n\t\tend\n\n\t\tinstaller.installed_gems.each do |spec|\n\t\t\tlog \"Installed: %s\" % [ spec.full_name ]\n\t\tend\n\n\tend\nend",
"def check_gem(gem, gem_path)\n result = `#{gem_path} query --local | grep #{ gem }`\n if result == \"\"\n installed = false\n else\n installed = true\n end #if\n \n installed\n end",
"def gems\n @gems ||=\n Bundler.load.current_dependencies.map do |dependency|\n GemsBond::Gem.new(dependency)\n end\n end",
"def check_binaries\n all_installed = true\n BINARIES.each do |bin|\n if `which #{bin}`.empty?\n all_installed = false\n puts \"#{bin} \"+'[NOT FOUND]'.red\n else\n puts \"#{bin} \"+'[OK]'.green\n end\n end\n\n unless all_installed\n puts 'Install appropriate programs before'\n raise SystemExit\n end\n\nend",
"def deps(pkg) # FIXME: \"*** PACKAGE MAY NOT BE DELETED *** \"\n if pkg.status != :available\n components = `#{@cmd} -n #{pkg.name}`.split(\"Requires:\\n\")\n if components.size > 1\n return components[1].strip\n else\n return \"[No depends]\"\n end\n else\n if File.exist?(File.expand_path(\"~/Library/Application Support/Guigna/pkgsrc/INDEX\"))\n # TODO: parse INDEX\n end\n \"[Not available]\"\n end\n end",
"def all_requires\n []\n end",
"def all_requires\n []\n end",
"def sane_env?( plugin )\n gem_errors = []\n\n plugin.gems.each do |gem|\n begin\n require gem\n rescue LoadError\n gem_errors << gem\n end\n end\n\n return { gem_errors: gem_errors } if !gem_errors.empty?\n true\n end",
"def require_gems; end",
"def failing_modules\n modules.reject {|m| %w(passed softfailed running none).include? m['result']}.map {|m| m['name'] }\n end",
"def find_missing(spec_names)\n spec_names.find_all { |full_name|\n specification(full_name).nil?\n }\n end",
"def gems\n provisioner, version = @impl.split('-')\n get_gem_list(provisioner, version)\n end",
"def common_gems(gemsets) \n common_gems = self.each_value.find_all do |gce| \n gce.in_all_gemsets_but_global? gemsets \n end\n end",
"def installed_files\n Dir.chdir(@spec.gem_dir) { Dir['**/*'].reject {|fp| ::File.directory?(fp) } }\n end",
"def candidates_exist_for_all_forced_changes?\n forced_packages_missing_candidates.empty?\n end",
"def gem_listed?(gem)\n lockfile_specs.map(&:name).include? gem\n end",
"def conflicts\n conflicts = {}\n self.runtime_dependencies.each do |dep|\n spec = Gem.loaded_specs[dep.name]\n if spec and not spec.satisfies_requirement? dep\n (conflicts[spec] ||= []) << dep\n end\n end\n env_req = Gem.env_requirement(name)\n (conflicts[self] ||= []) << env_req unless env_req.satisfied_by? version\n conflicts\n end",
"def append_from_gems\n\t\t\t::Gem.loaded_specs.each do |name, spec|\n\t\t\t\tConsole.logger.debug(self) {\"Checking gem #{name}: #{spec.full_gem_path}...\"}\n\t\t\t\t\n\t\t\t\tif path = spec.full_gem_path and File.directory?(path)\n\t\t\t\t\tappend_path(path, name: spec.full_name)\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def packages_from_require(rpmdep)\n refresh\n @rpmdb.whatprovides(rpmdep)\n end",
"def gem_available?(gemname)\n\t# gem_available_new_rubygems?(gemname) or gem_available_old_rubygems?(gemname)\n\tif defined?(Gem::Specification) and defined?(Gem::Specification.find_by_name)\n\t\tgem_available_new_rubygems?(gemname)\n\telse\n\t\tgem_available_old_rubygems?(gemname)\n\tend\nend",
"def reset_gem_specs!\n return unless Gem.loaded_specs.keys.include?('locomotivecms_wagon')\n\n core_gems = %w(did_you_mean).freeze\n\n Gem.loaded_specs.values.each do |spec|\n next if core_gems.include?(spec.name)\n spec.full_require_paths.each do |path|\n $LOAD_PATH.delete(path)\n end\n\n # Without this statement, bundler will raise the infamous \"You have already activated ...\"\n Gem.loaded_specs.delete(spec.name)\n end\nend",
"def redundant_gems(args = {})\n find_redundant_gems_with_gem(args)\n @count = 0\n @permutation_count = permutations\n @progress_bar = args[:progress_bar] || true\n gems = args[:gems] || @gems\n redundant = args[:redundant_gems] || @redundant_gems\n find_redundant_gems(args).empty? ? false : @redundant_gems\n end",
"def unfulfilled_requirements_for(*fulfillers)\n options = fulfillers.extract_options!\n fulfillers.flatten.inject({}) do |memo, fulfiller|\n unless unfulfilled_requirements(options[:framework])[ fulfiller ].blank?\n memo[ fulfiller ] = unfulfilled_requirements(options[:framework])[ fulfiller ]\n end\n memo\n end\n end",
"def test_bad_rubinius_deps\n check_deps_fail BadRubiniusBall unless `/usr/bin/which rbx`.chomp.empty?\n end",
"def has_conflicts?\n return true unless Gem.env_requirement(name).satisfied_by?(version)\n self.dependencies.any? do |dep|\n if dep.runtime?\n spec = Gem.loaded_specs[dep.name]\n spec and not spec.satisfies_requirement? dep\n else\n false\n end\n end\n end",
"def installed?(name, req = Gem::Requirement.default)\n Gem::Specification.any? { |s| s.name =~ name and req =~ s.version }\n end",
"def gems_from_manifest(manifest='.gems')\n gems = File.read(manifest).split(\"\\n\")\n gems.reject { |name| name =~ /^\\s*(#|$)/ }\n end",
"def parse_missing(input)\n matches = input.match(/Missing these required gems:([\\s\\S]*)You're running:/)\n return [] if matches.nil?\n matches[1].strip.split(\"\\n\").map do |line|\n m = line.match(/^\\s*(\\S+)\\s+(\\S+\\s+[0-9.]+)/)\n p line if m.nil?\n {:name => m[0], :version => m[1]}\n end\n end",
"def in_all_gemsets_but_global?(gemsets)\n in_all_gemsets = false\n remaining = gemsets - @gemsets_containing\n (remaining.empty? or remaining == ['default']) and (not gemsets.include? 'global')\n end",
"def required(gem_name, gem_install_name = nil)\n Required::required gem_name, gem_install_name\nend"
] | [
"0.7633258",
"0.7436955",
"0.74197423",
"0.72621655",
"0.7222977",
"0.70317864",
"0.69449383",
"0.68607575",
"0.67814004",
"0.67673004",
"0.6764804",
"0.67586553",
"0.6703803",
"0.65185887",
"0.6488151",
"0.6456092",
"0.6430396",
"0.64253855",
"0.6414735",
"0.6352877",
"0.6318913",
"0.62995034",
"0.6261826",
"0.6259057",
"0.6246277",
"0.6179927",
"0.6179927",
"0.61646146",
"0.6150876",
"0.6145891",
"0.6098972",
"0.6098951",
"0.60461575",
"0.60168076",
"0.60168076",
"0.5986114",
"0.5982404",
"0.5968966",
"0.5967655",
"0.59507984",
"0.594357",
"0.5938985",
"0.5932536",
"0.5914473",
"0.5908374",
"0.5898786",
"0.5892271",
"0.5890797",
"0.5889389",
"0.5885172",
"0.5878278",
"0.5870546",
"0.585645",
"0.5846018",
"0.5836255",
"0.5831657",
"0.5817442",
"0.579792",
"0.57960504",
"0.57852465",
"0.577611",
"0.57706386",
"0.57494664",
"0.57459205",
"0.5721636",
"0.5716199",
"0.57011884",
"0.56994355",
"0.5692371",
"0.5690882",
"0.5686044",
"0.5670244",
"0.56544554",
"0.56446004",
"0.56365705",
"0.56358284",
"0.56358284",
"0.5631149",
"0.5627053",
"0.5619189",
"0.5600123",
"0.5592621",
"0.5592265",
"0.5591214",
"0.55822647",
"0.55729645",
"0.55684555",
"0.55645055",
"0.5563423",
"0.5560845",
"0.5558647",
"0.5557642",
"0.5556908",
"0.5546508",
"0.55409014",
"0.5535114",
"0.553086",
"0.5530791",
"0.5526647",
"0.5522661"
] | 0.731619 | 3 |
Bundles the required gems into a JAR file. Before the gems are packed into the JAR, all JARs inside the gems are moved to the jar_dir. | def bundle
raise "Paths not given! Call setup first." if @install_dir.nil? || @jar_dir.nil?
gems_jar = File.join(jar_dir, 'gems.jar')
default_options = { :generate_rdoc => false,
:generate_ri => false,
:install_dir => install_dir }
FileUtils.rm_rf install_dir if File.exists? install_dir
FileUtils.mkdir_p install_dir
installer = Gem::DependencyInstaller.new(default_options)
@gems.each do |name, version|
puts "Installing #{name} (#{version})"
installer.install(name, version || Gem::Requirement.default)
end
Dir.glob("#{install_dir}/**/*.jar").each do |jar|
FileUtils.mv jar, File.join(jar_dir, jar.split("/").last)
end
FileUtils.rm gems_jar if File.exists? gems_jar
`jar cf #{gems_jar} -C #{install_dir} .`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_bundled_gems\n return unless bundle_gems\n\n if bundle_local\n logger.trace 'Adding bundler filer to jar locally...'\n else\n logger.trace 'Adding bundler files to jar...'\n end\n\n require 'bundler'\n begin\n gemfile_path, lockfile_path = nil\n\n # Execute Bundler commands in the app_path, not in the Dir.pwd\n Bundler::SharedHelpers.chdir app_path do\n # No need to check ENV['BUNDLE_GEMFILE'], because Bundler will\n # take care of that\n gemfile_path = Bundler.default_gemfile\n lockfile_path = Bundler.default_lockfile\n end\n rescue Bundler::GemfileNotFound\n logger.warn 'No Gemfile found - skipping gem dependencies'\n return {}\n end\n\n # We need gemfile_root to properly locate the `vendor/bundle`\n gemfile_root = gemfile_path.parent\n vendor_cache_path = gemfile_root.join('vendor/cache')\n vendor_bundle_path = gemfile_root.join('vendor/bundle')\n\n unless lockfile_path.exist?\n logger.warn 'No Gemfile.lock found — this might lead to unexpected \\\n dependency tree, please consider running `bundle install` to resolve \\\n and lock dependencies.'\n end\n\n exclude_registed_jars = TorqueBox::Jars.list.map { |j| File.basename(j) }\n bundle_source = temp_dir\n\n # No need to run bundler at all. Just copy the contents of the\n # `vendor/bundle` to the jar\n if vendor_bundle_path.exist?\n logger.info 'Using existing `vendor/bundle`. Make sure that your \\\n dependencies is up to date.'\n\n bundle_source = vendor_bundle_path\n else\n vendor_bundle_gems :lockfile_exist => lockfile_path.exist?\n end\n\n add_files :source => bundle_source.to_s,\n :destination => 'app/vendor/bundle',\n :pattern => '/{**/*,.bundle/**/*}',\n :exclude => exclude_registed_jars\n\n copy_bundler_gem\n end",
"def create!\n FileUtils.mkdir_p(@configuration[:build_dir])\n\n Dir.mktmpdir do |tmp_dir|\n output_path = File.join(@configuration[:build_dir], @configuration[:jar_name])\n project_dir = Pathname.new(@configuration[:app_dir])\n extra_files = @configuration[:extra_files] || []\n jruby_complete_path = @configuration[:jruby_complete]\n\n if !(defined? JRubyJars) && !(jruby_complete_path && File.exists?(jruby_complete_path))\n raise PuckError, 'Cannot build Jar: jruby-jars must be installed, or :jruby_complete must be specified'\n end\n\n gem_dependencies = resolve_gem_dependencies\n create_jar_bootstrap!(tmp_dir, gem_dependencies)\n\n ant = Ant.new(output_level: 1)\n ant.jar(destfile: output_path) do\n manifest do\n attribute name: 'Main-Class', value: 'org.jruby.JarBootstrapMain'\n attribute name: 'Created-By', value: \"Puck v#{Puck::VERSION}\"\n end\n\n zipfileset dir: tmp_dir, includes: 'jar-bootstrap.rb'\n\n if jruby_complete_path\n zipfileset src: jruby_complete_path\n else\n zipfileset src: JRubyJars.core_jar_path\n zipfileset src: JRubyJars.stdlib_jar_path\n end\n\n %w[bin lib].each do |sub_dir|\n zipfileset dir: project_dir + sub_dir, prefix: File.join(JAR_APP_HOME, sub_dir)\n end\n\n extra_files.each do |ef|\n path = Pathname.new(ef).expand_path.cleanpath\n prefix = File.join(JAR_APP_HOME, path.relative_path_from(project_dir).dirname.to_s)\n zipfileset dir: path.dirname, prefix: prefix, includes: path.basename\n end\n\n gem_dependencies.each do |spec|\n zipfileset dir: spec[:base_path], prefix: spec[:jar_path]\n end\n end\n end\n end",
"def make_jar(jarname, dirname, quiet = false)\n cmd(\"jar cf #{jarname} -C #{dirname} .\", quiet)\n end",
"def add_bundler_files(jar)\n pwd = Pathname.new(Dir.pwd)\n gemfile = config.bundler[:gemfile].relative_path_from(pwd).to_s\n lockfile = config.bundler[:lockfile].relative_path_from(pwd).to_s\n jar.files[jar.apply_pathmaps(config, gemfile, :application)] = config.bundler[:gemfile].to_s\n if File.exist?(lockfile)\n jar.files[jar.apply_pathmaps(config, lockfile, :application)] = config.bundler[:lockfile].to_s\n end\n end",
"def jar(name, **opts)\n\n opts = {} if opts.nil?\n opts = JSON[JSON[opts], symbolize_names: true]\n opts[:vendor_path] = 'vendor/checkouts'\n opts[:checkout_path] = File.join(opts[:vendor_path], name)\n opts[:jar_path] = File.join(\n opts[:checkout_path],\n 'target',\n \"#{name}-#{opts[:version]}.jar\"\n )\n\n raise ArgumentError, \"can't use path and git together\" if opts[:git] && opts[:path]\n\n system \"mkdir -p #{opts[:vendor_path]}\" unless Dir.exist?(opts[:vendor_path])\n\n if opts[:git]\n system \"git clone #{opts[:git]} #{opts[:checkout_path]}\" unless Dir.exist?(\n opts[:checkout_path]\n )\n end\n\n if opts[:build]\n puts 'building...'\n script = ''\n script += \"cd #{opts[:checkout_path]}\"\n script += \"\\n\"\n script += opts[:build]\n system script\n system \"rm -rf ./lib/ext/*\"\n system \"cp -r #{File.join(opts[:jar_path])} ./lib/ext\"\n end\nend",
"def create\n FileUtils.mkdir_p(@configuration[:build_dir])\n\n Dir.mktmpdir do |tmp_dir|\n output_path = File.join(@configuration[:build_dir], @configuration[:jar_name])\n temporary_output_path = File.join(Dir.mktmpdir, @configuration[:jar_name])\n project_dir = Pathname.new(@configuration[:app_dir]).expand_path.cleanpath\n extra_files = @configuration[:extra_files] || []\n jruby_complete_path = @configuration[:jruby_complete]\n\n if !(defined? JRubyJars) && !(jruby_complete_path && File.exists?(jruby_complete_path))\n raise PuckError, 'Cannot build Jar: jruby-jars must be installed, or :jruby_complete must be specified'\n end\n\n merge_archives = (@configuration[:merge_archives] || []).to_a\n if jruby_complete_path\n merge_archives << jruby_complete_path\n else\n merge_archives.push(JRubyJars.core_jar_path, JRubyJars.stdlib_jar_path)\n end\n\n gem_dependencies = @dependency_resolver.resolve_gem_dependencies(@configuration)\n create_jar_bootstrap!(tmp_dir, gem_dependencies)\n\n ant = Ant.new(output_level: 1)\n begin\n ant.jar(destfile: temporary_output_path) do\n manifest do\n attribute name: 'Main-Class', value: 'org.jruby.JarBootstrapMain'\n attribute name: 'Created-By', value: \"Puck v#{Puck::VERSION}\"\n end\n\n zipfileset dir: tmp_dir, includes: 'jar-bootstrap.rb'\n\n %w[bin lib].each do |sub_dir|\n path = project_dir + sub_dir\n if File.exists?(path)\n zipfileset dir: path, prefix: File.join(JAR_APP_HOME, sub_dir)\n end\n end\n\n extra_files.each do |file, target_path|\n path = Pathname.new(file).expand_path.cleanpath\n if target_path\n zipfileset file: path, fullpath: target_path\n else\n prefix = File.join(JAR_APP_HOME, path.relative_path_from(project_dir).dirname.to_s)\n zipfileset dir: path.dirname, prefix: prefix, includes: path.basename\n end\n end\n\n gem_dependencies.each do |spec|\n base_path = Pathname.new(spec[:base_path]).expand_path.cleanpath\n unless project_dir == base_path\n zipfileset dir: spec[:base_path], prefix: File.join(JAR_GEM_HOME, 'gems', spec[:versioned_name])\n zipfileset file: spec[:spec_file], fullpath: File.join(JAR_GEM_HOME, 'specifications', File.basename(spec[:spec_file]))\n end\n end\n\n merge_archives.each do |archive, target_path|\n if target_path\n zipfileset src: archive, prefix: target_path, excludes: SIGNATURE_FILES\n else\n zipfileset src: archive, excludes: SIGNATURE_FILES\n end\n end\n end\n\n FileUtils.mv(temporary_output_path, output_path)\n rescue Java::OrgApacheToolsAnt::BuildException => e\n raise PuckError, sprintf('Error when building JAR: %s (%s)', e.message, e.class), e.backtrace\n ensure\n FileUtils.rm_rf(File.dirname(temporary_output_path))\n end\n output_path\n end\n end",
"def inject_jar(jar_path)\n jar_dir = tmp_app_path.join('Contents/Java')\n jar_dir.rmtree\n jar_dir.mkdir\n cp Pathname.new(jar_path), jar_dir\n end",
"def fast_merge_jar(target_jar, merge_jar)\n info \"merging #{merge_jar}\"\n tmp = _(:target, \"tmp\")\n sh \"rm -rf #{tmp}\"\n sh \"mkdir -p #{tmp}; cd #{tmp}; jar -xf #{merge_jar}; jar -uf #{target_jar} *\"\n sh \"rm -rf #{tmp}\"\n end",
"def all_in_one_jar(options)\n name = options[:id] || fail(\"Missing :id\")\n libs = options[:libs] || fail(\"Missing :id\")\n package(:jar, :id => fakesdb(name)).tap do |pkg|\n pkg.enhance [task(:retrieve)]\n # double-enhance so merge happens after base jar is created\n pkg.enhance do\n pkg.enhance do\n libs.each do |prefix|\n Dir[_(\"lib\") + \"/#{prefix}-*.jar\"].each do |dep|\n fast_merge_jar pkg, dep if dep !~ /-sources/\n end\n end\n end\n end\n end\n end",
"def connectorj_jar\n ::File.basename(new_resource.url, '.tar.gz') + if connectorj_ver.split('.')[0].to_i >= 8\n '.jar'\n else\n '-bin.jar'\n end\n end",
"def shared_boot_jar_directory\n FilePath.new(@build_dir, \"boot-jars\")\n end",
"def patch_jars(jars)\n jars.each do |jar|\n tmp = File.new(\"MANIFEST.MF\", \"w\")\n Zip::ZipFile.open(jar) do |zip|\n cont = zip.read(\"META-INF/MANIFEST.MF\").rstrip\n tmp.puts(cont)\n if cont.match('DynamicImport-Package').nil? then\n tmp.puts(\"DynamicImport-Package: com.vladium.*\\n\")\n end\n\n tmp.close\n zip.replace(\"META-INF/MANIFEST.MF\", \"MANIFEST.MF\")\n end\n end\nend",
"def add_jar(jar)\n logger.debug \"Adding jar {}\", jar\n\n jar_name = \"jars/#{File.basename(jar)}\"\n classpath << \"${extract_root}/#{jar_name}\"\n\n jar_builder.add_file(jar_name.to_s, jar.to_s)\n end",
"def bundle_dependencies\r\n if options[:run_bundle]\r\n say \"Bundling application dependencies using bundler...\"\r\n in_root { run 'bundle install' }\r\n end\r\n end",
"def download_jar(jar_name, target_directory = @lib_directory, description = @component_name)\n download(description) { |file| FileUtils.cp file.path, File.join(target_directory, jar_name) }\n end",
"def create_jar(jar_file, options, &block)\n def options.get_and_delete(key, default_value)\n if self.has_key?(key)\n result = self[key]\n self.delete(key)\n else\n result = default_value\n end\n result\n end\n\n include_license = options.get_and_delete(:include_license, true)\n include_thirdparty_license = options.get_and_delete(:include_thirdparty_license, true)\n\n options[:destfile] = jar_file.to_s\n self.jar(options, &block)\n\n # Now add the license files to the JAR if necessary.\n static_resources = Registry[:static_resources]\n license_files = []\n license_files << static_resources.license_file if include_license\n license_files << static_resources.thirdparty_license_file if include_thirdparty_license\n license_files.each do |file|\n directory = file.directoryname.to_s\n self.jar(:destfile => jar_file.to_s, :update => 'true',\n :basedir => directory, :includes => file.filename.to_s)\n end\n end",
"def find_jars_to_patch()\n all_jars = Dir.glob(File.join(\"**\", \"*.jar\"))\n jars_to_patch = Array.new\n finalized_jars = Array.new\n\n File.open(\"finalized-jarlist.txt\").each_line do |f|\n # get the package name\n\n # +1 to rindex is to get rid of the begining /\n f = f.slice!(f.rindex('/')+1..f.length)\n f = f.slice(0...f.rindex('-'))\n finalized_jars.push(f)\n end\n\n all_jars.each do |jar|\n found = 0\n\n finalized_jars.each do |f|\n if not jar.match(f).nil? then\n found = 1\n break\n end\n end\n\n jars_to_patch.push(jar) if found == 1\n end\n return jars_to_patch\nend",
"def bundle_dependencies\n if options[:run_bundle]\n say \"Bundling application dependencies using bundler...\"\n in_root { run 'bundle install' }\n end\n end",
"def jar(name)\n \"https://clojars.org/#{name}\"\n end",
"def register_jarfile(jarfile, gem_spec = nil)\n fail \"Jarfile not found: #{jarfile}\" unless File.exist? jarfile\n registered_jarfiles[jarfile] = gem_spec\n end",
"def package_artifact\n # keep track of current working dir\n current_dir = Dir.pwd\n Dir.chdir @configuration.package_destination_path\n\n # zip final package\n cmd = []\n cmd << \"zip\"\n cmd << \"-r\"\n cmd << \"\\\"#{@configuration.zipped_package_name}\\\"\"\n cmd << \"\\\"#{@configuration.dsym_name}\\\"\" unless @configuration.skip_dsym\n cmd << \"\\\"#{@configuration.ipa_name}\\\"\" unless !@configuration.sdk.eql? \"iphoneos\"\n cmd << \"\\\"#{@configuration.app_name}.#{@configuration.app_extension}\\\"\" unless !@configuration.sdk.eql? \"macosx\"\n cmd << \"2>&1 %s ../build.output\" % (@configuration.verbose ? '| tee' : '>')\n\n system cmd.join \" \"\n\n # delete all the artifacts but the .app. which will be needed by the automation builds\n FileUtils.rm_rf @configuration.dsym_name unless !File.exists? @configuration.dsym_name\n FileUtils.rm_rf @configuration.ipa_name unless !File.exists? @configuration.ipa_name\n\n # back to working directory\n Dir.chdir current_dir\n\n puts \"Done\"\n puts \"ZIP package: #{@configuration.zipped_package_name}\"\n end",
"def lock_registered_jarfiles(*args, &blk)\n jarfiles = registered_jarfiles\n return if jarfiles.empty?\n instances = jarfiles.map do |jarfile, spec|\n if spec\n LockJar::Domain::GemDsl.create spec, jarfile\n else\n LockJar::Domain::JarfileDsl.create jarfile\n end\n end\n combined = instances.reduce do |result, inst|\n LockJar::Domain::DslMerger.new(result, inst).merge\n end\n args = args.reject { |arg| arg.is_a? String }\n lock(combined, *args, &blk)\n end",
"def reconfigure_jruby_stdlib\n abort 'cannot find jruby library in libs' if Dir['libs/jruby*'].empty?\n if (gem_version = ENV['JRUBY_JARS_VERSION'])\n gem('jruby-jars', gem_version)\n end\n require 'jruby-jars'\n\n log_action(\"Copying #{JRubyJars::stdlib_jar_path} to libs\") do\n FileUtils.cp JRubyJars::stdlib_jar_path, \"libs/jruby-stdlib-#{JRubyJars::VERSION}.jar\"\n end\n StdlibDependencies.load('rakelib/ruboto.stdlib.yml')\n\n Dir.chdir 'libs' do\n jruby_stdlib = Dir['jruby-stdlib-*.jar'][-1]\n log_action(\"Reformatting #{jruby_stdlib}\") do\n FileUtils.mkdir_p 'tmp'\n Dir.chdir 'tmp' do\n FileUtils.mkdir_p 'old'\n FileUtils.mkdir_p 'new/jruby.home'\n Dir.chdir 'old' do\n `jar -xf ../../#{jruby_stdlib}`\n raise \"Unpacking jruby-stdlib jar failed: #$?\" unless $? == 0\n end\n FileUtils.move 'old/META-INF/jruby.home/lib', 'new/jruby.home/lib'\n FileUtils.rm_rf 'new/jruby.home/lib/ruby/gems'\n\n remove_unneeded_parts_of_stdlib\n cleanup_jars\n\n Dir.chdir 'new' do\n `jar -cf ../../#{jruby_stdlib} .`\n raise \"Creating repackaged jruby-stdlib jar failed: #$?\" unless $? == 0\n end\n end\n\n FileUtils.remove_dir 'tmp', true\n end\n end\nend",
"def reshuffle_jars()\n FileUtils.mkdir_p(\"#{self.build_dir()}/src/edit-webapp/WEB-INF/lib/\")\n FileUtils.cp(Dir[\"#{UcbDeployer::RESOURCES_DIR}/soulwing-casclient-*\"],\n \"#{self.build_dir()}/src/edit-webapp/WEB-INF/lib/\")\n # These have been placed in $CATALINA_HOME/lib\n [\"mail\", \"activation\", \"javamail\", \"commons-logging\", \"log4j\"].each do |jar|\n FileUtils.rm_rf(Dir[\"#{self.build_dir()}/src/webapp/WEB-INF/lib/#{jar}-*\"])\n end\n end",
"def reconfigure_jruby_libs\n jruby_core = JRubyJars::core_jar_path.split('/')[-1]\n log_action(\"Removing unneeded classes from #{jruby_core}\") do\n Dir.mkdir \"libs/tmp\"\n Dir.chdir \"libs/tmp\"\n FileUtils.move \"../#{jruby_core}\", \".\"\n `jar -xf #{jruby_core}`\n File.delete jruby_core\n ['jni', 'org/jruby/ant', 'org/jruby/compiler/ir', 'org/jruby/demo', 'org/jruby/embed/bsf', \n 'org/jruby/embed/jsr223', 'org/jruby/ext/ffi','org/jruby/javasupport/bsf'\n ].each {|i| FileUtils.remove_dir i, true}\n `jar -cf ../#{jruby_core} .`\n Dir.chdir \"../..\"\n FileUtils.remove_dir \"libs/tmp\", true\n end\n\n jruby_stdlib = JRubyJars::stdlib_jar_path.split('/')[-1]\n log_action(\"Reformatting #{jruby_stdlib}\") do\n Dir.mkdir \"libs/tmp\"\n Dir.chdir \"libs/tmp\"\n FileUtils.move \"../#{jruby_stdlib}\", \".\"\n `jar -xf #{jruby_stdlib}`\n File.delete jruby_stdlib\n FileUtils.move \"META-INF/jruby.home/lib/ruby/1.8\", \"..\"\n Dir.chdir \"../1.8\"\n FileUtils.remove_dir \"../tmp\", true\n `jar -cf ../#{jruby_stdlib} .`\n Dir.chdir \"../..\"\n FileUtils.remove_dir \"libs/1.8\", true\n end\nend",
"def dependency_to_jar(dependency)\n group, artifact, version = dependency.split(\"/\")\n \"#{artifact}-#{version}.jar\"\nend",
"def rubygems_freeze\n create_freezer_dir(freezer_dir)\n action = update ? 'update' : 'install'\n puts \"#{action} #{@component} and dependencies from rubygems\"\n `#{sudo} gem #{action} #{@component} --no-rdoc --no-ri -i #{freezer_dir}`\n end",
"def require_jars(paths)\n paths = [paths] unless paths.is_a?(Array)\n paths.each do |path|\n jar_pattern = File.join(path,\"**\", \"*.jar\")\n Dir[jar_pattern].each {|jar_file| require jar_file}\n end\n end",
"def appbundle_gem(gem_name)\n # First lock the gemfile down.\n lockdown_gem(gem_name)\n\n shared_gemfile = self.shared_gemfile\n\n # Ensure the main bin dir exists\n bin_dir = File.join(install_dir, \"bin\")\n mkdir(bin_dir)\n\n block \"Lock down the #{gem_name} gem\" do\n installed_path = shellout!(\"#{bundle_bin} show #{gem_name}\", env: env, cwd: install_dir).stdout.chomp\n\n # appbundle the gem\n appbundler_args = [ installed_path, bin_dir, gem_name ]\n appbundler_args = appbundler_args.map { |a| ::Shellwords.escape(a) }\n shellout!(\"#{appbundler_bin} #{appbundler_args.join(\" \")}\", env: env, cwd: installed_path)\n end\n end",
"def build_jar\n `rm framework/local.properties` if File.exists? 'framework/local.properties'\n `rm framework/phonegap.jar` if File.exists? 'framework/phonegap.jar'\n `rm framework/phonegap.js` if File.exists? 'framework/phonegap.js'\n `ECHO 'sdk-location=#{ @android_sdk_path }' > framework/local.properties`\n `cd framework; ant jar`\n end",
"def add_gems\n Bundler.with_clean_env do\n run 'bundle install'\n end\n end",
"def util_bake_gem(name = \"a\", *extra, &block)\n files = [\"lib/#{name}.rb\"].concat(extra)\n\n spec = new_spec name, \"1\", nil, files, &block\n\n File.join @tempdir, \"gems\", \"#{spec.full_name}.gem\"\n end",
"def bundle!(export_dir= Rails.configuration.gtdinbox_export_dir)\n @bundle_filename = \"#{export_dir}/#{@bundle_id}-translation-export.zip\"\n\n\n Zip::ZipFile.open(@bundle_filename, Zip::ZipFile::CREATE) do |zipfile|\n pp @dir_names\n @dir_names.each {|dirname|zipfile.mkdir(dirname)}\n @dir_files.each do |dir_file|\n dirname, file = dir_file\n zip_filepath = File.basename(file.path).gsub(\"#{dirname}-#{@bundle_id}-\",'')\n zipfile.add([dirname, zip_filepath].join('/'), file.path)\n end\n end\n\n File.chmod(0644, @bundle_filename)\n clean_up\n\n @bundle_filename\n end",
"def bundle\n return unless File.exist?(\"Gemfile\")\n\n # Only need bundler/setup to get our paths right--we don't need to\n # actually require the gems, since we find the generate_backend.rb's\n # and just require them directly.\n require 'bundler/setup'\n end",
"def bundle\n return unless File.exist?(\"Gemfile\")\n\n # Only need bundler/setup to get our paths right--we don't need to\n # actually require the gems, since we find the generate-backend.rb's\n # and just require them directly.\n require 'bundler/setup'\n end",
"def bundle_install(jruby, quiet = false, opts = {})\n ex_opts = opts.map {|k,v| [k,v] }.join(\" \")\n cmd(\"#{jruby} -S bundle install --path ./vendor/bundle/ #{ex_opts}\", quiet)\n end",
"def bundle\n return unless File.exists?(\"Gemfile\")\n\n # Only need bundler/setup to get our paths right--we don't need to\n # actually require the gems, since we find the generate-backend.rb's\n # and just require them directly.\n require 'bundler/setup'\n end",
"def bundle args = []\n\t\t\tputs \"Starting to bunlde gemfile for modules ...\"\n\t\t\targs = Smods.keys if args.empty?\n\n\t\t\targs.each do | module_name |\n\t\t\t\tpath = \"#{Smods[module_name]}#{Spath[:gemfile]}\"\n\t\t\t\tif File.exist? path\n\t\t\t\t\t`bundle install --gemfile=#{path}`\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tputs \"Implemented completion\"\n\t\tend",
"def bundle_package(*args, &block)\n ruby_package(*args) do |pkg|\n Autoproj.env_add_path 'ROCK_BUNDLE_PATH', pkg.srcdir\n if block_given?\n pkg.instance_eval(&block)\n end\n end\nend",
"def require_jars!\n require 'jruby'\n\n # ask marc-marc4j gem to load the marc4j jars\n MARC::MARC4J.new(:jardir => settings['marc4j_reader.jar_dir'])\n\n # For some reason we seem to need to java_import it, and use\n # a string like this. can't just refer to it by full\n # qualified name, not sure why, but this seems to work.\n java_import \"org.marc4j.converter.impl.AnselToUnicode\"\n\n unless defined? Java::net.sourceforge.jtds.jdbc.Driver\n jtds_jar_dir = settings[\"jtds.jar_path\"] || File.expand_path(\"../../vendor/jtds\", File.dirname(__FILE__))\n\n Dir.glob(\"#{jtds_jar_dir}/*.jar\") do |x|\n require x\n end\n\n # For confusing reasons, in normal Java need to\n # Class.forName(\"net.sourceforge.jtds.jdbc.Driver\")\n # to get the jtds driver to actually be recognized by JDBC.\n #\n # In Jruby, Class.forName doesn't work, but this seems\n # to do the same thing:\n Java::net.sourceforge.jtds.jdbc.Driver\n end\n\n # So we can refer to these classes as just ResultSet, etc.\n java_import java.sql.ResultSet, java.sql.PreparedStatement, java.sql.Driver\n end",
"def import_from_jar\n # Example\n # this is used to import java generated file from the jar \n # within the application which will be running in java\n # you need to put the name of all the required class\n %w[\n controller\n handler\n application_controller\n application_handler\n ].each do |c|\n require c\n end\n\nend",
"def unpack(&bl)\n dir = nil\n pkg = ::Gem::Installer.new gem_path, :unpack => true\n\n if bl\n Dir.mktmpdir do |tmpdir|\n pkg.unpack tmpdir\n bl.call tmpdir\n end\n else\n dir = Dir.mktmpdir\n pkg.unpack dir\n end\n\n dir\n end",
"def instrument_jars(jars)\n jars.each do |jar|\n system(\"$JAVA_HOME/jre/bin/java -cp emma.jar emma instr -m overwrite -cp #{jar}\") if jar.match('webapps')\n end\nend",
"def slave_jar\n ::File.join(new_resource.remote_fs, 'slave.jar')\n end",
"def bundle\n Bundler.with_clean_env do\n execute(\n 'bundle', 'install', '--frozen', '--retry', '3', '--jobs', '3',\n fail_with: BundleError\n )\n end\n end",
"def package_agent\n @logger.info \"Packaging Bosh Agent to #{definition_dest_dir}/_bosh_agent.tar\"\n dst = File.join(definition_dest_dir, \"_bosh_agent.tar\")\n if File.directory? @agent_src_path\n @logger.info \"Tarring up Bosh Agent\"\n Dir.chdir(@agent_src_path) do\n sh(\"tar -cf #{dst} *.gem > /dev/null 2>&1\", {:on_error => \"Unable to package bosh gems\"})\n end\n else\n FileUtils.cp @agent_src_path, dst\n end\n end",
"def unpack(&bl)\n dir = nil\n pkg = ::Gem::Installer.new gem_path, :unpack => true\n\n if bl\n Dir.mktmpdir do |tmpdir|\n pkg.unpack tmpdir\n bl.call tmpdir\n end\n else\n dir = Dir.mktmpdir\n pkg.unpack dir\n end\n\n dir\n end",
"def bundle\n Dir.chdir @temp_dir\n system(\"bundle install\")\n end",
"def do_bundle\n # Custom bundle command ensures dependencies are correctly installed\n Bundler.with_unbundled_env { run \"bundle install\" }\nend",
"def do_bundle\n # Custom bundle command ensures dependencies are correctly installed\n Bundler.with_unbundled_env { run \"bundle install\" }\nend",
"def create_js_bundle(scripts)\n filename = js_bundle_filepath(scripts)\n content = @packager.bundle_files(scripts)\n WebResourceBundler::ResourceFile.new_js_file(filename, content)\n end",
"def write_gem_dir(gem_parts)\n tmp = Pathname(Dir.mktmpdir)\n warn(\"Using #{tmp} as a place to build the gem\")\n # Write out the gemspec\n (tmp + \"#{gem_name}.gemspec\").open(\"w\") {|f| f << gem_parts[:spec]}\n # Write out the readme\n (tmp + \"README.md\").open(\"w\") {|f| f << gem_parts[:readme]}\n # Write out the library itself\n (tmp + \"#{gem_name}.rb\").open(\"w\") {|f| f << gem_parts[:library]}\n # If a chunk of code has been specified to build a command line executable\n # from, write that out\n if gem_parts[:executable]\n (tmp + gem_name).open(\"w\") do |f|\n # Flip the executable bit on the binary file\n f.chmod(f.stat.mode | 0100)\n f << \"#!/usr/bin/env ruby\\n\"\n f << \"require #{gem_name.inspect}\\n\"\n f << \"#{gem_parts[:executable]}\\n\"\n end\n end\n tmp\n end",
"def build_jar\n puts \"Building phonegap.jar\"\n %w(build.properties local.properties phonegap.js phonegap.jar).each do |f|\n FileUtils.rm File.join(@droidgap_src_dir, f) if File.exists? File.join(@droidgap_src_dir, f)\n end\n open(File.join(@droidgap_src_dir, 'build.properties'), 'w') do |f|\n f.puts \"target=#{ @target }\"\n end \n open(File.join(@droidgap_src_dir, 'local.properties'), 'w') do |f|\n f.puts \"sdk.dir=#{ @android_sdk_path }\"\n end \n Dir.chdir(@droidgap_src_dir)\n `ant jar`\n Dir.chdir(@droidgap_dir)\n end",
"def slave_jar\n ::File.join(Chef::Config[:file_cache_path], 'slave.jar')\n end",
"def compress\n @env[:ui].info I18n.t(\"vagrant.actions.general.package.compressing\", :tar_path => tar_path)\n File.open(tar_path, Platform.tar_file_options) do |tar|\n Archive::Tar::Minitar::Output.open(tar) do |output|\n begin\n current_dir = FileUtils.pwd\n\n copy_include_files\n\n FileUtils.cd(@env[\"package.directory\"])\n Dir.glob(File.join(\".\", \"**\", \"*\")).each do |entry|\n Archive::Tar::Minitar.pack_file(entry, output)\n end\n ensure\n FileUtils.cd(current_dir)\n end\n end\n end\n end",
"def load_jars(*jars)\n jars.each do |jar|\n unless $LOADED_FEATURES.find{ |f| f =~ Regexp.new(jar) }\n log.finest \"Loading jar #{jar}...\"\n begin\n loaded = require(jar)\n rescue LoadError\n loaded = find_jar(jar)\n end\n unless loaded\n raise ConfigurationError, \"Could not load JAR file #{jar}\"\n end\n end\n end\n end",
"def execute\n gemname = get_one_gem_name\n path = get_path(gemname, options[:version])\n if path\n require 'fileutils'\n target_dir = File.basename(path).sub(/\\.gem$/, '')\n FileUtils.mkdir_p target_dir\n Installer.new(path).unpack(File.expand_path(target_dir))\n say \"Unpacked gem: '#{target_dir}'\"\n else\n alert_error \"Gem '#{gemname}' not installed.\"\n end\n end",
"def manifest(lib)\n artifact = Buildr.artifact(lib)\n artifact.invoke # download it if needed.\n \n m = nil\n Zip::ZipFile.open(artifact.to_s) do |zip|\n raise \"No manifest contained in #{lib}\" if zip.find_entry(\"META-INF/MANIFEST.MF\").nil?\n m = zip.read(\"META-INF/MANIFEST.MF\")\n end\n manifest = ::Buildr::Packaging::Java::Manifest.new(m)\n manifest.main\n end",
"def setup(install_dir, jar_dir)\n @install_dir = install_dir\n @jar_dir = jar_dir\n end",
"def registered_jarfiles\n @registered_jarfiles ||= {}\n end",
"def bundle args = []\n\t\t\tputs \"Starting to bunlde gemfile for modules ...\"\n\t\t\targs = Smods.keys if args.empty?\n\n\t\t\targs.each do | module_name |\n\t\t\t\tpath = \"#{Smods[module_name]}#{Spath[:gemfile]}\"\n\t\t\t\tif File.exist? path\n\t\t\t\t\t`bundle install --gemfile=#{path}`\n\t\t\t\tend\n\t\t\tend\n\t\t\tputs \"Successfully implemented\"\n\t\tend",
"def gf_scan_existing_binary_endorsed_jars(install_dir)\n jar_extensions = ['.jar']\n gf_binary_endorsed_dir = install_dir + '/glassfish/lib/endorsed'\n if Dir.exist?(gf_binary_endorsed_dir)\n Dir.entries(gf_binary_endorsed_dir).reject { |f| File.directory?(f) || !jar_extensions.include?(File.extname(f)) }\n else\n []\n end\nend",
"def package_stemcell\n @stemcell_files << generate_image << generate_manifest << stemcell_files\n # package up files\n package_files\n end",
"def upload_lambda_files\n puts '- bundling dependencies'\n Bundler.with_clean_env do\n Dir.chdir(app_path) do\n `bundle install`\n `bundle install --deployment --without development`\n end\n end\n FileUtils.remove_dir(app_path.join(\"vendor/bundle/ruby/#{GEM_PATH_RUBY_VERSION}/cache\")) # remove cache dir\n upload_app_layer(sub_dirs: '', add_layer_to_stack: false) # reuse layer upload\n FileUtils.remove_dir(app_path.join('.bundle'))\n FileUtils.remove_dir(app_path.join('vendor'))\n end",
"def package_stemcell\n @stemcell_files << generate_image << generate_manifest\n # package up files\n package_files\n end",
"def packaging_task(dir_path, pkg_name)\n chdir dir_path do\n sh \"#{ZIP} -9 -r -o ../#{pkg_name} * **/*\"\n end\nend",
"def packaging_task(dir_path, pkg_name)\n chdir dir_path do\n sh \"#{ZIP} #{ZIP_ARGS} -r -o ../#{pkg_name} * **/*\"\n end\nend",
"def rhino_jar\n if File.exists? normalize('support/js.jar')\n normalize 'support/js.jar'\n else\n RHINO\n end\n end",
"def zip_app_dir_bundle(temp_directory_to_create_bundle)\n zip_file_name = \"#{temp_directory_to_create_bundle}/app_dir_bundle.zip\"\n Dir.mktmpdir { |zip_build_dir|\n # Copy the bundle files into a temporary directory so we can just zip the sample bundle\n FileUtils.cp_r(StepConstants::SAMPLE_APP_BUNDLE_FULL_PATH, zip_build_dir)\n zip_directory(zip_build_dir, zip_file_name)\n }\n # Confirm appspec.yml is not at top level\n Zip::File.open(zip_file_name) { |zip| expect(zip.entries.map(&:name).include? \"appspec.yml\").to be false }\n zip_file_name\nend",
"def install_gems(gems)\n missing = [ ]\n\n blessed_gems_dir = File.join(@cache_base_dir, \"blessed_gems\")\n FileUtils.mkdir_p(blessed_gems_dir)\n\n gems.each do |(name, version)|\n gem_filename = \"%s-%s.gem\" % [ name, version ]\n\n user_gem_path = File.join(@app_dir, \"vendor\", \"cache\", gem_filename)\n blessed_gem_path = File.join(blessed_gems_dir, gem_filename)\n\n if File.exists?(user_gem_path)\n installed_gem_path = @cache.get(user_gem_path)\n unless installed_gem_path\n @logger.debug \"Installing user gem: #{user_gem_path}\"\n tmp_gem_dir = install_gem(user_gem_path)\n installed_gem_path = @cache.put(user_gem_path, tmp_gem_dir)\n end\n @logger.info \"Adding #{gem_filename} to app...\"\n copy_gem_to_app(installed_gem_path)\n\n elsif File.exists?(blessed_gem_path)\n installed_gem_path = @cache.get(blessed_gem_path)\n unless installed_gem_path\n @logger.debug \"Installing blessed gem: #{blessed_gem_path}\"\n tmp_gem_dir = install_gem(blessed_gem_path)\n installed_gem_path = @cache.put(blessed_gem_path, tmp_gem_dir)\n end\n @logger.info \"Adding #{gem_filename} to app...\"\n copy_gem_to_app(installed_gem_path)\n\n else\n missing << [ name, version ]\n end\n end\n\n Dir.mktmpdir do |tmp_dir|\n fetch_gems(missing, tmp_dir)\n\n missing.each do |(name, version)|\n gem_filename = \"%s-%s.gem\" % [ name, version ]\n gem_path = File.join(tmp_dir, gem_filename)\n\n @logger.debug \"Installing downloaded gem: #{gem_path}\"\n tmp_gem_dir = install_gem(gem_path)\n installed_gem_path = @cache.put(gem_path, tmp_gem_dir)\n output = `cp -n #{gem_path} #{blessed_gems_dir} 2>&1`\n if $?.exitstatus != 0\n @logger.debug \"Failed adding #{gem_path} to #{blessed_gems_dir}: #{output}\"\n end\n @logger.info \"Adding #{gem_filename} to app...\"\n\n copy_gem_to_app(installed_gem_path)\n end\n end\n end",
"def package!\n Logger.message \"#{ self.class } started packaging the backup files.\"\n run(\"#{ utility(:tar) } -c -f '#{ File.join(Backup::TMP_PATH, \"#{ Backup::TIME }.#{ Backup::TRIGGER }.tar\") }' -C '#{ Backup::TMP_PATH }' '#{ Backup::TRIGGER }'\")\n end",
"def bundle_install(jar, port, username, password)\n com = \"curl -u #{username}:#{password} -F action=install -F bundlestart=start -F bundlestartlevel=20 \" \\\n \"-F bundlefile=@\\\"#{jar}\\\" http://localhost:#{port}/system/console/bundles > /dev/null 2>&1\"\n cmd = MixLib::Shellout.new(com)\n cmd.run_command\n if cmd.error?\n fail \"Failed to install CQ required bundle: #{File.basename(jar)}\"\n else\n Chef::Log.info \"Uploaded bundle package required for CQ: #{File.basename(jar)}\"\n end\n end",
"def ensure_created\n unless @created\n classpath = @module_set['dso-tests-jdk15'].subtree('src').classpath(@build_results, :full, :runtime)\n puts(\"Creating boot JAR with: #{@jvm} and config file: #{@config_file}\")\n \n File.delete(path.to_s) if FileTest.exist?(path.to_s)\n sysproperties = {\n PropertyNames::TC_BASE_DIR => @static_resources.root_dir.to_s,\n PropertyNames::MODULES_URL => @build_results.modules_home.to_url\n }\n \n begin \n @ant.java(:classname => 'com.tc.object.tools.BootJarTool',\n :classpath => classpath.to_s,\n :jvm => @jvm.java,\n :fork => true,\n :failonerror => true,\n :dir => @build_results.tools_home.to_s) do\n\n sysproperties.each do |name, value|\n @ant.sysproperty(:key => name.xml_escape(true),\n :value => value.xml_escape(true))\n end\n\n @ant.arg(:value => '-o')\n @ant.arg(:value => @directory.ensure_directory)\n @ant.arg(:value => '-f')\n @ant.arg(:value => @config_file)\n @ant.arg(:value => '-q')\n end\n rescue\n raise(\"Bootjar creation failed\")\n end\n \n @created = true\n end\n self\n end",
"def run\n build_jar\n create_android\n generate_manifest\n copy_libs\n add_name_to_strings\n write_java\n end",
"def require_bundle_gems\n # NOTE: Dont think ENV['BUNDLE_GEMFILE'] is quite working right. We still need\n # to be in the project directory. Leaving logic in here for when it gets fix.\n if ENV['BUNDLE_GEMFILE'] || File.exist?(\"Gemfile\")\n require \"bundler/setup\"\n Bundler.require(*bundler_groups)\n end\n end",
"def build_aab\n validate\n\n prepare_bundle_folder_struct\n \n extract_protobuf_data_to_bundle_prep_dir\n\n extract_legacy_data_to_bundle_prep_dir\n \n build_base_zip \n \n create_config_file\n\n #Finally build AAB archive from prepared base.zip\n bundle = File.join(@intermediate,'bundle.aab')\n args = [ '-jar', @bundletool, 'build-bundle', \"--modules=#{@base_zip}\", \"--output=#{bundle}\" , \"--config=#{@config_file}\"]\n Jake.run( @javabin, args )\n\n bundle\n end",
"def archive_artifact\n subsection 'Archive artifact', color: :green, prefix: @output_prefix unless @silent\n @data = Zip::OutputStream.write_buffer do |out|\n if @artifacts.length == 1\n file = @artifacts.shift\n v '+ ' + File.basename(file)\n out.put_next_entry(File.basename(file))\n out.write File.read(file)\n else\n @artifacts.each do |artifact|\n next if artifact == './'\n\n v '+ ' + artifact\n out.put_next_entry(artifact)\n if File.directory? artifact\n artifact += '/' unless artifact.end_with? '/'\n Zip::Entry.new(nil, artifact).write_to_zip_output_stream(out)\n elsif File.symlink? artifact\n unless (f=File.realpath(artifact)).start_with? File.realpath('./') and File.exist?(f)\n v 'warning: doesn\\'t add ' + artifact + ', because it points outside of target directory.'\n next\n end\n\n d 's ' + artifact\n\n entry = Zip::Entry.new(nil, artifact)\n entry.gather_fileinfo_from_srcpath(artifact)\n entry.write_to_zip_output_stream(out)\n else\n d 'w ' + artifact\n out.write File.read(artifact)\n end\n end\n end\n end\n @data.rewind\n d \"Zip::OutputStream length: #{@data.length}\"\n\n raise 'ZIP data is empty' if @data.length == 0\n end",
"def install_jgem(gem_built_name)\n execute(:install_jgem, \"jgem install #{gem_built_name}\")\n end",
"def crypto_jar_internal_path(jar)\n libs = jar_contents(jar).scan(\n %r{\n (?<=\\ )resources\\/.*\n (?<=\\/[0-9])\\/\n com\\.adobe\\.granite\\.crypto-[0-9]+\\.[0-9]+\\.[0-9]+[^\\.]*\\.jar$\n }x\n ).flatten\n\n raise(\"Found #{libs}, but single JAR file is expected. Aborting!\") if libs.length != 1\n\n libs.first\n end",
"def pack directory_path\n Dir.chdir directory_path\n name = Dir.pwd.split(@fs).last\n files = Dir.glob \"**#{@fs}*\"\n File.open([name, @ext].join(\".\"), \"wb\") do |tar|\n Minitar.pack(files, tar)\n end\n end",
"def generate(opts={})\n generate_jar(opts).pack\n end",
"def package_agent\n @logger.debug \"Packaging Bosh Agent to #{definition_dest_dir}/_bosh_agent.tar\"\n dst = File.join(definition_dest_dir, \"_bosh_agent.tar\")\n if File.directory? @agent_src_path\n Dir.chdir(@agent_src_path) do\n sh(\"bundle package > /dev/null 2>&1 && gem build bosh_agent.gemspec > /dev/null 2>&1\", {:on_error => \"Unable to build Bosh Agent gem\"})\n Dir.chdir(File.join(@agent_src_path, \"vendor\", \"cache\")) do\n sh(\"tar -cf #{dst} *.gem > /dev/null 2>&1\", {:on_error => \"Unable to package bosh gems\"})\n end\n sh(\"tar -rf #{dst} *.gem > /dev/null 2>&1\", {:on_error => \"Unable to add bosh_agent gem to #{dst}\"})\n end\n else\n FileUtils.cp @agent_src_path, dst\n end\n end",
"def run_bundler options={}\n install_deps 'bundler', :type => Gem\n @shell.call \"cd #{self.checkout_path} && gem bundle\", options\n end",
"def run_bundle ; end",
"def run_bundle ; end",
"def convert_dependencies_to_jars(dependencies = DEPENDENCIES, as_classpath = false)\n ret = dependencies.map{ |d| maven_filename(dependency_to_jar(d)) }\n ret = ret.join(\":\") if as_classpath\n ret\nend",
"def install\n cookbook_gems = Hash.new { |h, k| h[k] = [] }\n\n cookbook_collection.each_value do |cookbook_version|\n cookbook_version.metadata.gems.each do |args|\n if cookbook_gems[args.first].last.is_a?(Hash)\n args << {} unless args.last.is_a?(Hash)\n args.last.merge!(cookbook_gems[args.first].pop) do |key, v1, v2|\n raise Chef::Exceptions::GemRequirementConflict.new(args.first, key, v1, v2) if v1 != v2\n\n v2\n end\n end\n cookbook_gems[args.first] += args[1..]\n end\n end\n\n events.cookbook_gem_start(cookbook_gems)\n\n unless cookbook_gems.empty?\n begin\n Dir.mktmpdir(\"chef-gem-bundle\") do |dir|\n File.open(\"#{dir}/Gemfile\", \"w+\") do |tf|\n Array(Chef::Config[:rubygems_url] || \"https://rubygems.org\").each do |s|\n tf.puts \"source '#{s}'\"\n end\n cookbook_gems.each do |gem_name, args|\n tf.puts \"gem(*#{([gem_name] + args).inspect})\"\n end\n tf.close\n Chef::Log.trace(\"generated Gemfile contents:\")\n Chef::Log.trace(IO.read(tf.path))\n # Skip installation only if Chef::Config[:skip_gem_metadata_installation] option is true\n unless Chef::Config[:skip_gem_metadata_installation]\n # Add additional options to bundle install\n cmd = [ \"bundle\", \"install\", Chef::Config[:gem_installer_bundler_options] ]\n env = {\n \"PATH\" => path_with_prepended_ruby_bin,\n \"BUNDLE_SILENCE_ROOT_WARNING\" => \"1\",\n }\n so = shell_out!(cmd, cwd: dir, env: env)\n Chef::Log.info(so.stdout)\n end\n end\n end\n Gem.clear_paths\n rescue Exception => e\n events.cookbook_gem_failed(e)\n raise\n end\n end\n\n events.cookbook_gem_finished\n end",
"def run\n assets.each do |asset|\n next if ::File.directory?(asset)\n\n compress(asset)\n checksum(asset)\n end\n\n generate_manifest\n end",
"def elasticsearch_jars\n Dir[File.join(settings[:es_lib_dir] || '/usr/lib/hadoop/lib', '{elasticsearch,lucene,jna,wonderdog}*.jar')].compact.uniq\n end",
"def sample_jar(name)\n File.join(File.expand_path(\"../samples\", __FILE__), name)\n end",
"def run_package_for_specified(bundle_info)\n if $options[:buildAll]\n info 'Packaging all dependencies'\n\n $toPackageDeps = []\n\n all_dependencies.each do |dep|\n files = dep.getInstalledFiles\n\n $toPackageDeps.push dep.Name if files && !files.empty?\n end\n\n puts $toPackageDeps.to_s\n end\n\n package_dependencies $toPackageDeps, bundle_info\nend",
"def find_jar(jar)\n oh = java.lang.System.getProperty('EPM_ORACLE_HOME') || ENV['EPM_ORACLE_HOME']\n unless oh\n raise ConfigurationError, \"No EPM_ORACLE_HOME defined. Set this as an environment \" +\n \"variable or Java system property, or else add #{jar} to the classpath.\"\n end\n log.finest \"EPM_ORACLE_HOME is #{oh}\"\n\n sub_dir = STANDARD_JAR_LOCATIONS[jar]\n if (ver_dirs = Dir[\"#{oh}/#{sub_dir}/*\"]) && !ver_dirs.empty?\n ver_dir = ver_dirs.first\n log.finest \"Adding #{ver_dir} dir to load path\"\n $LOAD_PATH << \"#{ver_dir}/lib\"\n require jar\n else\n raise ConfigurationError, \"Cannot locate #{jar} under #{oh}/#{sub_dir}\"\n end\n end",
"def to_zip\n tmpdir = Dir.mktmpdir\n dir = path = nil\n timed_section(Rails.logger, 'app_to_zip') do\n dir = unpack_upload\n synchronize_pool_with(dir)\n path = AppPackage.repack_app_in(dir, tmpdir, :zip)\n zip_path = save_package(path) if path\n end\n ensure\n FileUtils.rm_rf(tmpdir)\n FileUtils.rm_rf(dir) if dir\n FileUtils.rm_rf(File.dirname(path)) if path\n end",
"def package_dependency(dep, bundle_info)\n info \"Starting packaging #{dep}\"\n\n instance = if dep.is_a? String\n dependency_object_by_name dep\n else\n dep\n end\n\n onError \"Invalid dependency name: #{dep}\" unless instance\n\n files = instance.getInstalledFiles\n\n if !files || files.empty?\n error \"Dependency '#{dep}' has no files to package\"\n return nil\n end\n\n # Add symbolic link targets\n links_found = true\n total_links = 0\n handled = []\n\n while links_found\n\n links_found = false\n\n files.each do |f|\n full = File.join(DependencyInstallFolder, f)\n\n next if handled.include? full\n\n next unless File.exist?(full) && File.symlink?(full)\n\n link_target = File.join(File.dirname(f), File.readlink(full))\n\n unless child_path?(DependencyInstallFolder,\n File.join(DependencyInstallFolder, link_target))\n onError 'symbolic link to be installed points outside the dependency folder: ' +\n link_target.to_s\n end\n\n links_found = true\n total_links += 1\n handled.append full\n files.append link_target\n end\n end\n\n handled = nil\n\n info \"Resolved #{total_links} symbolic links in packaged file list\" if total_links > 0\n\n precompiled_name = instance.getNameForPrecompiled + '_' + CurrentPlatform\n zip_name = precompiled_name + '.tar.xz'\n info_file = precompiled_name + '_info.txt'\n hash_file = precompiled_name + '_hash.txt'\n\n # Check that all exist\n Dir.chdir(DependencyInstallFolder) do\n files.each do |f|\n unless File.exist? f\n onError \"Dependency file that should be packaged doesn't exist: \" + f.to_s\n end\n end\n\n files_to_restore = strip_files_if_needed files\n\n File.open(info_file, 'w') do |f|\n f.puts \"RubySetupSystem precompiled library for #{CurrentPlatform}\"\n f.puts instance.Name + ' retrieved from ' + instance.RepoURL\n f.puts instance.Version.to_s + ' Packaged at ' + Time.now.to_s\n f.puts ''\n f.puts \"You can probably find license from the repo url if it isn't included here\"\n f.puts 'This info file is included in ' + zip_name\n end\n\n # When bundling everything needs to be made clean\n File.unlink zip_name if File.exist?(zip_name) && $options[:bundle]\n\n info \"Compressing files into #{zip_name}\"\n\n # Write a tar file with lzma compression\n runSystemSafe('tar', '-cJf', zip_name, info_file, *files)\n\n restore_stripped_files files_to_restore\n\n onError 'Failed to create zip file' unless File.exist? zip_name\n\n hash = SHA3::Digest::SHA256.file(zip_name).hexdigest\n\n # Write hash to file\n File.open(hash_file, 'w') do |f|\n f.puts hash\n end\n\n success \"Done with #{dep}, created: #{zip_name}\"\n info \"#{zip_name} SHA3: \" + hash\n # info \"#{zip_name} PLATFORM: \" + CurrentPlatform\n bundle_info[:dep_files].append zip_name\n return { name: precompiled_name, hash: hash }\n end\nend",
"def archive_to(ant, path)\n if @build_dir.exist?\n path = FilePath.new(path)\n FilePath.new(path.directoryname).ensure_directory\n puts \"Archiving entire build directory ('#@build_dir') to '#{path}'...\"\n\n ant.jar(:destfile => path.to_s) do\n ant.fileset(:dir => @build_dir.to_s,\n :includes => \"**/testrun*/**, **/tests_aggregation/**\",\n :excludes => \"**/*.jar,**/*.class,**/objectdb/**,**/*.war,**/*.rar,**/var/**,**/repository/**,**/META-INF/**\")\n ant.fileset(:dir => @build_dir.to_s,\n :includes => \"**/boot-jars/**,**/build-config.local,**/war/*.war\")\n end\n\n puts \"Done archiving build.\"\n else\n puts \"#{@build_dir.tos_s} does not exist to archive the testrun\"\n end\n\n end",
"def assemble_tgz\n banner \"Assembling #{TAR}...\"\n rm_and_mkdir(DIR)\n \n # gem\n run(\"cp\", [\"-r\", \"#{File.dirname(__FILE__)}/../../lib\", GEM])\n # data\n mkdir(DATA)\n copy = []\n copy << \"Telfile\"\n copy += Dir[\"files*\"]\n copy.sort.each { |i| run(\"cp\", [\"-r\", i, DATA]) }\n # config.sh\n File.open(\"#{DIR}/config\", \"w\") do |f|\n f.puts(\"CONFIG_HOST='#{@options[:host]}'\") \n f.puts(\"CONFIG_RUBY='#{@config.ruby}'\")\n f.puts(\"CONFIG_RUBYGEMS='#{RUBYGEMS}'\") \n end\n # keys\n ssh_key = \"#{ENV[\"HOME\"]}/.ssh/#{PUBKEY}\"\n if File.exists?(ssh_key)\n run(\"cp\", [ssh_key, DIR])\n end\n \n Dir.chdir(File.dirname(DIR)) do\n run(\"tar\", [\"cfpz\", TAR, File.basename(DIR)])\n end\n end",
"def merge_gemfiles(*path, unlock: [])\n gems_remotes = Set.new\n dependencies = Hash.new do |h, k|\n h[k] = Hash.new do |h, k|\n h[k] = Hash.new do |a, b|\n a[b] = Array.new\n end\n end\n end\n path.each do |gemfile|\n bundler_def = Bundler::Dsl.evaluate(gemfile, nil, [])\n gems_remotes |= bundler_def.send(:sources).rubygems_remotes.to_set\n bundler_def.dependencies.each do |d|\n d.groups.each do |group_name|\n if !d.platforms.empty?\n d.platforms.each do |platform_name|\n dependencies[group_name][platform_name][d.name] = d\n end\n else\n dependencies[group_name][''][d.name] = d\n end\n end\n end\n end\n\n contents = []\n gems_remotes.each do |g|\n g = g.to_s\n if g.end_with?('/')\n g = g[0..-2]\n end\n contents << \"source '#{g.to_s}'\"\n end\n dependencies.each do |group_name, by_platform|\n contents << \"group :#{group_name} do\"\n by_platform.each do |platform_name, deps|\n deps = deps.values.sort_by(&:name)\n if !platform_name.empty?\n contents << \" platform :#{platform_name} do\"\n platform_indent = \" \"\n end\n deps.each do |d|\n if d.source\n options = d.source.options.map { |k, v| \"#{k}: \\\"#{v}\\\"\" }\n end\n contents << [\" #{platform_indent}gem \\\"#{d.name}\\\", \\\"#{d.requirement}\\\"\", *options].join(\", \")\n end\n if !platform_name.empty?\n contents << \" end\"\n end\n end\n contents << \"end\"\n end\n contents.join(\"\\n\")\n end",
"def build_resources( build_also_for_bundle )\n validate\n\n @logger.debug \"Resource dirs for AAPT2 builder: #{@res_dir}\"\n\n flat_list = []\n\n flat_list += compile_res_dir_to_flat(@res_dir)\n\n #Add all resources from maven dependencies\n @maven_deps.res_dirs.each {|d|\n flat_list += compile_res_dir_to_flat(d)\n }\n\n reslist = File.join(@intermediate,'flat.txt')\n File.open( reslist, 'w' ) { |f| f.write flat_list.join(' ') } \n \n\n args_common = [ 'link', \n '-I', @androidjar, \n '--manifest', @manifest, \n '-R', '@'+File.join(reslist),\n '--auto-add-overlay'\n ] \n\n if @no_compress_globs\n @no_compress_globs.each do |ext|\n args_common << '-0'\n args_common << ext\n end\n end\n\n @intermediate_apk = File.join(@intermediate,'output.apk')\n #make a dir to put generated R.java\n rdir = File.join(@intermediate,'rjava')\n mkdir_p (rdir)\n\n args = args_common.clone\n args << '-o'\n args << @intermediate_apk \n args << '--java'\n args << PathToWindowsWay(rdir)\n args << '--output-text-symbols'\n args << PathToWindowsWay(File.join(@rjava_dir, 'R.txt')) \n\n mkdir_p @rjava_dir \n #Finally run link to generate R.java for compiled resources. We need manifest ready at this point\n run_aapt2(args) \n\n #-A option is buggy at least on Windows. It writes \\\\ instead of / to path separators which will affect MANIFEST.MF in target APK and break access to assets\n #So we'll use zip to add assets manually\n #args << \"-A\"\n #args << @assets_dir\n Zip::File.open( @intermediate_apk, create: false ) { |z|\n root = Pathname.new(@assets_dir)\n Dir[File.join(@assets_dir,'**','*')].select{|f| File.file? f}.each{ |f|\n p = Pathname.new(f)\n z.add( File.join('assets',p.relative_path_from(root)) ,f )\n }\n }\n\n if ( build_also_for_bundle )\n #prepared archive name with protobuf data\n @pbprep = File.join(@intermediate,'output_for_bundle.apk')\n\n args_for_bundle = args_common.clone\n args_for_bundle << '-o'\n args_for_bundle << @pbprep \n args_for_bundle << '--proto-format' \n run_aapt2(args_for_bundle) \n end\n \n #We don't really care of package name and relative path where R.java is located\n #We just need to put generated R.java to specified @rjava_dir, so let's just find generated R.java and put it to target dir\n Dir[ File.join(rdir,'**','R.java') ].each { |f|\n cp_r( f, @rjava_dir )\n } \n end",
"def tarball\n Dir[\"#{dest}/#{SCOPE}-#{gemspec.name}-#{gemspec.version}.tgz\"].first\n end",
"def create_archive(opts = {})\n archive = normalize_archive_name( find_option( opts, 'name' ) || archive_name )\n app_dir = find_option( opts, 'app_dir' ) || Dir.pwd\n dest_dir = find_option( opts, 'dest_dir' ) || Dir.pwd\n excludes = find_option( opts, 'exclude' ) || \"\"\n should_precompile_assets = find_option( opts, 'precompile_assets' ) == true\n should_package_gems = find_option( opts, 'package_gems' ) == true\n package_without = find_option( opts, 'package_without' ) || Array.new\n\n if should_precompile_assets\n precompile_assets( app_dir )\n raise 'Error precompiling assets' unless $? == 0\n end\n\n archive_path = File.join( dest_dir, archive )\n archive_proc = lambda { create_knob_archive( app_dir, archive_path, excludes ) }\n\n if should_package_gems\n package_gems( app_dir, package_without ) {\n raise 'Error packaging gems' unless $? == 0\n archive_proc.call\n }\n else\n archive_proc.call\n end\n\n archive_path\n end"
] | [
"0.7421737",
"0.68111247",
"0.6689431",
"0.6677503",
"0.64717484",
"0.63810694",
"0.634262",
"0.6281837",
"0.62714773",
"0.6116783",
"0.60159737",
"0.5992325",
"0.59511906",
"0.5786924",
"0.5767364",
"0.5765505",
"0.57531726",
"0.56808",
"0.55749744",
"0.5507944",
"0.54144675",
"0.5409724",
"0.53790164",
"0.5363302",
"0.5362579",
"0.5362479",
"0.5329358",
"0.5309225",
"0.5299045",
"0.52917194",
"0.52884024",
"0.5271462",
"0.5270087",
"0.51980585",
"0.5196847",
"0.51702046",
"0.51524895",
"0.5151187",
"0.5088948",
"0.5086551",
"0.5084615",
"0.508423",
"0.5084006",
"0.5079806",
"0.5047277",
"0.5025958",
"0.5016494",
"0.50114995",
"0.49934387",
"0.49934387",
"0.49920577",
"0.49884355",
"0.49858388",
"0.49774405",
"0.49493396",
"0.49450186",
"0.49300724",
"0.49296075",
"0.49237898",
"0.49185726",
"0.49123886",
"0.49093667",
"0.49050808",
"0.4900624",
"0.48984525",
"0.48920795",
"0.48913115",
"0.4871754",
"0.48683175",
"0.48659506",
"0.48437837",
"0.4827902",
"0.4821958",
"0.48163912",
"0.4816261",
"0.48004255",
"0.4799188",
"0.47884017",
"0.47871944",
"0.4781972",
"0.47814122",
"0.47741213",
"0.47690934",
"0.476758",
"0.476758",
"0.4762986",
"0.47623783",
"0.47608104",
"0.47507247",
"0.47502342",
"0.47319883",
"0.4728071",
"0.47155285",
"0.47114706",
"0.47091308",
"0.47060958",
"0.46848327",
"0.46835545",
"0.46777064",
"0.46773037"
] | 0.74910843 | 0 |
GET /daties GET /daties.json | def index
@daties = Daty.all.order(updated_at: :desc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n render json: WeatherDatum.all\n end",
"def index\n @dossiers = Dossier.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dossiers }\n end\n end",
"def index\n @data = Datum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data }\n end\n end",
"def index\n @dices = Dice.all\n\n render json: @dices\n end",
"def index\n @dinos = Dino.where(query_params)\n render json: @dinos\n end",
"def index\n @diaries = current_user.diaries.all\n respond_to do |format|\n format.html {render :index}\n format.json { render json: @diaries }\n end\n end",
"def index\n\n @dtests = Dtest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dtests }\n end\n end",
"def index\n @denuncia = Denuncium.all\n\n render json: @denuncia\n end",
"def index\n weathers = Weather.all\n render json: weathers, status: 200\n end",
"def index\n\n require 'net/http'\n require 'json'\n\n @measures = Measure.all.order(\"created_at DESC\")\n weatherData\n\n end",
"def show\n @datum = Datum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datum }\n end\n end",
"def show\n @datum = Datum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datum }\n end\n end",
"def index\n\t\t@dairies = Dairy.all\n\tend",
"def show\n @skydatum = Skydatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skydatum }\n end\n end",
"def consulta\n fiesta = Fiesta.all\n render json: fiesta\n end",
"def index\n @my_dairies = MyDairy.all\n end",
"def index\n @dnas = Dna.all\n\n render json: @dnas\n end",
"def index\n @weather_station = WeatherStation.find(params[:weather_station_id])\n @meteo_data = []\n @meteo_data = @weather_station.meteo_datums.order('created_at desc').limit(100) unless @weather_station.blank?\n\n render 'api/v1/meteo_data/index', params: [@weather_station, @meteo_data]\n end",
"def index\n @duty_stations = DutyStation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @duty_stations }\n end\n end",
"def index\n\n get_collections\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deities }\n format.js {}\n end\n end",
"def index\n @djs = Dj.all\n end",
"def show\n json = self.as_json(only: [:created_at, :version])\n json['url'] = doi_url\n json\n end",
"def index\n\n @data = Datum.all\n end",
"def index\n @dolgnosts = Dolgnost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dolgnosts }\n end\n end",
"def getJson\n render json: getData()\n end",
"def dayIndex\n render json: Restaurant.restaurantsDay\n end",
"def index\n @wods = Wod.order(\"created_at DESC\")\n\n render json: @wods\n end",
"def index\n @specialties = Specialty.all\n\n render json: @specialties\n end",
"def index\n @dia_eventos = DiaEvento.all\n render json: @dia_eventos\n end",
"def show\n @daily_statistic = DailyStatistic.find(params[:id])\n\n render json: @daily_statistic\n end",
"def show\n render json: @dice\n end",
"def index\n if params[:q]\n url = \"http://api.worldweatheronline.com/premium/v1/tz.ashx?q=#{params[:q]}&format=json&key=2c46659bd90a41a0bcf132257162410\"\n @json = ActiveSupport::JSON.decode(open(url).read)\n else\n end\n end",
"def index\n @data_collections = DataCollection.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data_collections }\n end\n end",
"def index\n @daily_horoscopes = DailyHoroscope.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @daily_horoscopes }\n end\n end",
"def index\n @days = @trip.days.order(trip_day: :asc)\n render json: @days, include: [:activities]\n end",
"def show\n @dato = Dato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dato }\n end\n end",
"def get_data\n users_without_admin = User.where(\"name != 'admin'\").count\n users = Userarchyves.select('user_id, food, voted_for').where(archyves_id: current_round.id).all\n retaurants = Restaurant.select('id, votes').all\n \n # return json \n respond_to do |format|\n format.json {\n render json: {\n users: users.as_json(only: [:user_id, :food, :voted]),\n restaurants: retaurants.as_json(only: [:id, :votes]),\n winner: winner.as_json(only: [:id]),\n food_history: food_history.as_json(only: [:food]),\n round_end: round_ended?.as_json\n }\n }\n end\n end",
"def index\n @zones = Zone.all\n\n render json: @zones\n end",
"def index\n @dbh_measurements = DbhMeasurement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dbh_measurements }\n end\n end",
"def index\n @joys = Joy.all\n render json: @joys\n end",
"def days\n @trainings = Training.all\n @activities = Activity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trainings }\n end\n end",
"def show\n @internship = Internship.find(params[:id])\n @diaries = Diary.where(:internship_id => @internship.id).paginate(:page => params[:page]).order('id DESC')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @internship }\n end\n end",
"def index\n @dairy_plans = DairyPlan.where(:student_id => @student.id)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dairy_plans }\n end\n end",
"def show\n dinosaurs = Dinosaur.filter_by_species(params[:species])\n\n if dinosaurs\n render json: dinosaurs\n else\n render json: dinosaurs.errors, status: :unprocessable_entity\n end\n end",
"def dates\n render json: @standings\n end",
"def index\n @deseases = Desease.order(:id)\n\n render json: @deseases\n end",
"def show\n @energy_datum = EnergyDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @energy_datum }\n end\n end",
"def index\n @diciplinas = Diciplina.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @diciplinas }\n end\n end",
"def index\n @daters = Dater.all\n end",
"def index\n @zones = Zone.all\n render json: @zones\n #@zones\n end",
"def index\n @tipo_denuncia = TipoDenuncium.all\n\n render json: @tipo_denuncia\n end",
"def show\n @dayoff = Dayoff.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dayoff }\n end\n end",
"def index\n data = get_index_data\n @dayoffs = data.page(params[:current_page]).per(PER_PAGE)\n respond_to do |format|\n format.html {\n render \"dashboards/admin_dashboard\"\n }\n\n format.json {\n render json: {\n total_page: @data.total_page,\n data: ActiveModel::SerializableResource.new(@dayoffs, each_serializer: AdminDayoffSerializer)\n }, status: :ok\n }\n end\n end",
"def index\n @rides = Ride.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @rides\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render json: DeliveriesDatatable.new(view_context) }\n end\n end",
"def index\n @diets = @profile.diets\n respond_with @diets\n end",
"def show\n @data = Datum.find(params[:datum_id])\n end",
"def index\n puts \"user: #{@current_user.json_hash[:id]}\"\n hosted_dinners = []\n attended_dinners = []\n @hosted_dinners = @current_user.hosted_dinners.where('starts_at >= ?', \"#{Time.now}\").order(starts_at: :asc).each do |dinner|\n hosted_dinners << dinner.all_info\n end\n @attended_dinners = @current_user.attended_dinners.where('starts_at >= ?', \"#{Time.now}\").order(starts_at: :asc).each do |dinner|\n attended_dinners << dinner.all_info\n end\n render json: {\n hosting: hosted_dinners,\n attending: attended_dinners\n }\n end",
"def index\n birds = Bird.all\n render json: birds.to_json(except: [:created_at, :updated_at])\n end",
"def index\n @data_points = DataPoint.recent # cached_recent\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data_points }\n end\n end",
"def index\n @distros = getmydata(\"Distro\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @distros }\n end\n end",
"def index\n @jsons = Json.all\n end",
"def dresses\n render json: { collections: Collection.published_dresses }\n end",
"def index\n @flights = Flight.all\n render json: @flights\n end",
"def set_weather_datum\n render json: WeatherDatum.find(params[:id])\n end",
"def show\n @kf_diary = Kf::Diary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kf_diary }\n end\n end",
"def index\n @departamentos = Departamento.all\n\n render json: @departamentos\n end",
"def index\n @dogs = Dog.all\n render json: @dogs, each_serializer: DogSerializer, root: 'dogs'\n end",
"def index\n @data_tables = DataTable.all\n\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @data_tables.as_json(only: [:title, :username, :name, :email, :hometown]) }\n # end\n end",
"def weather\n # empty array dates is still fine, not a reason for 400 (happens for venues without courts)\n render json: {} and return if params.dig(:dates).blank?\n\n forecast = WeatherForecaster.call(venue, [*params.require(:dates)])\n json = forecast.transform_values do |value|\n value ? value.slice(*%w(icon temperature)) : nil\n end\n render json: json\n end",
"def fetch_json\n res = open(\"http://www.cleanairmakemore.com/widget_json.cfm\").read\n\n # Documented in views/burn/phx/data.json.\n s = res.index(\"facts\")\n json = res[0, s-4] + \"}\"\n\n # json = File.read(\"views/burn/phx/data.json\")\n json\n end",
"def home\n @json_all_activities = Activity.all.to_json\n @json_featured_activities = Activity.find_all_by_featured(true).to_json\n @json_all_zones = Zone.find(:all, :order => \"name\").to_json\n @json_featured_zones = Zone.find_all_by_featured(true, :order => \"name\").to_json\n end",
"def index\n @stats = Stat.all\n\n render json: {data:\n @stats.map {|stat|\n days = range_to_days(stat)\n {\n total_seconds: stat.total_seconds,\n human_readable_total: humanize(stat.total_seconds),\n daily_average: stat.daily_average,\n human_readable_daily_average: humanize(stat.daily_average),\n range: stat.range,\n holidays: stat.holidays,\n days_including_holidays: days,\n days_minus_holidays: days - stat.holidays,\n status: stat.status,\n is_already_updating: stat.is_already_updating,\n is_stuck: stat.is_stuck,\n is_up_to_date: stat.is_up_to_date,\n timeout: stat.timeout,\n editors: stat.editors.map {|e|\n {\n name: e.name,\n total_seconds: e.total_seconds,\n percent: e.percent\n }\n }\n }\n }}\n end",
"def index\n # @weekdays = Weekday.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Oj.dump(@weekdays, mode: :compat) }\n end\n end",
"def index\n @weddings = Wedding.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @weddings }\n end\n end",
"def diaries\n\t\t@diaries = current_user.diaries.desc(:date).limit(7)\n\n\t\trender 'clients/diary/diaries' \n\tend",
"def index\n @ducks = Duck.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ducks }\n end\n end",
"def index\n @datasets = Dataset.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @datasets }\n end\n end",
"def index\n @tour_dates = TourDate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tour_dates }\n end\n end",
"def index\n @funds = Fund.all\n\n render json: @funds\n end",
"def index\n if params[:patient_id]\n @patient = Patient.find(params[:patient_id])\n @diseases = @patient.diseases\n else\n @patient = nil\n @diseases = Disease.all\n end\n respond_to :html, :json, :js\n end",
"def index_hosting\n puts \"user: #{@current_user.json_hash[:id]}\"\n dinners = []\n @dinners = @current_user.hosted_dinners\n @dinners.each do |dinner|\n dinners << dinner.all_info\n end\n render json: dinners\n end",
"def index\r\n @classdays = Classday.all\r\n\r\n render json: @classdays\r\n end",
"def show\n render json: @dino\n end",
"def food_info(food_id)\n get(\"/foods/#{food_id}.json\")\n end",
"def show\n render 'api/v1/meteo_data/show', params: @meteo_datum\n end",
"def getDate\n @sales = Sale.where(\"date = ?\", params[:date])\n render json: @sales\n end",
"def index\n @things = current_user.things.where('the_date >= ?', Date.today ).order('the_date ASC')\n @thing_day = @things.group_by { |t| t.the_date }\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @things }\n end\n end",
"def index\n @breeds = Breed.all\n\n render json: @breeds\n end",
"def index\n @karyalay_caterers = KaryalayCaterer.all\n render json: @karyalay_caterers\n end",
"def index\n @heights = Height.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @heights }\n end\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 show\n @basin = Basin.find(params[:id])\n\n @client = YahooWeather::Client.new \n @response = @client.fetch_by_location('Massingir, Gaza, Mz','c')\n @reponse2 = @client.fetch_by_location('Louis Trichardt, Limpopo, South Africa','c')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @basin }\n\n end\n end",
"def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end",
"def index\n @jsons = Json.all\n\n\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: SoldiersDatatable.new(view_context) }\n end\n end",
"def index\n @varieties = Variety.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @varieties }\n end\n end",
"def showByLocation\n location_id=params[:location_id]\n loc=Location.find_by(location_id:location_id)\n if loc!=nil\n @weathers=loc.weathers.where(\"date=?\",params[:date])\n @weathers_currently = Parser.currentWeather params[:location_id]\n if @weathers==nil\n @weathers=[]\n end\n else\n @weathers=[]\n @weathers_currently={}\n end\n\n respond_to do |format|\n format.html\n format.json #json format is implemented in *.json.erb file\n end\n end",
"def index\n locations = Location.all\n render json: locations\n end",
"def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end"
] | [
"0.66285557",
"0.65773255",
"0.6513484",
"0.64763695",
"0.63176906",
"0.61696565",
"0.6093377",
"0.6087909",
"0.6086818",
"0.60836077",
"0.60710794",
"0.60710794",
"0.60502076",
"0.60462576",
"0.60323244",
"0.6015316",
"0.6012293",
"0.60026836",
"0.59943765",
"0.5985998",
"0.5985104",
"0.59740174",
"0.59342474",
"0.5922659",
"0.5904718",
"0.59009284",
"0.5887125",
"0.5886336",
"0.5886195",
"0.58860123",
"0.58593404",
"0.5823592",
"0.5802559",
"0.5799748",
"0.5787088",
"0.57865363",
"0.57801545",
"0.57781315",
"0.57701373",
"0.57662797",
"0.5765948",
"0.5763699",
"0.57555646",
"0.57502013",
"0.57490915",
"0.5748084",
"0.5743685",
"0.5738469",
"0.57346606",
"0.5724157",
"0.57197726",
"0.57178575",
"0.5713409",
"0.5712748",
"0.5706087",
"0.5700211",
"0.5697048",
"0.56851393",
"0.5676745",
"0.56732893",
"0.5671734",
"0.56712645",
"0.5664367",
"0.5663697",
"0.56560344",
"0.56546766",
"0.5651925",
"0.5649241",
"0.56481516",
"0.5645705",
"0.5639071",
"0.56320614",
"0.5629384",
"0.5628852",
"0.56230927",
"0.56215566",
"0.5620762",
"0.56153566",
"0.5614602",
"0.56033885",
"0.5602012",
"0.55996275",
"0.5599456",
"0.5599144",
"0.5598739",
"0.5583582",
"0.55833215",
"0.5580014",
"0.5580009",
"0.5574769",
"0.55744267",
"0.55663025",
"0.55602616",
"0.5559673",
"0.55585563",
"0.55493987",
"0.5545676",
"0.5543493",
"0.5542442",
"0.55354506"
] | 0.5953204 | 22 |
GET /daties/1 GET /daties/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @data = Datum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data }\n end\n end",
"def show\n @datum = Datum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datum }\n end\n end",
"def show\n @datum = Datum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datum }\n end\n end",
"def index\n render json: WeatherDatum.all\n end",
"def index\n @dossiers = Dossier.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dossiers }\n end\n end",
"def show\n @data = Datum.find(params[:datum_id])\n end",
"def show\n json = self.as_json(only: [:created_at, :version])\n json['url'] = doi_url\n json\n end",
"def index\n @dinos = Dino.where(query_params)\n render json: @dinos\n end",
"def show\n @skydatum = Skydatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skydatum }\n end\n end",
"def show\n @daily_statistic = DailyStatistic.find(params[:id])\n\n render json: @daily_statistic\n end",
"def index\n @dices = Dice.all\n\n render json: @dices\n end",
"def show\n @dato = Dato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dato }\n end\n end",
"def show\n @energy_datum = EnergyDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @energy_datum }\n end\n end",
"def show_dataset\n @dataset = Dataset.find(params[:dataset_id])\n @data = (ActiveRecord::Base.connection.select_all(\"SELECT * from dataset_#{@dataset.id} ORDER BY id ASC\")).to_json\n render :inline => @data\n end",
"def index\n @weather_station = WeatherStation.find(params[:weather_station_id])\n @meteo_data = []\n @meteo_data = @weather_station.meteo_datums.order('created_at desc').limit(100) unless @weather_station.blank?\n\n render 'api/v1/meteo_data/index', params: [@weather_station, @meteo_data]\n end",
"def index\n weathers = Weather.all\n render json: weathers, status: 200\n end",
"def index\n\n require 'net/http'\n require 'json'\n\n @measures = Measure.all.order(\"created_at DESC\")\n weatherData\n\n end",
"def index\n\n @dtests = Dtest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dtests }\n end\n end",
"def index\n\n @data = Datum.all\n end",
"def show\n @data_point = DataPoint.find(params[:id])\n\n if @data_point\n render json: @data_point\n else\n render json: @data_point, status: 404\n end\n end",
"def show\n @historial_odt = HistorialOdt.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @historial_odt }\n end\n end",
"def getJson\n render json: getData()\n end",
"def set_weather_datum\n render json: WeatherDatum.find(params[:id])\n end",
"def show\n @raw_datum = RawDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @raw_datum }\n end\n end",
"def show\n render 'api/v1/meteo_data/show', params: @meteo_datum\n end",
"def consulta\n fiesta = Fiesta.all\n render json: fiesta\n end",
"def show\n @item_datum = ItemData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item_datum }\n end\n end",
"def getData(data_of, id)\n url_data = stringGetUrlPath(data_of)\n url_request = \"#{url_data}/#{id}\"\n response_data = readData(url_request)\n return response_data\n end",
"def index\n @denuncia = Denuncium.all\n\n render json: @denuncia\n end",
"def index\n @duty_stations = DutyStation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @duty_stations }\n end\n end",
"def index\n @patients = Patient.order('last_name ASC')\n\n #find the latest patient made\n @id = Patient.maximum(:id)\n if(@id != nil)\n @patient = Patient.find(@id)\n File.open(\"public/patient_info.json\", \"w\"){ |f| f << @patient.to_json}\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dataset }\n end\n end",
"def index\n @daties = Daty.all.order(updated_at: :desc)\n end",
"def index\n @diaries = current_user.diaries.all\n respond_to do |format|\n format.html {render :index}\n format.json { render json: @diaries }\n end\n end",
"def dayIndex\n render json: Restaurant.restaurantsDay\n end",
"def index\n @data_collections = DataCollection.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data_collections }\n end\n end",
"def show\n dog = Dog.find(params[:id])\n render json: dog\n end",
"def food_info(food_id)\n get(\"/foods/#{food_id}.json\")\n end",
"def index\n @datasets = Dataset.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @datasets }\n end\n end",
"def show\n @dayoff = Dayoff.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dayoff }\n end\n end",
"def index\n @specialties = Specialty.all\n\n render json: @specialties\n end",
"def index\n @data_points = DataPoint.recent # cached_recent\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data_points }\n end\n end",
"def show\n @daily_exercise = DailyExercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daily_exercise }\n end\n end",
"def index\n\n get_collections\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deities }\n format.js {}\n end\n end",
"def index\n @djs = Dj.all\n end",
"def index\n @dnas = Dna.all\n\n render json: @dnas\n end",
"def show\n @basin = Basin.find(params[:id])\n\n @client = YahooWeather::Client.new \n @response = @client.fetch_by_location('Massingir, Gaza, Mz','c')\n @reponse2 = @client.fetch_by_location('Louis Trichardt, Limpopo, South Africa','c')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @basin }\n\n end\n end",
"def show\n @internship = Internship.find(params[:id])\n @diaries = Diary.where(:internship_id => @internship.id).paginate(:page => params[:page]).order('id DESC')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @internship }\n end\n end",
"def showJSON\n\n\t\trender json: UrlDataModel.find(params[:id])\n\n\tend",
"def index\n @wods = Wod.order(\"created_at DESC\")\n\n render json: @wods\n end",
"def show\n @kf_diary = Kf::Diary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kf_diary }\n end\n end",
"def show\n @cycdatum = Cycdatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cycdatum }\n end\n end",
"def index\n @dolgnosts = Dolgnost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dolgnosts }\n end\n end",
"def index\n @dbh_measurements = DbhMeasurement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dbh_measurements }\n end\n end",
"def show\n @question_datum = QuestionDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_datum }\n end\n end",
"def index\n @dia_eventos = DiaEvento.all\n render json: @dia_eventos\n end",
"def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end",
"def index\n\t\t@dairies = Dairy.all\n\tend",
"def show\n @article_datum = ArticleDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @article_datum }\n end\n end",
"def show\n @dress = Dress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dress }\n end\n end",
"def show\n @daily_inventory = DailyInventory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daily_inventory }\n end\n end",
"def show\n @datoscontacto = Datoscontacto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datoscontacto }\n end\n end",
"def traffic id, date = Date.today.to_s\n uri = \"#{BASE_URL}/gauges/#{id}/traffic?date=#{date}\"\n fetch uri\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 @distros = getmydata(\"Distro\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @distros }\n end\n end",
"def index\n @my_dairies = MyDairy.all\n end",
"def details\n @daily_deal = DailyDeal.find(params[:id])\n respond_to do |format|\n format.json do\n render with_api_version\n end\n end\n end",
"def show\n @data_collection = DataCollection.find(params[:id])\n @questionnaires = @data_collection.questionnaires\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @data_collection }\n end\n end",
"def index\n @daily_horoscopes = DailyHoroscope.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @daily_horoscopes }\n end\n end",
"def show\n @dailyStanding = DailyStanding.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @dailyStanding }\n end\n end",
"def show\n @dtest = Dtest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dtest }\n end\n end",
"def show \n bird = Bird.find_by(id: params[:id])\n # render json: {id: bird.id, name: bird.name, species: bird.species} \n #* could also use slice\n # render json: bird.slice(:id,:name:species)\n #* better option to be specific\n # render json: bird, only: [:id,:name,:species]\n #* alternatively can choose to exluse\n render json: bird, except: [:created_at, :updated_at] \n # this is how it looked behind the scenes: render json: birds.to_json(except: [:created_at, :updated_at])\nend",
"def show\n render json: @dice\n end",
"def index\n @joys = Joy.all\n render json: @joys\n end",
"def show\n @seo_datum = SeoDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seo_datum }\n end\n end",
"def show\n @data = @recipe.read(params[:id])\n render json: @data\n end",
"def show\n @sales_datum = SalesDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_datum }\n end\n end",
"def fetch_json\n res = open(\"http://www.cleanairmakemore.com/widget_json.cfm\").read\n\n # Documented in views/burn/phx/data.json.\n s = res.index(\"facts\")\n json = res[0, s-4] + \"}\"\n\n # json = File.read(\"views/burn/phx/data.json\")\n json\n end",
"def get_one\n question_data = Question.new.get_one( params[:id] )\n return render json: question_data\n end",
"def get_patient\n @patient = Patient.pluck(:id,:name)\n render json: @patient\n end",
"def show\n @dj = Dj.find(params[:id])\n if params[:format] == :json\n respond_with @dj\n else\n render 'root/index'\n end\n\n end",
"def show\n @dc = Dc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @dc }\n end\n end",
"def show\n @weather = Weather.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @weather }\n end\n end",
"def show\n @weather = Weather.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @weather }\n end\n end",
"def show\n @enterprise_datum = EnterpriseDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enterprise_datum }\n end\n end",
"def show\n @dteor = Dteor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dteor }\n end\n end",
"def data\n @gesturedata = Gesture.select('data').where(\"id =?\" , params[:id])\n render json: @gesturedata[0][:data]\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dbh_measurement }\n end\n end",
"def getDate\n @sales = Sale.where(\"date = ?\", params[:date])\n render json: @sales\n end",
"def show\n @joy = Joy.find(params[:id])\n render json: @joy\n end",
"def index\n @dairy_plans = DairyPlan.where(:student_id => @student.id)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dairy_plans }\n end\n end",
"def show\n @dymmmy = Dymmmy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dymmmy }\n end\n end",
"def index\n data = get_index_data\n @dayoffs = data.page(params[:current_page]).per(PER_PAGE)\n respond_to do |format|\n format.html {\n render \"dashboards/admin_dashboard\"\n }\n\n format.json {\n render json: {\n total_page: @data.total_page,\n data: ActiveModel::SerializableResource.new(@dayoffs, each_serializer: AdminDayoffSerializer)\n }, status: :ok\n }\n end\n end",
"def index\n birds = Bird.all\n render json: birds.to_json(except: [:created_at, :updated_at])\n end",
"def show\n @idiom = Idiom.find(params[:id])\n @essays = Essay.where(idiom_id: params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @idiom }\n end\n end",
"def show\n @county = County.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @county }\n end\n end",
"def index\n @tipo_denuncia = TipoDenuncium.all\n\n render json: @tipo_denuncia\n end",
"def index\n if params[:q]\n url = \"http://api.worldweatheronline.com/premium/v1/tz.ashx?q=#{params[:q]}&format=json&key=2c46659bd90a41a0bcf132257162410\"\n @json = ActiveSupport::JSON.decode(open(url).read)\n else\n end\n end",
"def show\n @day_list = DayList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @day_list }\n end\n end",
"def index\n @dogs = Dog.all\n render json: @dogs, each_serializer: DogSerializer, root: 'dogs'\n end",
"def show\n @datastore = Datastore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datastore }\n end\n end"
] | [
"0.65137297",
"0.63814336",
"0.63814336",
"0.63604116",
"0.63084036",
"0.6123568",
"0.6097422",
"0.60878927",
"0.6086345",
"0.60814965",
"0.6051762",
"0.60254365",
"0.59646183",
"0.5955802",
"0.5940997",
"0.5923522",
"0.5884963",
"0.58788383",
"0.58704484",
"0.58594525",
"0.5854748",
"0.58510965",
"0.5838656",
"0.58328867",
"0.58120376",
"0.57984084",
"0.5797373",
"0.5796456",
"0.5794326",
"0.5793786",
"0.5785616",
"0.5778363",
"0.57771355",
"0.5772586",
"0.57673573",
"0.5763176",
"0.5762826",
"0.5761315",
"0.57549894",
"0.57532275",
"0.5752005",
"0.5747955",
"0.5745974",
"0.5744394",
"0.5740156",
"0.57388365",
"0.5733888",
"0.57202685",
"0.57099634",
"0.5704871",
"0.5698177",
"0.56962574",
"0.56945807",
"0.5691558",
"0.56881034",
"0.5686075",
"0.5668883",
"0.5668185",
"0.56667185",
"0.5664082",
"0.56587523",
"0.5654647",
"0.56462026",
"0.56453806",
"0.56422806",
"0.56376666",
"0.5630846",
"0.562708",
"0.5626458",
"0.5622731",
"0.5621301",
"0.5620039",
"0.56188875",
"0.56180215",
"0.56084704",
"0.5607134",
"0.5601407",
"0.5599638",
"0.5597636",
"0.5592317",
"0.55921954",
"0.55913836",
"0.55896986",
"0.55896986",
"0.55887663",
"0.5586278",
"0.5584977",
"0.55834913",
"0.5582922",
"0.55775243",
"0.5571408",
"0.5570594",
"0.55688155",
"0.55683047",
"0.5563124",
"0.55582434",
"0.55555624",
"0.55552197",
"0.55548793",
"0.55539334",
"0.5551859"
] | 0.0 | -1 |
POST /daties POST /daties.json | def create
@daty = current_user.daties.build(daty_params)
respond_to do |format|
if @daty.save
format.html { redirect_to @daty, notice: 'Daty was successfully created.' }
format.json { render :show, status: :created, location: @daty }
else
format.html { render :new }
format.json { render json: @daty.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @meteo_datum = MeteoDatum.new(meteodatum_params)\n @meteo_datum.weather_station_id = params[:weather_station_id]\n\n if @meteo_datum.save\n render json: @meteo_datum, status: :created\n else\n render json: @meteo_datum.errors, status: :unprocessable_entity\n end\n end",
"def create\n @datum = Datum.new(params[:datum])\n\n respond_to do |format|\n if @datum.save\n format.html { redirect_to @datum, notice: 'Datum was successfully created.' }\n format.json { render json: @datum, status: :created, location: @datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @datum = Datum.new(datum_params)\n\n respond_to do |format|\n if @datum.save\n format.html { redirect_to @datum, notice: 'Datum was successfully created.' }\n format.json { render :show, status: :created, location: @datum }\n else\n format.html { render :new }\n format.json { render json: @datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @datat_table_datum = DatatTableDatum.new(datat_table_datum_params)\n\n respond_to do |format|\n if @datat_table_datum.save\n format.html { redirect_to @datat_table_datum, notice: 'Datat table datum was successfully created.' }\n format.json { render :show, status: :created, location: @datat_table_datum }\n else\n format.html { render :new }\n format.json { render json: @datat_table_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @skydatum = Skydatum.new(params[:skydatum])\n\n respond_to do |format|\n if @skydatum.save\n format.html { redirect_to @skydatum, notice: 'Skydatum was successfully created.' }\n format.json { render json: @skydatum, status: :created, location: @skydatum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @skydatum.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 @test_datum = TestDatum.new(test_datum_params)\n\n respond_to do |format|\n if @test_datum.save\n format.html { redirect_to @test_datum, notice: 'Test datum was successfully created.' }\n format.json { render :show, status: :created, location: @test_datum }\n else\n format.html { render :new }\n format.json { render json: @test_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dato = Dato.new(params[:dato])\n\n respond_to do |format|\n if @dato.save\n format.html { redirect_to @dato, notice: 'Dato was successfully created.' }\n format.json { render json: @dato, status: :created, location: @dato }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, data = {})\n request 'POST', path, body: data.to_json\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 create\n @iot_datum = IotDatum.new(iot_datum_params)\n\n respond_to do |format|\n if @iot_datum.save\n format.html { redirect_to @iot_datum, notice: 'Iot datum was successfully created.' }\n format.json { render :show, status: :created, location: @iot_datum }\n else\n format.html { render :new }\n format.json { render json: @iot_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @tracked_datum = TrackedDatum.new(tracked_datum_params)\n\n respond_to do |format|\n if @tracked_datum.save\n format.html { redirect_to @tracked_datum, notice: 'Tracked datum was successfully created.' }\n format.json { render :show, status: :created, location: @tracked_datum }\n else\n format.html { render :new }\n format.json { render json: @tracked_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item_datum = ItemData.new(params[:item_datum])\n\n respond_to do |format|\n if @item_datum.save\n format.html { redirect_to @item_datum, notice: 'Item datum was successfully created.' }\n format.json { render json: @item_datum, status: :created, location: @item_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def datum_params\n params.require(:datum).permit(:name, :value)\n end",
"def create\n @dataset_datum = DatasetDatum.new(dataset_datum_params)\n\n respond_to do |format|\n if @dataset_datum.save\n format.html { redirect_to @dataset_datum, notice: 'Dataset datum was successfully created.' }\n format.json { render action: 'show', status: :created, location: @dataset_datum }\n else\n format.html { render action: 'new' }\n format.json { render json: @dataset_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @scrapping_datum = ScrappingDatum.new(scrapping_datum_params)\n\n respond_to do |format|\n if @scrapping_datum.save\n format.html { redirect_to @scrapping_datum, notice: 'Scrapping datum was successfully created.' }\n format.json { render :show, status: :created, location: @scrapping_datum }\n else\n format.html { render :new }\n format.json { render json: @scrapping_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @energy_datum = EnergyDatum.new(params[:energy_datum])\n\n respond_to do |format|\n if @energy_datum.save\n format.html { redirect_to @energy_datum, notice: 'Energy datum was successfully created.' }\n format.json { render json: @energy_datum, status: :created, location: @energy_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @energy_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @input_datum.update(params[:input_data].keys, params[:input_data].values)\n format.html { redirect_to @input_datum, notice: 'Input datum was successfully created.' }\n format.json { render :show, status: :created, location: @input_datum }\n else\n format.html { render :new }\n format.json { render json: @input_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def daty_params\n params.require(:daty).permit(:start_date, :end_date, :localisation)\n end",
"def create\n @dice = Dice.new(dice_params)\n\n if @dice.save\n render json: @dice, status: :created, location: @dice\n else\n render json: @dice.errors, status: :unprocessable_entity\n end\n end",
"def create\n @question_datum = QuestionDatum.new(params[:question_datum])\n\n respond_to do |format|\n if @question_datum.save\n format.html { redirect_to @question_datum, notice: 'Question datum was successfully created.' }\n format.json { render json: @question_datum, status: :created, location: @question_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @question_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name].compact.join('/')\n url += \"/\"\n return HTTParty.post(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end",
"def create\n current_account.parties.create(params[:parties].values)\n @date = params[:parties].values.first[:created_at].to_time\n @parties = current_account.parties.by_month(@date.month, :year => @date.year)\n @daily = @parties.select{|p| p.created_at.to_date == @date.to_date}.group_by(&:game)\n @count = @parties.size\n find_yours(@parties)\n @games = compute_monthly_played(@parties, @date.beginning_of_month)\n respond_to do |format|\n format.js\n end\n end",
"def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end",
"def collected_datum_params\n params.require(:collected_datum).permit(:turtle_id, :temperature, :deep, :light, :latitude, :longitude, :date)\n end",
"def create\n render json: Dish.create(dish_params)\n end",
"def set_weather_datum\n render json: WeatherDatum.find(params[:id])\n end",
"def create\n @request_datum = RequestDatum.new(request_datum_params)\n\n respond_to do |format|\n if @request_datum.save\n format.html { redirect_to @request_datum, notice: 'Request datum was successfully created.' }\n format.json { render action: 'show', status: :created, location: @request_datum }\n else\n format.html { render action: 'new' }\n format.json { render json: @request_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @field_datum = FieldDatum.new(field_datum_params)\n respond_to do |format|\n if @field_datum.save()\n format.html { redirect_to @field_datum, notice: 'Field datum was successfully created.' }\n format.json { render :show, status: :created, location: @field_datum }\n else\n format.html { render :new }\n format.json { render json: @field_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_datafactory(name) \n\n factory_create = {\n \"location\": \"centralus\"\n }\n\n response = HTTParty.put(\"https://management.azure.com/subscriptions/#{subscriptionId}/resourceGroups/#{resourceGroupName}/providers/Microsoft.DataFactory/factories/#{name}?api-version=2018-06-01\", {\n\n body: factory_create.to_json,\n\n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Content-Type\" => 'application/json', \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 transmit_data\n body = {body: {datum:{data_type:\"float\", value: rand, virtual_entity_id: 1}}}\n self.class.post(API+'/data', body)\n end",
"def post(path, data = {}, params = {})\n body = data.to_json\n path = File.join(@prefix, path)\n\n response = @conn.post(path, body) do |req|\n req.params = params\n req.headers['Content-Type'] = 'application/json'\n end\n\n JSON.parse response.body\n end",
"def create\n @dow = Dow.new(dow_params)\n\n respond_to do |format|\n if @dow.save\n format.html { redirect_to @dow, notice: 'Dow was successfully created.' }\n format.json { render :show, status: :created, location: @dow }\n else\n format.html { render :new }\n format.json { render json: @dow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post endpoint, data\n do_request :post, endpoint, data\n end",
"def create\n @dailystat = Dailystat.new(dailystat_params)\n\n respond_to do |format|\n if @dailystat.save\n format.html { redirect_to @dailystat, notice: 'Dailystat was successfully created.' }\n format.json { render :show, status: :created, location: @dailystat }\n else\n format.html { render :new }\n format.json { render json: @dailystat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @datebodydatum = Datebodydatum.new(datebodydatum_params)\n @datebodydatum.weight = @datebodydatum.weight.round(1)\n respond_to do |format|\n if @datebodydatum.save\n format.html { redirect_to datebodydatum_url(@datebodydatum, :date_search => params[:date_search]), notice: 'Datebodydatum was successfully created.' }\n format.json { render action: 'show', status: :created, location: @datebodydatum }\n else\n format.html { render action: 'new' }\n format.json { render json: @datebodydatum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def datum_params\n params.require(:datum).permit(:gid, :year, :month, :day, :team_name, :team_id)\n end",
"def create\n @sales_datum = SalesDatum.new(params[:sales_datum])\n\n respond_to do |format|\n if @sales_datum.save\n format.html { redirect_to @sales_datum, notice: 'Sales datum was successfully created.' }\n format.json { render json: @sales_datum, status: :created, location: @sales_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sales_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sleep_datum = SleepDatum.new(sleep_datum_params)\n\n respond_to do |format|\n if @sleep_datum.save\n format.html { redirect_to @sleep_datum, notice: 'Sleep datum was successfully created.' }\n format.json { render :show, status: :created, location: @sleep_datum }\n else\n format.html { render :new }\n format.json { render json: @sleep_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @payroll_datum = PayrollDatum.new(payroll_datum_params)\n\n respond_to do |format|\n if @payroll_datum.save\n format.html { redirect_to @payroll_datum, notice: 'Payroll datum was successfully created.' }\n format.json { render :show, status: :created, location: @payroll_datum }\n else\n format.html { render :new }\n format.json { render json: @payroll_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unstructured_datum = UnstructuredDatum.new(unstructured_datum_params)\n\n respond_to do |format|\n if @unstructured_datum.save\n format.html { redirect_to @unstructured_datum, notice: 'Unstructured datum was successfully created.' }\n format.json { render :show, status: :created, location: @unstructured_datum }\n else\n format.html { render :new }\n format.json { render json: @unstructured_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_datum = UserDatum.new(user_datum_params)\n\n respond_to do |format|\n if @user_datum.save\n format.html { redirect_to @user_datum, notice: \"User datum was successfully created.\" }\n format.json { render :show, status: :created, location: @user_datum }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @user_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @raw_datum = RawDatum.new(params[:raw_datum])\n\n respond_to do |format|\n if @raw_datum.save\n format.html { redirect_to @raw_datum, notice: 'Raw datum was successfully created.' }\n format.json { render json: @raw_datum, status: :created, location: @raw_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @raw_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_datum_params\n params.require(:test_datum).permit(:name)\n end",
"def create\n @mood_datum = MoodDatum.new(mood_datum_params)\n \n respond_to do |format|\n if @mood_datum.save \n params['significant_events'].each do |key,value| \n PatientSignificantEvent.create(:patient_id =>@mood_datum.user_id ,:doctor_id => @mood_datum.doctor_id ,:mood_data_id =>@mood_datum.id ,:comments => value )\n end \n format.html { redirect_to new_mood_datum_path(:patient => current_user.id), notice: 'Mood datum was successfully created.' }\n format.json { render action: 'show', status: :created, location: @mood_datum }\n else\n format.html { render action: 'new' }\n format.json { render json: @mood_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @collected_datum = CollectedDatum.new(collected_datum_params)\n\n respond_to do |format|\n if @collected_datum.save\n format.html { redirect_to @collected_datum, notice: 'Collected datum was successfully created.' }\n format.json { render :show, status: :created, location: @collected_datum }\n else\n format.html { render :new }\n format.json { render json: @collected_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sensor_datum_params\n params.require(:sensor_datum).permit(:sensor_find_id, :timestamp, :data)\n end",
"def create\n @dapi = Dapi.new(dapi_params)\n\n respond_to do |format|\n if @dapi.save\n format.html { redirect_to @dapi, notice: 'Dapi was successfully created.' }\n format.json { render :show, status: :created, location: @dapi }\n else\n format.html { render :new }\n format.json { render json: @dapi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_daty\n @daty = Daty.find(params[:id])\n end",
"def create\n @dia_evento = DiaEvento.new(dia_evento_params)\n\n if @dia_evento.save\n render json: @dia_evento, status: :created, location: @dia_evento\n else\n render json: @dia_evento.errors, status: :unprocessable_entity\n end\n end",
"def post_json(url, data)\n JSON.parse(post(url, data, :json, :json))\n end",
"def create\n @dayoff = Dayoff.new(params[:dayoff])\n\n respond_to do |format|\n if @dayoff.save\n format.html { redirect_to @dayoff, notice: 'Dayoff was successfully created.' }\n format.json { render json: @dayoff, status: :created, location: @dayoff }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dayoff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @seo_datum = SeoDatum.new(params[:seo_datum])\n\n respond_to do |format|\n if @seo_datum.save\n format.html { redirect_to @seo_datum, notice: 'Seo datum was successfully created.' }\n format.json { render json: @seo_datum, status: :created, location: @seo_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @seo_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @datalog = Datalog.new(datalog_params)\n\n respond_to do |format|\n if @datalog.save\n format.html { redirect_to @datalog, notice: 'Datalog was successfully created.' }\n format.json { render :show, status: :created, location: @datalog }\n else\n format.html { render :new }\n format.json { render json: @datalog.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sendData\n\t# List of all days\n\t@list_of_days = (1.month.ago.to_date...Date.today).to_a\n\t# New Array for graph\n\t@graph = Array.new\n\t# Set all dates to zero\n\t@list_of_days.each do |k|\n\t\t# Convert to useable date\n\t\tdate = k.to_date\n\t\t# Count all clicks/leads per day, per user\n\t\t@clicks = Click.complete_day(date).where(:user_id => current_user.id).count\n\t\t@leads = Lead.complete_day(date).where(:user_id => current_user.id).count\n\t\t# Add to array per day with clicks\n\t\t@graph << { y: date.strftime(\"%Y-%m-%d\"), click: @clicks, lead: @leads}\n\tend\n\t#Respond to JSON\n\trespond_to do |format|\n\t\tformat.json { render json: @graph }\n\tend\n end",
"def create\n plant = Plant.create(plant_params)\n render json: plant, status: :created\n end",
"def create\n @geo_datum = GeoDatum.new(geo_datum_params)\n\n respond_to do |format|\n if @geo_datum.save\n format.html { redirect_to @geo_datum, notice: 'Geo datum was successfully created.' }\n format.json { render :show, status: :created, location: @geo_datum }\n else\n format.html { render :new }\n format.json { render json: @geo_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @diary = Diary.create!(params[:diary])\n respond_to do |format|\n format.html { redirect_to diaries_url }\n format.js\n end\n end",
"def create\n dish = Dish.where(name: params[:name]).first\n dish ||= Dish.create(name: params[:name], party: current_party, price: params[:price])\n\n OrderItem.create(user: current_user, dish: dish)\n\n render json: { :name => dish.name, :price => dish.price, :participants => [current_user.login] }\n end",
"def new\n @skydatum = Skydatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @skydatum }\n end\n end",
"def create\n @ga_datum = GaDatum.new(ga_datum_params)\n\n respond_to do |format|\n if @ga_datum.save\n format.html { redirect_to @ga_datum, notice: 'Ga datum was successfully created.' }\n format.json { render :show, status: :created, location: @ga_datum }\n else\n format.html { render :new }\n format.json { render json: @ga_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n dive = Dive.new(dive_params)\n if dive.save\n render json: dive\n else\n render json: {message: dive.errors}, status: 400\n end\n end",
"def post(path, json, params = {})\n if path.include?('covid19')\n request = Net::HTTP::Post.new(path, @headers)\n else\n request = Net::HTTP::Post.new('/v2' + path, @headers)\n end\n request.add_field('Content-Type', 'application/json')\n request.body = json\n params.each do |k, v|\n request[k] = v\n end\n send_request(request)\n end",
"def create\n @valet_datum = ValetDatum.new(valet_datum_params)\n\n respond_to do |format|\n if @valet_datum.save\n format.html { redirect_to @valet_datum, notice: 'Valet datum was successfully created.' }\n format.json { render :show, status: :created, location: @valet_datum }\n else\n format.html { render :new }\n format.json { render json: @valet_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @datoscontacto = Datoscontacto.new(params[:datoscontacto])\n\n respond_to do |format|\n if @datoscontacto.save\n format.html { redirect_to @datoscontacto, notice: 'Datoscontacto was successfully created.' }\n format.json { render json: @datoscontacto, status: :created, location: @datoscontacto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @datoscontacto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def weather_datum_params\n params.require(:weather_datum).permit(:temp, :humidity, :location)\n end",
"def post_json(location, json_data)\n response = RestClient::Request.new(\n :method => :post,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json},\n :payload => json_data\n ).execute\n results = JSON.parse(response.to_str)\n end",
"def post_json(location, json_data)\n response = RestClient::Request.new(\n :method => :post,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json},\n :payload => json_data\n ).execute\n results = JSON.parse(response.to_str)\n end",
"def post_data(data, api_key)\n mutation = Mutations::CREATE_EVENT\n Client.query(mutation, api_key, {\n \"sessionId\": data[:session_id],\n \"eventInput\": {\n \"input\": data\n }\n })\n end",
"def create\n @objeto = Dato.new(dato_params)\n\n respond_to do |format|\n if @objeto.save\n format.html { redirect_to @objeto, notice: 'Dato was successfully created.' }\n format.json { render :show, status: :created, location: @objeto }\n else\n format.html { render :new }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_data_download(project_id, opts = {})\n post \"projects/#{project_id}/datadownload\", opts\n end",
"def create\n @dataed = Dataed.new(params[:dataed])\n\n respond_to do |format|\n if @dataed.save\n format.html { redirect_to(@dataed, :notice => 'Dataed was successfully created.') }\n format.xml { render :xml => @dataed, :status => :created, :location => @dataed }\n format.json { render :json => @dataed, :status => :created, :location => @dataed }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @dataed.errors, :status => :unprocessable_entity }\n format.json { render :json => @dataed.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create(data)\n data.each do |response|\n puts person = @person_repository.create_or_find(response)\n homeworld_response = StarwarsService.get_response(response[\"homeworld\"])\n planet = @planet_repository.find(homeworld_response[\"name\"]).first\n person.planet_id = planet.id\n\n if response[\"species\"].empty? == false\n species_response = StarwarsService.get_response(response[\"species\"].first)\n specie = @specie_repository.find(species_response[\"name\"]).first\n person.specie_id = specie.id\n end\n person.save\n end\n end",
"def create\n @userdatum = Userdatum.new(userdatum_params)\n\n respond_to do |format|\n if @userdatum.save\n format.html { redirect_to @userdatum, notice: \"Userdatum was successfully created.\" }\n format.json { render :show, status: :created, location: @userdatum }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @userdatum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @spdatum = Spdatum.new(params[:spdatum])\n\n respond_to do |format|\n if @spdatum.save\n format.html { redirect_to @spdatum, notice: 'Spdatum was successfully created.' }\n format.json { render json: @spdatum, status: :created, location: @spdatum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @spdatum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dinner = Dinner.new(dinner_params)\n @dinner.host_id = @current_user.json_hash[:id]\n if @dinner.valid?\n @dinner.save\n render json: @dinner.all_info\n else\n puts @dinner.errors.messages.inspect\n render status: :bad_request, json: {\n errors: @dinner.errors.messages\n }\n end\n end",
"def create\n\t\trespond_with Species.create(species_params)\n\tend",
"def create\n @diet = Diet.new(diet_params)\n @diet.user = @current_user\n\n if @diet.save\n render json: @diet, status: 201, location: @diet, root: true\n else\n render json: @diet.errors, status: 422\n end\n end",
"def create\n @dress = Dress.new(params[:dress])\n\n respond_to do |format|\n if @dress.save\n format.html { redirect_to @dress, notice: 'Dress was successfully created.' }\n format.json { render json: @dress, status: :created, location: @dress }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @article_datum = ArticleDatum.new(params[:article_datum])\n\n respond_to do |format|\n if @article_datum.save\n format.html { redirect_to @article_datum, notice: 'Article datum was successfully created.' }\n format.json { render json: @article_datum, status: :created, location: @article_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @article_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @data_ukt = DataUkt.new(data_ukt_params)\n\n respond_to do |format|\n if @data_ukt.save\n format.html { redirect_to @data_ukt, notice: 'Data ukt was successfully created.' }\n format.json { render :show, status: :created, location: @data_ukt }\n else\n format.html { render :new }\n format.json { render json: @data_ukt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_json(path, body)\n url = [base_url, path].join\n resp = HTTParty.post(url, headers: standard_headers, body: body.to_json)\n parse_json(url, resp)\n end",
"def create\n @processed_datum = ProcessedDatum.new(params[:processed_datum])\n\n respond_to do |format|\n if @processed_datum.save\n format.html { redirect_to @processed_datum, notice: 'Processed datum was successfully created.' }\n format.json { render json: @processed_datum, status: :created, location: @processed_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @processed_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_post(path, data = {})\n api_request(:post, path, :data => data)\n end",
"def create\n @dteor = Dteor.new(params[:dteor])\n\n respond_to do |format|\n if @dteor.save\n format.html { redirect_to @dteor, notice: t(:created) }\n format.json { render json: @dteor, status: :created, location: @dteor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dteor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @data_item = DataItem.new(data_item_params)\n\n respond_to do |format|\n if @data_item.save\n format.html { redirect_to @data_item, notice: 'Data item was successfully created.' }\n format.json { render :show, status: :created, location: @data_item }\n else\n format.html { render :new }\n format.json { render json: @data_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dtest = Dtest.new(params[:dtest])\n\n respond_to do |format|\n if @dtest.save\n format.html { redirect_to @dtest, notice: t(:notise_test) }\n format.json { render json: @dtest, status: :created, location: @dtest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dtest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add datapoints, opts={}\n datapoints = [*datapoints]\n\n datapoints.each do |dp|\n # we grab these datapoints for ourselves\n dp.goal = self\n \n data = {\n \"sendmail\" => opts[:sendmail] || false\n }.merge(dp.to_hash)\n\n # TODO create_all doesn't work because Ruby's POST encoding of arrays is broken.\n @user.post \"users/me/goals/#{@slug}/datapoints.json\", data\n end\n end",
"def create\n @cow_dairy = CowDairy.new(cow_dairy_params)\n @cow_dairy.user_id = @current_user.id\n\n if @cow_dairy.save\n render :show, status: :created, location: v1_cow_dairy_url(@cow_dairy)\n else\n render json: @cow_dairy.errors, status: :unprocessable_entity\n end\n end",
"def create\n render json: Beverage.create!(beverage_post_params), status: :created\n end",
"def create\n @asos_datum = AsosDatum.new(asos_datum_params(asos_station))\n\n respond_to do |format|\n if @asos_datum.save\n format.html { redirect_to @asos_datum, notice: 'Asos datum was successfully created.' }\n format.json { render action: 'show', status: :created, location: @asos_datum }\n else\n format.html { render action: 'new' }\n format.json { render json: @asos_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end",
"def create\n @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 geo_datum_params\n params.require(:geo_datum).permit(:geoId, :geoYear, :geoName, :geoValue, :dataId, :dataYear, :dataName, :dataValue)\n end",
"def create\n @enterprise_datum = EnterpriseDatum.new(params[:enterprise_datum])\n\n respond_to do |format|\n if @enterprise_datum.save\n format.html { redirect_to @enterprise_datum, notice: 'Enterprise datum was successfully created.' }\n format.json { render json: @enterprise_datum, status: :created, location: @enterprise_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enterprise_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dji_forecast = DjiForecast.new(dji_forecast_params)\n\n respond_to do |format|\n if @dji_forecast.save\n format.html { redirect_to @dji_forecast, notice: 'Dodano prognozę.' }\n format.json { render :show, status: :created, location: @dji_forecast }\n else\n format.html { render :new }\n format.json { render json: @dji_forecast.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @dossiers = Dossier.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dossiers }\n end\n end",
"def create\n @aws_datum = AwsDatum.new(aws_datum_params)\n\n respond_to do |format|\n if @aws_datum.save\n format.html { redirect_to @aws_datum, notice: 'Aws datum was successfully created.' }\n format.json { render :show, status: :created, location: @aws_datum }\n else\n format.html { render :new }\n format.json { render json: @aws_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fooddiary = @food.fooddiaries.new(fooddiary_params)\n @fooddiary.user_id = current_user.id\n @fooddiary.name = @food.name\n @fooddiary.eiweiß = @food.eiweiß\n @fooddiary.fett = @food.fett\n @fooddiary.kohlenhydrate = @food.kohlenhydrate\n @fooddiary.kalorien = @food.kalorien\n respond_to do |format|\n if @fooddiary.save\n format.html { redirect_to foods_path }\n format.json { render :show, status: :created, location: @fooddiary }\n else\n format.html { render :new }\n format.json { render json: @fooddiary.errors, status: :unprocessable_entity }\n end\n end\n end",
"def request_datum_params\n # params.require(:request_datum).permit(:date, :client_id, :agent_id)\n params.require(:request_datum).permit!\n end"
] | [
"0.5969446",
"0.5880498",
"0.5841724",
"0.5801228",
"0.5745463",
"0.5705525",
"0.5697604",
"0.56937057",
"0.56911564",
"0.5650348",
"0.5620837",
"0.56168604",
"0.56119776",
"0.5587607",
"0.55873734",
"0.5577817",
"0.5567594",
"0.55527216",
"0.55085063",
"0.5497819",
"0.5483523",
"0.5435079",
"0.54183847",
"0.540535",
"0.5397672",
"0.5395844",
"0.5391382",
"0.53847104",
"0.53750235",
"0.53697044",
"0.53627294",
"0.53450376",
"0.5338359",
"0.53183687",
"0.5313903",
"0.53117615",
"0.5303614",
"0.5294836",
"0.52937615",
"0.52745336",
"0.5269299",
"0.5268667",
"0.52663565",
"0.52586854",
"0.52569497",
"0.5245999",
"0.52369004",
"0.52362025",
"0.5235837",
"0.5233538",
"0.5227721",
"0.5223209",
"0.52184176",
"0.5216881",
"0.5215341",
"0.5203281",
"0.51891685",
"0.51869637",
"0.51765394",
"0.5173398",
"0.51714206",
"0.5170994",
"0.5169929",
"0.5163949",
"0.51626664",
"0.51575196",
"0.515164",
"0.515164",
"0.51503277",
"0.51394814",
"0.51358914",
"0.51333886",
"0.5128841",
"0.5120806",
"0.5120753",
"0.5119914",
"0.5112055",
"0.5110247",
"0.51099294",
"0.51077336",
"0.51074386",
"0.510429",
"0.50969",
"0.50953853",
"0.5090162",
"0.5081751",
"0.5074056",
"0.5073619",
"0.5073586",
"0.50730705",
"0.50664073",
"0.5065417",
"0.50621563",
"0.5060874",
"0.5059795",
"0.5050775",
"0.50499153",
"0.50498736",
"0.50486934",
"0.5047592"
] | 0.6704057 | 0 |
PATCH/PUT /daties/1 PATCH/PUT /daties/1.json | def update
respond_to do |format|
if @daty.update(daty_params)
format.html { redirect_to @daty, notice: 'Daty was successfully updated.' }
format.json { render :show, status: :ok, location: @daty }
else
format.html { render :edit }
format.json { render json: @daty.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\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(data = :object || :json)\n end",
"def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end",
"def update\n do_patch { return } # check if patch and do submission and return early if it is a patch (submission)\n # otherwise this is a PUT of the dataset metadata\n check_status { return } # check it's in progress, clone a submitted or raise an error\n respond_to do |format|\n format.json do\n dp = if @resource\n DatasetParser.new(hash: params['dataset'], id: @resource.identifier, user: @user) # update dataset\n else\n DatasetParser.new(hash: params['dataset'], user: @user, id_string: params[:id]) # upsert dataset with identifier\n end\n @stash_identifier = dp.parse\n ds = Dataset.new(identifier: @stash_identifier.to_s) # sets up display objects\n render json: ds.metadata, status: 200\n end\n end\n end",
"def update(data, &block)\n request :patch, @data[:id], data, &block\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @dato = Dato.find(params[:id])\n\n respond_to do |format|\n if @dato.update_attributes(params[:dato])\n format.html { redirect_to @dato, notice: 'Dato was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(data, params={})\n send_request @opts[:update_path], params, data\n end",
"def update\n respond_to do |format|\n if @dataset_datum.update(dataset_datum_params)\n format.html { redirect_to @dataset_datum, notice: 'Dataset datum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @dataset_datum.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 @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end",
"def jsonapi_update!(attributes)\n assign_jsonapi_attributes(attributes)\n save!\n end",
"def patch(url, data, headers = {})\n request(:patch, url, headers, :data => data)\n end",
"def update\n respond_to do |format|\n if @request_datum.update(request_datum_params)\n format.html { redirect_to @request_datum, notice: 'Request datum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @request_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(resource,identifier,json)\n raise 'Not Yet Implemented'\n end",
"def update\n @set.update_attributes({ :data => params[:data] })\n render_json :entry => @set and return\n end",
"def update\n @set.update_attributes({ :data => params[:data] })\n render_json :entry => @set and return\n end",
"def update\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n format.html { redirect_to @dataset, notice: 'Dataset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dataset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n dream = Dream.find params[:id]\n dream.update dream_params\n render json: {dream: dream}\n end",
"def update\n respond_to do |format|\n if @datum.update(datum_params)\n format.html { redirect_to @datum, notice: 'Datum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @data = args[:data] if args.key?(:data)\n @id = args[:id] if args.key?(:id)\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n @datum = Datum.find(params[:id])\n\n respond_to do |format|\n if @datum.update_attributes(params[:datum])\n format.html { redirect_to @datum, notice: 'Datum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @datum = Datum.find(params[:id])\n\n respond_to do |format|\n if @datum.update_attributes(params[:datum])\n format.html { redirect_to @datum, notice: 'Datum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @objeto.update(dato_params)\n format.html { redirect_to @objeto, notice: 'Dato was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @meteorological_data = MeteorologicalData.find(params[:id])\n\n respond_to do |format|\n if @meteorological_data.update_attributes(params[:meteorological_data])\n format.html { redirect_to(@meteorological_data, :notice => 'MeteorologicalData was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @meteorological_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @iot_datum.update(iot_datum_params)\n format.html { redirect_to @iot_datum, notice: 'Iot datum was successfully updated.' }\n format.json { render :show, status: :ok, location: @iot_datum }\n else\n format.html { render :edit }\n format.json { render json: @iot_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(datum)\n validate_request datum\n current_path = \"/api/#{update_version}/update\"\n payload = datum.to_json\n @conn.post(current_path, payload)\n end",
"def update\n respond_to do |format|\n if @databox.update(databox_params)\n format.html { redirect_to @databox, notice: 'Databox was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @databox.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @datafile.update(datafile_params)\n format.html { redirect_to @datafile, notice: 'Datafile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @datafile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @datum.update(datum_params)\n format.html { redirect_to @datum, notice: 'Datum was successfully updated.' }\n format.json { render :show, status: :ok, location: @datum }\n else\n format.html { render :edit }\n format.json { render json: @datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_request\n end\n end",
"def update(&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(data, &block)\n request :put, @data[:id], data, &block\n end",
"def update\n @item_datum = ItemData.find(params[:id])\n\n respond_to do |format|\n if @item_datum.update_attributes(params[:item_datum])\n format.html { redirect_to @item_datum, notice: 'Item datum was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @datoscontacto = Datoscontacto.find(params[:id])\n\n respond_to do |format|\n if @datoscontacto.update_attributes(params[:datoscontacto])\n format.html { redirect_to @datoscontacto, notice: 'Datoscontacto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @datoscontacto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(data = nil, options = nil)\n options ||= {}\n options[:method] = :patch\n call data, options\n end",
"def update!(**args)\n @json_schemas = args[:json_schemas] if args.key?(:json_schemas)\n @schema = args[:schema] if args.key?(:schema)\n end",
"def update\n @dato = Dato.find(params[:id])\n\n respond_to do |format|\n if @dato.update_attributes(params[:dato])\n format.html { redirect_to(@dato, :notice => 'Dato was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @dato.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @dato = Dato.find(params[:id])\n\n respond_to do |format|\n if @dato.update_attributes(params[:dato])\n format.html { redirect_to(@dato, :notice => 'Dato was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @dato.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @dataset.update(dataset_params)\n format.html { redirect_to @dataset, notice: 'Dataset was successfully updated.' }\n format.json { render :show, status: :ok, location: @dataset }\n else\n format.html { render :edit }\n format.json { render json: @dataset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @question_datum = QuestionDatum.find(params[:id])\n\n respond_to do |format|\n if @question_datum.update_attributes(params[:question_datum])\n format.html { redirect_to @question_datum, notice: 'Question datum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fixture = Fixture.find(params[:id])\n\n respond_to do |format|\n if @fixture.update_attributes(fixture_params)\n format.json { head :no_content }\n else\n format.json { render json: @fixture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def contact_updated(freshdesk_data,contact_id)\n\t\t#Rails.logger.info \"Update method id and data\"\n\t\t#Rails.logger.debug \"#{@api_domain}-#{contact_id}-#{@api_key}\"\n\t\t#Rails.logger.debug \"#{freshdesk_data.to_json}\"\n\t response = HTTParty.put(\n\t \"#{@api_domain}contacts/#{contact_id}\", \n\t\t basic_auth: { username: @api_key, password: \"password\" },\n\t\t headers: { 'Content-Type' => 'application/json' },\n\t\t body: freshdesk_data.to_json\n\t )\n\tend",
"def update\n @person = Person.find(params[:id]) \n respond_to do |format|\n if @person.update(person_params)\n format.json { render json: @person, status: :ok }\n else\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def update(params)\n @validated = false\n replace(JSONModel.deep_merge(@data, params))\n end",
"def update\n animal = Animal.find(params[:id])\n\n if validate_params(animal_params)\n animal.update(animal_params)\n render json: animal, status: 200, location: [:api, animal]\n else\n render json: { errors: animal.errors }, status: 422\n end\n end",
"def update(request) \n # get the old data from the request object\n old_data = request.oldValues\n # get the date from the request object\n update_data = request.data\n\t \t \n new_id = update_data[@pk]\n # merge to hash objects \n merged_data = old_data.merge!(update_data) \n merged_data.delete(@pk)\n \n #update\n @model.update(new_id, merged_data) \t \n\t response = DSResponse.new \n response.status = 0 \n return response\n end",
"def patch(path, **args); end",
"def patch(resource, data)\n proxy(method: :patch, url: url_for(resource), data: data)\n end",
"def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end",
"def update\n @experiment = Experiment.find(@datapoint.experiment_id)\n respond_to do |format|\n if @datapoint.update(datapoint_params)\n format.html { redirect_to @experiment, notice: 'Datapoint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @datapoint.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 respond_to do |format|\n if @datat_table_datum.update(datat_table_datum_params)\n format.html { redirect_to @datat_table_datum, notice: 'Datat table datum was successfully updated.' }\n format.json { render :show, status: :ok, location: @datat_table_datum }\n else\n format.html { render :edit }\n format.json { render json: @datat_table_datum.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!(**args)\n @data = args[:data] if args.key?(:data)\n end",
"def update!(**args)\n @data = args[:data] if args.key?(:data)\n end",
"def update!(**args)\n @data = args[:data] if args.key?(:data)\n end",
"def update\n respond_to do |format|\n if @asos_datum.update(asos_datum_params)\n format.html { redirect_to @asos_datum, notice: 'Asos datum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @asos_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @person.seat\n render json: {errors: 'Cannot update a seated person'}, status: 422\n else\n @person.update person_params\n render json: @person\n end\n end",
"def update\n @data_note = DataNote.find(params[:id])\n\n respond_to do |format|\n if @data_note.update_attributes(params[:data_note])\n format.html { redirect_to @data_note.data_source, notice: 'Data note was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @data_note.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n respond_to do |format|\n if @datafile.update(datafile_params)\n format.html { redirect_to @datafile, notice: 'Datafile was successfully updated.' }\n format.json { render :show, status: :ok, location: @datafile }\n else\n format.html { render :edit }\n format.json { render json: @datafile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @data = args[:data] if args.key?(:data)\n @metadata = args[:metadata] if args.key?(:metadata)\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 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 patch(path, opts = {})\n request(:patch, path, opts).body\n end",
"def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n format.html { redirect_to(@dataset, :notice => 'Dataset was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @dataset.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n id = shift_argument\n validate_arguments!\n dataclip_reference = options[:dataclip]\n uri = URI(\"#{base_url}/#{id}\")\n req = Net::HTTP::Patch.new(uri.path)\n body = prepare_body(dataclip_reference)\n execute_and_print(uri, req, body)\n end",
"def update\n respond_to do |format|\n if @tracked_datum.update(tracked_datum_params)\n format.html { redirect_to @tracked_datum, notice: 'Tracked datum was successfully updated.' }\n format.json { render :show, status: :ok, location: @tracked_datum }\n else\n format.html { render :edit }\n format.json { render json: @tracked_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @scrapping_datum.update(scrapping_datum_params)\n format.html { redirect_to @scrapping_datum, notice: 'Scrapping datum was successfully updated.' }\n format.json { render :show, status: :ok, location: @scrapping_datum }\n else\n format.html { render :edit }\n format.json { render json: @scrapping_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @data_collection = DataCollection.find(params[:id])\n\n respond_to do |format|\n if @data_collection.update_attributes(params[:data_collection])\n format.html { redirect_to @data_collection, notice: 'Data collection was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @data_collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @datastore = Datastore.find(params[:id])\n\n respond_to do |format|\n if @datastore.update_attributes(params[:datastore])\n format.html { redirect_to @datastore, notice: 'Datastore was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @datastore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @datasource.update(form_params)\n format.json { render json: { datasources: @datasource }, status: :ok, location: @datasource }\n else\n format.json { render json: @datasource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @field_datum.update(field_datum_params)\n format.html { redirect_to @field_datum, notice: 'Field datum was successfully updated.' }\n format.json { render :show, status: :ok, location: @field_datum }\n else\n format.html { render :edit }\n format.json { render json: @field_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @dataed = Dataed.find(params[:id])\n\n respond_to do |format|\n if @dataed.update_attributes(params[:dataed])\n format.html { redirect_to(@dataed, :notice => 'Dataed was successfully updated.') }\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @dataed.errors, :status => :unprocessable_entity }\n format.json { render :json => @dataed.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Location.update(params[\"id\"], params[\"location\"])\n end",
"def update\n respond_to do |format|\n if @test_meta_datum.update(test_meta_datum_params)\n format.html { redirect_to @test_meta_datum, notice: 'Test meta datum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @test_meta_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @specie = Specie.find(params[:id])\n\n respond_to do |format|\n if @specie.update_attributes(params[:specie])\n format.html { redirect_to @specie, notice: 'Specie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @specie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @animal = Animal.find(params[:id])\n @species = ['Lion', 'Koala', 'Panda']\n @zoo = Zoo.find(params[:zoo_id])\n\n respond_to do |format|\n\n if @animal.update_attributes(params[:animal])\n format.html { redirect_to zoo_animal_path(params[:zoo_id],@animal.id),\n notice: 'animal was successfully updated.' }\n format.json { head :no_content }\n else\n\n format.html { render action: \"edit\"}\n format.json { render json: @animal.errors,\n status: :unprocessable_entity }\n end\n end\n end",
"def update\n put :update\n end",
"def update\n respond_to do |format|\n if @input_datum.update(input_datum_params)\n format.html { redirect_to @input_datum, notice: 'Input datum was successfully updated.' }\n format.json { render :show, status: :ok, location: @input_datum }\n else\n format.html { render :edit }\n format.json { render json: @input_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def update\n if @diet.update(diet_params)\n head :no_content, status: 204\n else\n render json: @diet.errors, status: 422\n end\n end",
"def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@data_set = DataSet.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @data_set.update_attributes(params[:data_set])\n\t\t\t\tformat.html { redirect_to @data_set, notice: 'Data set was successfully updated.' }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @data_set.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @test_datum.update(test_datum_params)\n format.html { redirect_to @test_datum, notice: 'Test datum was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_datum }\n else\n format.html { render :edit }\n format.json { render json: @test_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @staffer = Staffer.find(params[:id])\n\n respond_to do |format|\n if @staffer.update_attributes(params[:staffer])\n format.html { redirect_to @staffer, notice: 'Staffer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @staffer.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.68686336",
"0.6824158",
"0.6794531",
"0.6645903",
"0.64442414",
"0.63872534",
"0.63589317",
"0.6240699",
"0.62149256",
"0.6173382",
"0.61181927",
"0.6105475",
"0.6068339",
"0.60622215",
"0.60581076",
"0.6055442",
"0.60456413",
"0.60319173",
"0.60319173",
"0.6030113",
"0.6023298",
"0.6005699",
"0.5991494",
"0.5972385",
"0.5969276",
"0.5943019",
"0.5943019",
"0.5942736",
"0.5942736",
"0.59114933",
"0.58986413",
"0.5885046",
"0.5874753",
"0.5825674",
"0.582422",
"0.58115363",
"0.5807464",
"0.57999206",
"0.5799463",
"0.5785114",
"0.5778444",
"0.57742715",
"0.5771159",
"0.5764367",
"0.5764367",
"0.5755364",
"0.575458",
"0.575458",
"0.5752925",
"0.57510173",
"0.57475364",
"0.5726407",
"0.57254493",
"0.57221586",
"0.5720102",
"0.5716583",
"0.56989384",
"0.5696093",
"0.569332",
"0.5691418",
"0.5690765",
"0.56902504",
"0.5688936",
"0.5672201",
"0.5664947",
"0.5664947",
"0.5664947",
"0.56557906",
"0.5654217",
"0.56419367",
"0.5638573",
"0.56335515",
"0.5627733",
"0.56275487",
"0.56274927",
"0.56244195",
"0.56220067",
"0.56219435",
"0.5615504",
"0.560405",
"0.55921894",
"0.55855894",
"0.5581009",
"0.5580725",
"0.5579778",
"0.5577416",
"0.5572828",
"0.5568984",
"0.55670494",
"0.5566287",
"0.55657613",
"0.55627936",
"0.5559518",
"0.555879",
"0.55571145",
"0.5554785",
"0.55531377",
"0.55527264",
"0.55515444",
"0.5551422"
] | 0.6466438 | 4 |
DELETE /daties/1 DELETE /daties/1.json | def destroy
@daty.destroy
respond_to do |format|
format.html { redirect_to daties_url, notice: 'Daty was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 @datum = Datum.find(params[:id])\n @datum.destroy\n\n respond_to do |format|\n format.html { redirect_to data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datum = Datum.find(params[:id])\n @datum.destroy\n\n respond_to do |format|\n format.html { redirect_to data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datum.destroy\n respond_to do |format|\n format.html { redirect_to data_url }\n format.json { head :no_content }\n end\n end",
"def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end",
"def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @dataset_datum.destroy\n respond_to do |format|\n format.html { redirect_to dataset_data_url }\n format.json { head :no_content }\n end\n end",
"def 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 @datashows = Datashow.find(params[:id])\n @datashows.destroy\n\n respond_to do |format|\n format.html { redirect_to(datashows_url) }\n format.xml { head :ok }\n end\n end",
"def delete datapoints\n datapoints = [*datapoints]\n datapoints.each do |dp|\n @user.delete \"/users/me/goals/#{@slug}/datapoints/#{dp.id}.json\"\n end\n end",
"def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to datos_url }\n format.json { head :no_content }\n end\n end",
"def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\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 @datum = Datum.find(params[:id])\n verify_user(@datum.user.id)\n @datum.destroy\n\n respond_to do |format|\n format.html { redirect_to data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @skydatum = Skydatum.find(params[:id])\n @skydatum.destroy\n\n respond_to do |format|\n format.html { redirect_to skydata_url }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def deleteDataId(data_of, id)\n url_data = stringGetUrlPath(data_of)\n url_request = \"#{url_data}/#{id}\"\n puts \">>>>>> delete #{data_of} with id:#{id}\"\n deleteData(url_request)\n end",
"def destroy\n @datum.destroy\n respond_to do |format|\n format.html { redirect_to data_url, notice: 'Datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datoscontacto = Datoscontacto.find(params[:id])\n @datoscontacto.destroy\n\n respond_to do |format|\n format.html { redirect_to datoscontactos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datapoint.destroy\n respond_to do |format|\n format.html { redirect_to datapoints_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @energy_datum = EnergyDatum.find(params[:id])\n @energy_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to energy_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @seo_datum = SeoDatum.find(params[:id])\n @seo_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to seo_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datat_table_datum.destroy\n respond_to do |format|\n format.html { redirect_to datat_table_data_url, notice: 'Datat table datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @raw_datum = RawDatum.find(params[:id])\n @raw_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to raw_data_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(path, data={})\n request(:delete, path, data)\n end",
"def destroy\n @request_datum.destroy\n respond_to do |format|\n format.html { redirect_to request_data_url }\n format.json { head :no_content }\n end\n end",
"def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end",
"def delete_json(url)\n JSON.parse(delete(url, :json, :json))\n end",
"def destroy\n @dataset.destroy\n respond_to do |format|\n format.html { redirect_to study_path(@dataset.study), notice: 'Dataset was successfully destroyed.' }\n format.json { head :no_content }\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 delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end",
"def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end",
"def destroy\n @test_datum.destroy\n respond_to do |format|\n format.html { redirect_to test_data_url, notice: 'Test datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datafile.destroy\n respond_to do |format|\n format.html { redirect_to datafiles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question_datum = QuestionDatum.find(params[:id])\n @question_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to question_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datalog.destroy\n respond_to do |format|\n format.html { redirect_to datalogs_url, notice: 'Datalog was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @databox.destroy\n render json: { post: @databox }\n# respond_to do |format|\n# format.html { redirect_to databoxes_url }\n# format.json { head :no_content }\n# end\n end",
"def destroy\n @asos_datum.destroy\n respond_to do |format|\n format.html { redirect_to asos_data_url }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @item_datum = ItemData.find(params[:id])\n @item_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to item_datum_url }\n format.json { head :ok }\n end\n end",
"def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @datastore = Datastore.find(params[:id])\n @datastore.destroy\n\n respond_to do |format|\n format.html { redirect_to datastores_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @historial_odt = HistorialOdt.find(params[:id])\n @historial_odt.destroy\n\n respond_to do |format|\n format.html { redirect_to historial_odts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @git_datum = GitDatum.find(params[:id])\n @git_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to git_data_url }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end",
"def destroy\n @dailystat.destroy\n respond_to do |format|\n format.html { redirect_to dailystats_url, notice: 'Dailystat was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tracked_datum.destroy\n respond_to do |format|\n format.html { redirect_to tracked_data_url, notice: 'Tracked datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataset = Dataset.find(params[:id])\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to datasets_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @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 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 delete(resource)\n headers = base_headers.merge('Content-Type' => 'application/json')\n url = \"#{@base_url}/#{resource}\"\n\n @logger.debug(\"DELETE request Url: #{url}\")\n @logger.debug(\"-- Headers: #{headers}\")\n\n x = HTTParty.delete(url, headers: headers)\n puts x.inspect\n x\n end",
"def api_delete(action, data)\n api_request(action, data, 'DELETE')\n end",
"def delete(path)\n request(:delete, path)\n end",
"def destroy\n #Finds selected data file\n @data_file = DataFile.find(params[:id])\n #destroys data file\n @data_file.destroy\n respond_to do |format|\n format.html { redirect_to '/admin' }\n format.json { head :ok }\n end\n end",
"def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to(datos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to(datos_url) }\n format.xml { head :ok }\n end\n end",
"def deletef\n url = prefix + \"deletef\" + id_param\n return response(url)\n end",
"def destroy\n @article_datum = ArticleDatum.find(params[:id])\n @article_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to article_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unstructured_datum.destroy\n respond_to do |format|\n format.html { redirect_to unstructured_data_url, notice: 'Unstructured datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataset = Dataset.find(params[:id])\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dataset = Dataset.find(params[:id])\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @fixture = Fixture.find(params[:id])\n @fixture.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @spdatum = Spdatum.find(params[:id])\n @spdatum.destroy\n\n respond_to do |format|\n format.html { redirect_to spdata_url }\n format.json { head :no_content }\n end\n end",
"def delete(*args)\n request(:delete, *args)\n end",
"def destroy\n @content_datum = ContentDatum.find(params[:id])\n @content_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to content_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dapi.destroy\n respond_to do |format|\n format.html { redirect_to dapis_url, notice: 'Dapi was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"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_item(id)\n record \"/todos/delete_item/#{id}\"\n end",
"def destroy\n @climb_datum = ClimbDatum.find(params[:id])\n @climb_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to climb_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gethotelstaticdatagd = Gethotelstaticdatagd.find(params[:id])\n @gethotelstaticdatagd.destroy\n\n respond_to do |format|\n format.html { redirect_to gethotelstaticdatagds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n puts @iot_datum.count\n if @iot_datum.count > 0\n @deleted_rec = IotDatum.new\n @deleted_rec.workbench_number = @iot_datum.workbench_number\n @deleted_rec.part_number = @iot_datum.part_number\n @deleted_rec.target = @iot_datum.target\n @deleted_rec.lot_size = @iot_datum.lot_size\n @deleted_rec.employee_name = @iot_datum.employee_name\n @deleted_rec.shift = @iot_datum.shift\n @deleted_rec.device_id = @iot_datum.device_id\n @deleted_rec.count = @iot_datum.count\n @deleted_rec.status = 'Deleted'\n @deleted_rec.save!\n @iot_datum.destroy\n else\n @iot_datum.destroy\n end\n respond_to do |format|\n format.html { redirect_to iot_data_url, notice: 'Planner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def destroy\n @data_note = DataNote.find(params[:id])\n @data_note.destroy\n\n respond_to do |format|\n format.html { redirect_to data_sources_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @dymmmy = Dymmmy.find(params[:id])\n @dymmmy.destroy\n\n respond_to do |format|\n format.html { redirect_to dymmmies_url }\n format.json { head :ok }\n end\n end",
"def delete(path)\n request 'DELETE', path\n end",
"def destroy\n @jedi = Jedi.find(params[:id])\n @jedi.destroy\n\n respond_to do |format|\n format.html { redirect_to jedis_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datafile.destroy\n respond_to do |format|\n format.html { redirect_to datafiles_url, notice: 'Datafile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @daily_exercise = DailyExercise.find(params[:id])\n @daily_exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to daily_exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataed = Dataed.find(params[:id])\n @dataed.destroy\n\n respond_to do |format|\n format.html { redirect_to(dataeds_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end"
] | [
"0.71012366",
"0.69983524",
"0.69983524",
"0.6914332",
"0.68503565",
"0.6837376",
"0.6819457",
"0.68034667",
"0.67860085",
"0.6740459",
"0.6704675",
"0.6671048",
"0.66459",
"0.6619549",
"0.65895253",
"0.656336",
"0.65559727",
"0.65557826",
"0.6552506",
"0.65391463",
"0.6523386",
"0.65128845",
"0.6500011",
"0.64914733",
"0.6487375",
"0.64816225",
"0.64803797",
"0.64803797",
"0.64803797",
"0.64803797",
"0.6473655",
"0.6470376",
"0.6451715",
"0.6449296",
"0.6447383",
"0.64448076",
"0.6438001",
"0.64270234",
"0.64184415",
"0.6416469",
"0.6414709",
"0.6413388",
"0.6412456",
"0.64085513",
"0.64085513",
"0.6394404",
"0.6392432",
"0.6392242",
"0.6383844",
"0.63829374",
"0.6381682",
"0.63754916",
"0.63632137",
"0.63592273",
"0.6352366",
"0.6352034",
"0.63444775",
"0.6342122",
"0.6328911",
"0.63223386",
"0.63222045",
"0.63116735",
"0.63095486",
"0.6308228",
"0.6306979",
"0.6297719",
"0.6297082",
"0.6295935",
"0.6285509",
"0.6285509",
"0.62847143",
"0.62831396",
"0.62828827",
"0.6281711",
"0.6281711",
"0.62760586",
"0.6272862",
"0.62717193",
"0.62690854",
"0.62689507",
"0.6266454",
"0.6266454",
"0.6258483",
"0.62579304",
"0.62577575",
"0.62556225",
"0.6253828",
"0.62454486",
"0.6245186",
"0.6240038",
"0.62356097",
"0.6235606",
"0.6232817",
"0.6232056",
"0.6231732",
"0.6230511",
"0.62277335",
"0.62269044",
"0.62240034",
"0.62216705"
] | 0.70612794 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_daty
@daty = Daty.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 daty_params
params.require(:daty).permit(:start_date, :end_date, :localisation)
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 |
save format to context | def store_pwfmt_params
Pwfmt::Context.formats = params[:pwfmt][:formats] if params[:pwfmt]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format\n @format ||= {}\n end",
"def format\n @_format\n end",
"def format\n @format\n end",
"def convert(format)\n manipulate!(:format => format)\n @format = format\n end",
"def format\n @format ||= properties.format.new self\n end",
"def formats; end",
"def formats; end",
"def format(format)\n @format = format\n end",
"def persist_wiki_format\n if Pwfmt::Context.format_for?('issue_notes')\n PwfmtFormat.persist(self, 'journal_notes', Pwfmt::Context.format_for('issue_notes'))\n elsif Pwfmt::Context.format_for?(\"journal_#{id}_notes\")\n PwfmtFormat.persist(self, 'journal_notes', Pwfmt::Context.format_for(\"journal_#{id}_notes\"))\n end\n end",
"def to_format\n @format ||= lookup.last \n end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format= format\n @format = format\n @document = nil\n end",
"def formats\n format\n end",
"def format!; end",
"def format=(value)\n\t\t\t@format = value\n\t\tend",
"def save!(context)\n raise NotImplementedError, \"Subclasses must implement a save!(context) method.\"\n end",
"def reformat(data, format=params[:format])\n content_type CONTENT_TYPES[format], :charset => 'utf-8'\n case format\n when 'txt'\n data.to_s\n when 'yaml'\n YAML::dump(data)\n when 'xml'\n data.to_xml\n when 'json'\n data.to_json\n else\n raise 'Unknown format: ' + format\n end\n end",
"def reformat(data, format=params[:format])\n content_type CONTENT_TYPES[format], :charset => 'utf-8'\n case format\n when 'txt'\n data.to_s\n when 'yaml'\n YAML::dump(data)\n when 'xml'\n data.to_xml\n when 'json'\n data.to_json\n else\n raise 'Unknown format: ' + format\n end\n end",
"def format\n raise NotImplementedError\n end",
"def convert(format)\n branch format: format\n end",
"def format\n @format ||= self._format_default\n end",
"def save_to(path); end",
"def format(fmt)\n scoped_formats.push(fmt)\n yield\n ensure\n scoped_formats.pop\n end",
"def format\n @ole.Format\n end",
"def format\n @ole.Format\n end",
"def with_format(format)\n old_formats = formats\n self.formats = [format]\n yield\n self.formats = old_formats\n nil\n end",
"def formats=(values); end",
"def determine_and_set_format options\n options.format = @template_format = options.format || @template_format\n end",
"def set_formato\n @formato = Formato.find(params[:id])\n end",
"def format\n @format ||= Manipulator.new\n end",
"def _process_format(format); end",
"def _process_format(format); end",
"def storeFormatOnAmazonS3(videomp4, videoconverted, format)\n Formatvideo.create({\n :video_clip_id => videomp4.id,\n :format => File.open(videoconverted),\n :type => format\n })\n end",
"def set_created_format\n @created_format = CreatedFormat.find(params[:id])\n end",
"def format=(value)\n @format = value\n end",
"def format=(value)\n @format = value\n end",
"def format=(value)\n @format = value\n end",
"def format=(format)\n use_format(format)\n end",
"def formats(*args, &block)\n unless respond_to?(:model_formatting_attributes)\n # use all these attributes instead of a single ModelFormatting::Config because\n # it's easier to support subclassing.\n class_attribute :model_formatting_attributes, \n :model_formatting_white_list, :model_formatting_context, \n :model_formatting_before_callback, :model_formatting_after_callback\n send :include, ModelFormatting::InstanceMethods\n self.model_formatting_context = []\n self.model_formatting_attributes = {} \n self.model_formatting_white_list = HTML::WhiteListSanitizer.new\n before_save :format_content_with_model_formatting\n end\n\n model_formatting_attributes.update args.extract_options!\n args.each do |field|\n model_formatting_attributes[field] = \"formatted_#{field}\"\n end\n\n if block\n config = ModelFormatting::Config.new(model_formatting_white_list, model_formatting_attributes, model_formatting_context)\n config.instance_eval &block\n self.model_formatting_before_callback = config.before_callback if config.before_callback\n self.model_formatting_after_callback = config.after_callback if config.after_callback\n end\n end",
"def persist_wiki_format\n PwfmtFormat.persist(self, 'project_description')\n end",
"def set_formating\n @formating = Formating.find(params[:id])\n end",
"def save_format=(save_format)\n validator = EnumAttributeValidator.new('String', [\"VDX\", \"VSX\", \"VTX\", \"TIFF\", \"PNG\", \"BMP\", \"EMF\", \"JPEG\", \"PDF\", \"XPS\", \"GIF\", \"HTML\", \"SVG\", \"SWF\", \"XAML\", \"VSDX\", \"VSTX\", \"VSSX\", \"VSDM\", \"VSSM\", \"VSTM\"])\n unless validator.valid?(save_format)\n fail ArgumentError, \"invalid value for 'save_format', must be one of #{validator.allowable_values}.\"\n end\n @save_format = save_format\n end",
"def format\n return @format\n end",
"def format\n return @format\n end",
"def format\n return @format\n end",
"def create_format_method\n end",
"def save\n end",
"def save\n end",
"def save\n end",
"def with_format(format, &block)\n old_formats = formats\n self.formats = [format]\n yield\n self.formats = old_formats\n nil\n end",
"def save!\n end",
"def with_format(format, &block)\n\t old_formats = formats\n\t self.formats = [format]\n\t block.call\n\t self.formats = old_formats\n\t nil\n\tend",
"def format(format_value)\n @template.format = format_value\n end",
"def insert_text_format\n attributes.fetch(:insertTextFormat)\n end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save_context(context)\n session[:context] = context\n end",
"def force(new_format)\r\n @format = new_format\r\n self\r\n end",
"def save(wfid, jid, job, context_buffer)\n raise NotImplementedError\n end",
"def save(options = {})\n save_to(@path, options)\n end",
"def format(format, &block)\n scope :format => format, &block\n end",
"def update\n @format = Format.find(params[:id])\n\n respond_to do |format|\n if @format.update_attributes(params[:form])\n format.html { redirect_to(@format, :notice => 'Format was successfully updated.') }\n format.xml { head :ok }\n format.csv { head :ok }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @format.errors, :status => :unprocessable_entity }\n format.csv { render :csv => @format.errors, :status => :unprocessable_entity }\n format.json { render :json => @format.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def save_to(path)\n File.open(path, \"w\") do |file|\n I18n.with_locale(meta.locale) do\n file << render\n end\n end\n end",
"def format(&block)\n @format = block if block\n @format\n end",
"def _process_format(format) # :nodoc:\n end",
"def create\n @format = Format.new(params[:format])\n\n respond_to do |format|\n if @format.save\n format.html { redirect_to @format, notice: 'Format was successfully created.' }\n format.json { render json: @format, status: :created, location: @format }\n else\n format.html { render action: \"new\" }\n format.json { render json: @format.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_as_link_to format\n link_to \"Save as #{format.to_s.capitalize}\", {:model => params[:model],\n :format => format, :filter => params[:filter], :sort => params[:sort],\n :sort_reverse => params[:sort_reverse], :search => params[:search]}\n end",
"def reserve_format\n return unless @text && @content\n\n @text.wiki_format = @content.text.wiki_format\n Pwfmt::Context.reserve_format('content_text', @text)\n end",
"def format\n raise '#format must be implemented in child class'\n end",
"def save_impl(format, file)\n ImageIO.write(@src, format, file)\n end",
"def as(format)\n @format = 'yaml'\n end",
"def format=(extension); end",
"def save\n SAVE\n end",
"def save\n prepare\n h = {}\n h[:title] = @title\n h[:sequence] = @sequence.map(&:export)\n outfile = File.join(@basedir, \"#{@name}.json\")\n File.open(outfile, 'w') do |f|\n f.write JSON.pretty_generate(h)\n end\n end",
"def reset_format!\n self.format = @default_format\n end",
"def formatter; end",
"def formatter; end",
"def formatter; end",
"def save\n File.open(@file, 'w') do |file|\n file.write(Psych.dump(@params))\n end\n @saved = true\n end",
"def save\n end",
"def save!\n resource.save!\n end",
"def format=(procedure); end",
"def save\n now = Time.now\n\n data = {\n :id => @id,\n :desc => @desc,\n :ctime => Timestamp.dump(@ctime) || Timestamp.dump(now),\n :mtime => Timestamp.dump(now),\n :ppg_filename => @ppg_filename,\n }\n jobinfo.write(YAML.dump(data))\n end",
"def testing_format\n @testing_format ||= TestingFormat.create\n end",
"def save(file=nil)\n file = file || path \n text = format.render(number)\n ::File.open(file, 'w'){ |f| f << text }\n end",
"def save\n super save\n end",
"def save_context(context)\n message_context_session[:context] = context\n end"
] | [
"0.60575414",
"0.60413516",
"0.60328984",
"0.59167314",
"0.5910424",
"0.588435",
"0.588435",
"0.58680737",
"0.5849825",
"0.5843311",
"0.58194053",
"0.58194053",
"0.58194053",
"0.58194053",
"0.58194053",
"0.58194053",
"0.58194053",
"0.58194053",
"0.5767838",
"0.57380444",
"0.5732856",
"0.57231814",
"0.5715438",
"0.57095546",
"0.57095546",
"0.5653694",
"0.56516516",
"0.5647683",
"0.5639306",
"0.561669",
"0.56056607",
"0.56056607",
"0.5602645",
"0.5577676",
"0.5576071",
"0.55700153",
"0.5563363",
"0.55607045",
"0.55607045",
"0.5559787",
"0.5535715",
"0.5533823",
"0.5533823",
"0.5533823",
"0.552484",
"0.5504753",
"0.5486835",
"0.5480073",
"0.547207",
"0.5464506",
"0.5464506",
"0.5464506",
"0.5457494",
"0.545595",
"0.545595",
"0.54427326",
"0.5437234",
"0.54372096",
"0.54210526",
"0.54122937",
"0.53962064",
"0.5376789",
"0.5376789",
"0.5376789",
"0.5376789",
"0.5376789",
"0.5376789",
"0.5376789",
"0.5376789",
"0.5362898",
"0.53594327",
"0.5340887",
"0.53375405",
"0.53320533",
"0.532716",
"0.53211206",
"0.5319102",
"0.53131676",
"0.5304985",
"0.53047186",
"0.5302657",
"0.5299117",
"0.5298351",
"0.52936274",
"0.5292405",
"0.5289758",
"0.52858746",
"0.5281371",
"0.5279934",
"0.5279934",
"0.5279934",
"0.5275391",
"0.52680635",
"0.5265599",
"0.52605355",
"0.52509165",
"0.52507967",
"0.5247009",
"0.52445585",
"0.52318215"
] | 0.53991157 | 60 |
Instantiate Coin with the attributes below, adds + sign for positive change numbers | def initialize(name, price_usd, price_btc, market_cap_usd, percent_change_24h, last_updated_unix)
@name = name
@price_usd = price_usd.to_f.round(2)
@price_btc = price_btc.to_i
@market_cap_usd = market_cap_usd.to_i
@percent_change_24h = percent_change_24h.to_i
@last_updated_unix = last_updated_unix
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_coin(coin)\n name = coin['name']\n price_usd = coin['price_usd']\n price_btc = coin['price_btc']\n market_cap_usd = coin['market_cap_usd']\n percent_change_24h = coin['percent_change_24h']\n last_updated_unix = coin['last_updated']\n CryptoMarket::Coin.new(name, price_usd, price_btc, market_cap_usd,\n percent_change_24h, last_updated_unix).tap do |new_coin|\n coins << new_coin\n end\n end",
"def coin_change(coins, amount)\n make_change(coins, amount, 0, {})\nend",
"def creditCoins(amount)\r\n @betESSCoins += amount\r\n end",
"def make_better_change(value, coins)\n\nend",
"def make_better_change(value, coins)\n\nend",
"def make_better_change(value, coins)\n\nend",
"def run\n create_coins_from_attributes\n end",
"def initialize (amount, currency)\n\n #Amount is stored in BigDecimal for better precision in currency operations\n @amount_bigdecimal = BigDecimal.new(amount,0)\n\n @currency = currency\n\n end",
"def initialize (amount, code = \"USD\")\n #need default for object to accept 1 argument\n @code = code #currency code\n @amount = amount #amount\n @@count +=1\n #add 1 to count everytime a new object is made for the class\n end",
"def add_time(coin)\n\n end",
"def put_coin(value)\n @calculator.add_pending value\n end",
"def create\n @coin = Coin.new(coin_params)\n\n respond_to do |format|\n if @coin.save\n format.html { redirect_to @coin, notice: 'Coin was successfully created.' }\n format.json { render :show, status: :created, location: @coin }\n else\n format.html { render :new }\n format.json { render json: @coin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def +(currency_object)\n if @currency_symb == currency_object.currency_symb\n Currency.new(@amount +currency_object.amount)\n else\n raise UnknownCurrencyCodeError\n end\n #puts \"The value of the new curent currecy is #{@amount}.\" #This will print the new amount.\n #puts \"The value of the currency_object's amout is #{currency_object.amount}\"\nend",
"def greedy_make_change(target, coins=[25,10,5,1])\nend",
"def create_coins_from_attributes\n @api_data.each do |coin|\n create_coin(coin)\n end\n end",
"def set_coin\n @coin = Coin.find(params[:id])\n end",
"def make_change(amount)\n amount = amount * 100\n\n change = []\n @currency.each do |key, value|\n num_coins, amount = coins_per_amount(value, amount)\n change << [key] * num_coins\n end\n change.flatten\n end",
"def +(another_currency)\n\n #converts the given instance in the actual currency and sums the amounts\n amount = @amount_bigdecimal + another_currency.convert_to(@currency).amount\n\n #returns the result as a new instance\n Xchange.new(amount,@currency)\n\n end",
"def initialize\n @balance = 0\n end",
"def initialize(name = \"\", price = 0, weight = 0)\n self.name = name\n self.price = price\n self.weight = weight\n @quantity = 0\n @description = \"\"\n @@ship_price_per_oz = 1.2\n end",
"def set_coin\n @coin = Coin.find(params[:id])\n end",
"def initialize\n\t\t@mult = 1.1\n @name = 'High Low'\n @min = 1\n @game_money = $player.wallet.amount #game_money\n @game_bet = 0\n\tend",
"def create\n @coin = Coin.new(coin_params)\n\n if @coin.save\n render :show, status: :created, location: @coin\n else\n render json: @coin.errors, status: :unprocessable_entity\n end\n end",
"def initialize(amount, currency_code)\n @amount = amount.to_f\n @currency_code = currency_code\n end",
"def set_coin\n @coin = Coin.find(params[:id])\n end",
"def set_coin\n @coin = Coin.find(params[:id])\n end",
"def set_coin\n @coin = Coin.find(params[:id])\n end",
"def -@\n Money.new(-cents)\n end",
"def initialize(amount, currency)\n set_amount(amount)\n set_currency(currency)\n end",
"def create\n @mint_coin = @coin.mint_coins.build(params[:mint_coin])\n \n respond_to do |format|\n if @mint_coin.save\n format.html { redirect_to coin_mint_coins_url([@coin]), :notice => 'Mint coin was successfully created.' }\n format.json { render :json => @mint_coin, :status => :created, :location => @mint_coin }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @mint_coin.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def console_add_money(amount)\n credits.create!(amount: amount, note: \"Admin added #{amount} cents\")\n end",
"def new_quantity args={}\n SY::Quantity.new args.merge( composition: self )\n end",
"def initialize(amount, currency)\n\t\t@amount = amount.to_f\n\t\t@currency = currency\n\tend",
"def initialize(balance)\n @balance = balance\n end",
"def initialize(name, gold, min, max, kind)\n @name = name\n @goldCoins = gold\n @minBonus = min\n @maxBonus = max\n @kind = kind\n end",
"def initialize(amount, currency_code)\n @amount = amount\n @currency_code = currency_code\n end",
"def add_cash(amount)\n transaction = Transaction.new\n transaction.transaction_type_id = 1\n transaction.seller_id = self.id\n transaction.price = Setting.first.exchange_rate\n transaction.amount = amount\n transaction.save\n self.update_portfolio\n return transaction\n end",
"def initialize(starting_balance)\n @balance = starting_balance\n end",
"def coin_params\n params.require(:coin).permit(:value, :name)\n end",
"def initialize(balance:)\n @balance = balance\n @change = nil\n @product = nil\n end",
"def create\n @our_coin = OurCoin.new(params[:our_coin])\n\n respond_to do |format|\n if @our_coin.save\n format.html { redirect_to @our_coin, :notice => 'Our coin was successfully created.' }\n format.json { render :json => @our_coin, :status => :created, :location => @our_coin }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @our_coin.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def change(amount, coins)\n return 0 if coins.empty?\n\n # TO make zero, there is one way. Dont give anything.\n ways = Array.new(amount + 1, 0)\n ways[0] = 1\n coins.each do |coin|\n (coin..amount).each do |amt|\n ways[amt] += ways[amt - coin]\n end\n end\n ways[-1]\nend",
"def -@\n Money.new(-value, currency, precision)\n end",
"def create\n @mycoin = Mycoin.new(mycoin_params)\n\n \n respond_to do |format|\n if @mycoin.save\n format.html { redirect_to @mycoin, notice: 'Mycoin was successfully created.' }\n format.json { render :show, status: :created, location: @mycoin }\n else\n format.html { render :new }\n format.json { render json: @mycoin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def -(another_currency)\n\n #converts the given instance in the actual currency and substracts the amounts\n amount= @amount_bigdecimal - another_currency.convert_to(@currency).amount\n\n #returns the result as a new instance\n Xchange.new(amount,@currency)\n\n end",
"def create_transaction\n Transaction.new(\n player,\n [certificate],\n @source,\n [@source.cost(certificate)]\n )\n end",
"def +(other)\n Money.create_from_cents((cents + other.to_money.cents))\n end",
"def display_coins\n end",
"def -@\n return Money.new(-amount, currency)\n end",
"def add_money(value)\n raise_invalid_coin! if @money[value.to_s].nil?\n @money[value.to_s] += 1\n update_money\n end",
"def initialize(buyer, price, amount)\n @buyer = buyer\n @bid_price = price\n @desired_amount = amount\n @bought_amount = 0\n end",
"def add_transaction( **attributes )\n\t\tcheck_for_required_attributes( attributes )\n\t\tattributes[:amount] = normalize_amount( attributes[:amount] )\n\t\tsuper\n\tend",
"def +(other)\n raise TypeError.new(\"Argument is not a Money object\") unless other.instance_of?(Money)\n \n d = @dollars + other.dollars\n c = @cents + other.cents\n\n if c >= 100\n d = d + 1\n c = c % 100\n end\n \n Money.new(d,c)\n end",
"def initialize(name, balance=100)\n @name = name\n @balance = balance\n end",
"def initialize(dollars=0, cents=0)\n @dollars = dollars\n @cents = cents\n end",
"def initialize(dollars=0, cents=0)\n @dollars = dollars\n @cents = cents\n end",
"def increment_coin(transaction_coin_value)\n system_coin_value = @user_coin.value\n increment_value = system_coin_value.to_i + transaction_coin_value.to_i\n @user_coin.update(value: increment_value)\n if ((system_coin_value > 10) || (system_coin_value > transaction_coin_value.to_i))\n @user_coin.update(count_status: 'high')\n end\n end",
"def initialize\n super\n @bet_amount = 0\n end",
"def initialize\n @api_data = CryptoMarket::Api.fetch_coin_data\n @coins = []\n end",
"def initialize_account\n self.credits = 0\n end",
"def abs\n return self.class.new(amount.abs, currency)\n end",
"def initialize(notes = DEFAULT_BALANCE)\n @balance = {}\n deposit(notes)\n end",
"def initialize(cents, currency = nil, bank = nil)\n @cents = cents.to_i\n @currency = (currency || Money.default_currency).upcase\n @bank = bank || Money.default_bank\n end",
"def initialize(company, symbol, price_per_share, currency, quantity)\n @company = company\n @symbol = symbol\n @price_per_share = price_per_share.to_i\n @currency = currency\n @quantity = quantity\n end",
"def initialize(name, price, currency, shares)\n @name = name\n @price = price\n @currency = currency.upcase\n @shares = shares\n convert_curr\n shares_totals\n end",
"def coin_params\n params.require(:coin).permit(:number)\n end",
"def make_change(amount, denominations)\n\nend",
"def create\n @coin_attribute = @coin.coin_attributes.build(params[:coin_attribute])\n\n \n respond_to do |format|\n if @coin_attribute.save\n format.html { redirect_to coin_coin_attributes_url([@coin]), :notice => 'Attribute was successfully created.' }\n format.json { render :json => @coin_attribute, :status => :created, :location => @coin_attribute }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @coin_attribute.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def coin_params\n params.require(:coin).permit(:coin_api_id, :name, :symbol)\n end",
"def flip_coin\n @state.flip_coin(self)\n end",
"def accept_coins(coins_hash)\n coins_hash[:valid][:coins].each do |k, v|\n while v > 0\n @coins << Coin.new(k)\n v -= 1\n end\n end\n end",
"def -(other)\n Money.create_from_cents((cents - other.to_money.cents))\n end",
"def test_should_be_able_to_be_added\n currency1 = Currency.new(\"USD\", 1.0)\n currency2 = Currency.new(\"USD\", 5.0)\n\n assert_equal Currency.new(\"USD\", 6.0), currency1.+(currency2)\n end",
"def initialize(name, amount)\n\t\t\t@name = name\n\t\t\t@amount = amount\n \n\t\tend",
"def coin_change2(coins, amount)\n coins_needed = Hash.new do |hash, key|\n coins_needed_after_one = coins.select {|coin_value| coin_value <= key}.map {|coin_value| hash[key-coin_value]}\n .reject {|coins_needed| coins_needed == -1}.min\n hash[key] = if coins_needed_after_one == nil then -1 else 1 + coins_needed_after_one end\n end.update(0 => 0)\n \n #This is just to prevent stack overflow. If you tried to directly calculate amount you might have too many calls down.\n (1..amount).each {|current| coins_needed[current]}\n \n coins_needed[amount]\nend",
"def give_coins(from_addr, to_addr, coins, acc_balances)\n acc_balances[from_addr] = acc_balances[from_addr].to_i - coins.to_i\n acc_balances[to_addr] = acc_balances[to_addr].to_i + coins.to_i\n\n acc_balances\nend",
"def make_change( amount )\n #REMOVED IN REFACTOR: coins = changer( pull_cents( f ), COINS )\n #REMOVED IN REFACTOR: bills = changer( pull_bills( f ), BILLS )\n coins = changer( pull_currency( amount ){ | s, idx | currency = s[ idx + 1..-1 ] }, COINS )\n bills = changer( pull_currency( amount ){ | s, idx | currency = s[ 0...idx ] }, BILLS )\n [ bills, coins ]\n end",
"def initialize(make, model, make_year, origin_price)\n @make = make\n @model = model\n @make_year = make_year\n @origin_price = origin_price\n @current_value = current_value\n @dealer_price = current_value + dealer_markup\n end",
"def hold_coins num\n @held_coins = num\n end",
"def initialize(turn, amount, corporate_bonus)\n super(turn)\n @amount = amount\n @corporate_bonus = corporate_bonus\n end",
"def make_change(amount)\n\tcoin_values = [25, 10, 5, 1]\n\tcoins = []\n\n\tcoin_values.each do |value|\n\t\twhile amount >= value\n\t\t\tcoins.push(value)\n\t\t\tamount -= value\n\t\tend\n\tend\n\n\t# while (amount - 25) >= 0\n\t# \tcoins.push(25)\n\t# \tamount -= 25\n\t# end\n\n\t# while (amount - 10) >= 0\n\t# \tcoins.push(10)\n\t# \tamount -= 10\n\t# end\n\n\n\t# while (amount - 5) >= 0\n\t# \tcoins.push(5)\n\t# \tamount -= 5\n\t# end\n\n\t# while (amount - 1) >= 0\n\t# \tcoins.push(1)\n\t# \tamount -= 1\n\t# end\n\tcoins\nend",
"def initialize(title, amount)\n @title = title\n @amount = amount\n end",
"def initialize(id, balance, open_date)\n\t\t# ruby dosen't like constants in intialize values, lowercase it\n\t\t\t@id = id\n\t\t\t@balance = balance\n\t\t\t@open_date = open_date\n\t\t\t# pretty_initial_balance = (@initial_balance / 100).to_f\n\t\t\tis_negative # method to determine if transaction would lead to overdraft\n\t\tend",
"def original\n original_amount\n end",
"def make_change(num)\n\t\n\tarray = []\n\n\tamount = num\n\tquaters = amount/25\n\t# puts quaters \n\tamount_left= num - (quaters * 25 )\n\tdime = amount_left/10\n\t# puts dime\n\tamount_left2 = num - (quaters*25+dime*10)\n\tnickel = amount_left2/5\n\t# puts nickel\n\tamount_left3 = num - (quaters*25+dime*10+nickel*5)\n\tpenny = amount_left3/1\n\t# puts penny\n\tarray.push((quaters*25),(dime*10),(nickel*5),penny)\n\tarray\n\n\t# coins = []\n\n\t# while (amount-25) >= 0\n\t# \tcoins.push(25)\n\t# \tamount -=25\n\t# end\n\n\n\n\nend",
"def initialize(hex)\n super\n @a = 1\n @hex = hex\n end",
"def create_transaction\n Transaction.new(\n player,\n [director_certificate],\n @game.initial_offering,\n [@par_price * director_certificate.num_shares]\n )\n end",
"def initialize(amount, currency)\n @amount = amount.to_f.round(2)\n @base_currency = currency\n @bank = Bank.instance\n end",
"def cost\n super + 0.10\n end",
"def cost\n super + 0.10\n end",
"def player_coin=(coins)\n $game_variables[Yuki::Var::CoinCase] = coins\n end",
"def make_change_iterative(amount, coins = [25, 10, 5, 1])\n change = []\n coins.each do |coin|\n count = amount / coin # how many of that coin I can use\n count.times { change << coin }\n amount -= count * coin\n end\n \n change\nend",
"def cost\n super + 0.20\n end",
"def initialize(snack_price_cents, snack_count)\n @user_balance_cents = 0\n @snack_count = snack_count\n @snack_price_cents = snack_price_cents\n end",
"def cost\n super + 0.15\n end",
"def add_year_growth(coins)\r\n \r\n coins.each do |x|\r\n \r\n puts 'x.name: ' + x.name if @debug\r\n \r\n if @growth.has_key?(x.name) then\r\n x.percent_change_year = @growth[x.name].to_s\r\n else\r\n x.percent_change_year = '-'\r\n end\r\n end \r\n \r\n coins\r\n \r\n end",
"def initialize(*args)\n @id, @name, @money,\n @bitcoins, @credits,\n @experience, @rank,\n @builders, @x, @y,\n @country, @skin = args\n end",
"def +(other)\n raise TypeError unless other.is_a?(Money)\n if self.base_currency == other.base_currency\n Money.new(amount + other.amount, base_currency)\n else\n Money.new(amount + other.convert_to(self.base_currency).amount, base_currency)\n end\n end",
"def *(number)\n\n #performs the multiplication in BigDecimal\n amount= @amount_bigdecimal * BigDecimal(number,0)\n\n #returns the result as a new instance\n Xchange.new(amount,@currency)\n\n end",
"def initialize(n)\n\n @balance = n\n @ledger = []\n\n end"
] | [
"0.62319946",
"0.61666965",
"0.6109753",
"0.60831803",
"0.60831803",
"0.60831803",
"0.5875681",
"0.58481145",
"0.58333826",
"0.57771313",
"0.57499164",
"0.5746851",
"0.5723386",
"0.5706028",
"0.5685634",
"0.56356573",
"0.562961",
"0.5609288",
"0.5599456",
"0.5585126",
"0.5585025",
"0.5582925",
"0.55727077",
"0.55451846",
"0.5534181",
"0.5534181",
"0.5534181",
"0.5521697",
"0.5509885",
"0.55029184",
"0.5492145",
"0.5482561",
"0.54822385",
"0.5466719",
"0.54666835",
"0.5457687",
"0.5454096",
"0.54518425",
"0.5447544",
"0.5436655",
"0.5432779",
"0.54225373",
"0.5416778",
"0.54154444",
"0.54071176",
"0.539934",
"0.5396824",
"0.53947145",
"0.53916866",
"0.5390251",
"0.5389792",
"0.5372927",
"0.537281",
"0.53724456",
"0.5371644",
"0.5371644",
"0.53700614",
"0.53659874",
"0.53643435",
"0.53631663",
"0.536312",
"0.53586847",
"0.5358114",
"0.53440917",
"0.53373694",
"0.5335291",
"0.53304344",
"0.5311567",
"0.53074783",
"0.5282411",
"0.5281794",
"0.52752066",
"0.52734876",
"0.5268495",
"0.5266517",
"0.52642953",
"0.5262862",
"0.5261637",
"0.5257199",
"0.5254052",
"0.5253305",
"0.5235257",
"0.52342576",
"0.52273786",
"0.522531",
"0.52179134",
"0.5215968",
"0.5208469",
"0.520672",
"0.520672",
"0.52052045",
"0.52034557",
"0.51975375",
"0.5194229",
"0.5187252",
"0.5184598",
"0.5179239",
"0.5178687",
"0.51779395",
"0.5175106"
] | 0.55036384 | 29 |
Prints out the coin attributes for the Coin object with terminaltable gem | def attributes
table = terminal_table do |t|
t.title = name.upcase
t.add_row ["Price USD:", "$#{price_usd}"]
t.add_row ["Price BTC:", "#{price_btc}"]
t.add_row ["Market Cap USD:", "$#{market_cap_usd}"]
t.add_row ["Change Last 24h:", "#{percent_change_24h}%"]
t.add_row ["Last Updated:", "#{Time.at(last_updated_unix.to_i)}"]
t.style = { all_separators: true, width: 60 }
end
puts table
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_coin_names\n coin_names_arrays.each do |coin|\n coin.each do |name|\n index = name.slice!(/\\d+\\s/).strip\n table = terminal_table do |t|\n t.add_row [index, name]\n t.style = { all_separators: true, width: 60 }\n end\n puts table\n end\n yield\n end\n end",
"def details\n\n puts \"\"\n puts \"Todays crypto update:\"\n puts \"Volume is the amount of the coin that has been traded with in a certain time frame...fyi\"\n puts \"----------------------------------------------------------------------\"\n puts \"| Coin (Symbol) | Volume (1 day) | Volume (7 day) | Volume (30 day) |\"\n puts \"----------------------------------------------------------------------\"\n puts \"\"\n\n @coins = TheCryptoUpdate::Coin.all[0..99]\n\n @coins.find do |coin|\n puts \" #{coin.name} (#{coin.symbol}) | $#{coin.volume_1d} | $#{coin.volume_7d} | $#{coin.volume_30d} |\"\n end\n\n end",
"def display_coins\n end",
"def print_sorted_prices\n sort_by_price_usd.each do |coin|\n unless coin.price_usd == 0\n table = terminal_table do |t|\n t.add_row [coin.name, \"$#{coin.price_usd}\"]\n t.style = { all_separators: true, width: 60 }\n end\n puts table\n end\n end\n end",
"def show_coins_list\n coins_list(coins)\n end",
"def print_billcoins\r\n\t\t@billcoins.each_pair {|k, v| puts \"#{k}: #{v} billcoins\" unless k==\"SYSTEM\"}\t# don't print SYSTEM billcoin count\r\n\tend",
"def print_fields\r\n\t\tputs \"name: #{@name}\"\r\n\t\tputs \"num_billcoins: #{@num_billcoins}\"\r\n\t\tputs \"\"\r\n\tend",
"def list_top_coins\n # here doc - http://blog.jayfields.com/2006/12/ruby-multiline-strings-here-doc-or.html\n puts <<-DOC.colorize(:cyan)\n ____ ____ ____ _________ ____ ____ ____ ____ ____ ____ _________ ____ ____ ____ ____ ____ ____\n ||T |||h |||e ||| |||C |||r |||y |||p |||t |||o ||| |||U |||p |||d |||a |||t |||e ||\n ||__|||__|||__|||_______|||__|||__|||__|||__|||__|||__|||_______|||__|||__|||__|||__|||__|||__||\n |/__\\|/__\\|/__\\|/_______\\|/__\\|/__\\|/__\\|/__\\|/__\\|/__\\|/_______\\|/__\\|/__\\|/__\\|/__\\|/__\\|/__\\|/__\\|/__\\|/__\\|/__\\||\n\n DOC\n\n puts \"Top 100 Cryptocurrencies By Market Capitalization\"\n puts \"\"\n puts \"Todays crypto update:\"\n puts \"-----------------\"\n puts \"| Coin (Symbol) |\"\n puts \"-----------------\"\n\n @coins = TheCryptoUpdate::Coin.all[0..99]\n\n @coins.each.with_index(1) do |coin, i|\n # puts \"#{i}. #{coin.name} (#{coin.symbol}) | $#{coin.volume_1d} | #{coin.volume_7d}% | #{coin.volume_30d}% |\"\n puts \"#{i}. #{coin.name} (#{coin.symbol})\"\n end\n\n end",
"def display_stats\n #Table of dragon stats\n table = Terminal::Table.new do |t|\n t.headings = ['Type','Dragon']\n t.add_row ['HP', '100']\n end\n puts table #print table \n end",
"def print_player(player)\n puts \"Player #{player.id}: Balance: #{player.money}. \"\n end",
"def print_sorted_changes(input = nil)\n sort_by_change(input).each do |coin|\n table = terminal_table do |t|\n t.add_row [coin.name, \"#{coin.percent_change_24h}%\"]\n t.style = { all_separators: true, width: 60 }\n end\n puts table\n end\n end",
"def print_result\n @balance.sort.each do |key, value|\n puts \"#{key}: #{value} billcoins\" if value != 0\n end\n end",
"def display_resource(coin)\n \"#{coin.name} (#{coin.symbol})\"\n end",
"def bin_status\n rows = []\n\n # loop through to find all available bin space\n self.bins.each do |bin|\n rows << [bin.type, \"#{bin.bin_level}%\"]\n end\n # Drawing and styling the table\n table = Terminal::Table.new :rows => rows\n table = Terminal::Table.new :title => ' Your available bin space '.light_white.on_light_red, :headings => ['Bin type'.light_white, 'How much used'.light_white], :rows => rows, :style => {:width => 100, :padding_left => 1, :border_x => \"=\"}\n\n puts table\n end",
"def print_list(shopping_list)\n table = Terminal::Table.new :title => @list_name, :headings => ['Item'.white.on_green, 'Quantity'.white.on_green], :rows => shopping_list[\"items\"]\n table.style = {:width => 40, :padding_left => 3, :border_x => \"-\", :border_i => \"x\"}\n puts table\nend",
"def inspect\n to_table.render :ascii\n end",
"def print_wallet\n\t\tputs \"\\n\\n\\n\"\n\t\tputs \"Your balance: #{@balance.round(2)}\"\n\tend",
"def terminal_table\n rows = @moods.map do |mood|\n mood.to_arr\n end\n table = Terminal::Table.new({ headings: HEADINGS, rows: rows })\n puts table\n end",
"def print_meals\n meals.reset\n puts separator_line\n table = TTY::Table.new\n table << [\"Index\", \"Title\", \"Status\", \"On Shopping List?\", \"Rating\", \"Notes\"].map{|item|\n ptext(item)\n }\n meals.each_with_index do |meal, index|\n table << [\n index+1,\n meal.recipe.title,\n meal.active == false ? \"Cooked\" : \"Awaiting Cooking\",\n meal.shopping == true ? \"Yes\" : \"No\",\n !meal.rating.nil? ? meal.rating.to_5_stars : \"[Unrated]\",\n !meal.notes.nil? ? meal.notes.max_line_length(50) : \"None.\"\n ]\n end\n\n putable = table.render(:ascii, multiline: true, padding: [1,1,1,1]) do |renderer|\n renderer.border.separator = TTY::Table::Border::EACH_ROW\n end\n puts putable\n end",
"def print_concordance\n puts \"\\n\\nPrinting concordance...\\n\\n\"\n sorted_keys = @result.keys.sort\n sorted_keys.each do |key|\n puts \"#{key.ljust(20)} {#{@result[key][:count]}:#{@result[key][:line_nums].join(',')}}\"\n end\n end",
"def show_balance(header = \"NODE BALANCE\")\n\n puts \"\\n#{header}\"\n puts \"=\" * header.length\n\n @weights.each do |node,providers|\n puts \"#{node}\"\n providers.each do |label,detail|\n printf \" %-12s weight = %2d | serve_mode = %-8s | status = %-4s | address = %s\\n\",\n label, detail['weight'], detail['serve_mode'], detail['status'], detail['address']\n end\n end\n\n puts \"\"\n end",
"def table_entry(item)\n line = item.name.dup\n line << \"|#{format_coverage(item.total_percentage)}\"\n line << \"|#{format_coverage(item.line_rate)}\" if header_line_rate?\n line << \"|#{format_coverage(item.branch_rate)}\" if header_branch_rate?\n line << \"\\n\"\n end",
"def print_fields\r\n\t\tputs \"from_address: #{@from_address}\"\r\n\t\tputs \"to_address: #{@to_address}\"\r\n\t\tputs \"num_billcoins: #{@num_billcoins}\"\r\n\t\tputs \"\"\r\n\tend",
"def display_object\n\tputs \"Name: #{name}\"\n\tpretty_price = format(\"%0.2f\", price)\n\tputs \"Price: $#{pretty_price}\"\n\tputs \"Size: #{size}\"\n end",
"def print_order\n p \"@@@@@@@@@ Order id: ##{order.attrs['id']}\"\n p \"Name: #{order.attrs['name']} Email: #{order.attrs['email']}\"\n p \"Status: #{order.attrs['status']}\"\n\n conn = DatabaseConnector.new.connect\n rs = conn.exec \"select li.*, products.name from line_items as li INNER JOIN products on li.product_id = products.id where li.order_id = '#{order.attrs['id']}'\"\n\n char_len = 30\n rs.each do |row|\n prod_name = \"#{row['id']} : #{row['name']}\"\n\n p \"#{prod_name} #{'-'*(char_len - prod_name.length)}---> #{row['amount']} X #{row['quantity']} = #{row['amount'].to_f * row['quantity'].to_i}\"\n end\n p '-'*55\n if order.attrs['discont_desc'] != ''\n p \"Sub Total #{'-'*25} -> #{order.attrs['sub_total']}\"\n p \"Coupon #{'-'*25} -> #{order.attrs['discont_desc']}\"\n p \"You Saved #{'-'*25} -> #{order.attrs['amount'].to_i - order.attrs['sub_total'].to_i}\"\n p '-'*55\n end\n p \"Total #{'-'*25} -> #{order.attrs['amount']}\"\n end",
"def print\n table_header = \"Last Name | First Name | Gender | Date of Birth | Favorite Color\"\n puts table_header\n puts \"-\" * 50\n @people_array.each do |p|\n puts \"#{p['LastName']} | #{p['FirstName']} | #{p['Gender']} | #{p['DateOfBirth']} | #{p['FavoriteColor']}\"\n end\n end",
"def print()\n printf \"\\nAuthor ID: %d affiliation: %s affiliation short: %s country: %s\\n\", self.article_author_id, self.name, self.short_name, self.country\n printf \"\\nAddress: %s, %s, %s, %s, %s\\n\", self.add_01, self.add_02, self.add_03,self.add_04, self.add_05\n end",
"def output_table(title = '', headings, rows)\n table = Terminal::Table.new\n table.title = title unless title.empty?\n table.rows = rows\n table.headings = headings\n table.style = {\n :padding_left => 1,\n :padding_right => 1\n }\n\n puts table\n end",
"def print_table_t(objects, *method_names)\n terminal_width = `tput cols`.to_i\n cols = objects.count + 1 # Label column\n col_width = (terminal_width / cols) - 1 # Column spacing\n\n Array(method_names).map do |method_name|\n cells = objects.map { |o| o.send(method_name).inspect }\n cells.unshift(method_name)\n\n puts cells.map { |cell| cell.to_s.ljust(col_width) }.join \" \"\n end\n nil\nend",
"def table\n @assets.collect() do |asset|\n # Available keys\n # [\"cusip\", \"accountName\", \"description\", \"tradingRatio\", \"source\",\n # \"type\", \"taxCost\", \"originalTicker\", \"originalCusip\", \"holdingType\",\n # \"price\", \"percentOfParent\", \"fundFees\", \"percentOfTMV\", \"value\",\n # \"originalDescription\", \"ticker\", \"quantity\", \"manualClassification\",\n # \"oneDayValueChange\", \"change\", \"sourceAssetId\", \"feesPerYear\",\n # \"external\", \"userAccountId\", \"priceSource\", \"costBasis\", \"exchange\",\n # \"oneDayPercentChange\"]\n [\n asset[\"accountName\"],\n asset[\"description\"],\n classes[-3], # My Class\n classes[-2], # One of the 7 Classes\n classes[-1], # Sector\n asset[\"ticker\"],\n asset[\"quantity\"],\n asset[\"price\"],\n asset[\"value\"],\n asset[\"cusip\"],\n asset[\"taxCost\"],\n asset[\"fundFees\"],\n asset[\"feesPerYear\"],\n asset[\"type\"],\n \"EOL\"\n ]\n end\n end",
"def print\n\n #Each variable of the array is of type class and the |l| allows you to access\n #each instance of the class individually as you would with a single\n #class type variable \n @ledger.each do |l|\n puts \"#{l.date} #{l.payee} #{l.amount} #{l.currBalance}\"\n end\n\n puts \"Current Balance: #{@balance}\"\n\n end",
"def show\n @coin_attribute = @coin.coin_attributes.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @coin_attribute }\n end\n end",
"def print_register\n puts \"#{name}'s' Bank Account\"\n puts \"/\" * 40\n\n puts \"Description\".ljust(30) + \"Amount\".rjust(10)\n puts \"/\" * 40\n @transactions.each do |transaction|\n puts transaction[:description].ljust(30) + sprintf(\"%0.2f\", transaction[:amount]).rjust(10)\n end\n\n puts \"-\" * 40\n\n puts \"Ending Balance:\".ljust(30) + sprintf(\"%0.2f\", balance).rjust(10)\n puts \"-\" * 40\n end",
"def output\n alphabetical_keys = @concordance_hash.keys.sort\n alphabetical_keys.each do |key|\n value = \"{\" + @concordance_hash[key][0].to_s + \":\" +\n @concordance_hash[key][1..-1].to_s.delete(\"[] \") + \"}\"\n\n printf \"%-25s %s \\n\", key, value\n end\n end",
"def dump\n info \"販売価格:#{@sell_price},買取価格:#{@purchase_price},利益:#{@yield}\\n\"\n #ap \"販売価格:#{@sell_price}\\n買取価格:#{@purchase_price}\\n利益:#{@yield}\\n\"\n end",
"def inspect\n \"#{'%.2f' % self.amount} #{self.currency}\"\n end",
"def show_info()\n\t\tputs \"ID: #{@@id}\"\n\t\tputs \"Name: #{@car_name}\"\n\t\tputs \"Make: #{@@make}\"\n\t\tputs \"Cost: #{calc_total_cost} INR\"\n\t\tputs\n\t\tputs \"Review: #{@review}\"\n\t\tputs \"Rating: #{@rating} stars\"\n\tend",
"def build_table(patients)\n rows = []\n patients.each do | person |\n rows << [person[:bed_no], person[:hospital_no], person[:first_name], person[:last_name], person [:dob], person[:age], person[:current_diagnosis] ]\n x = person[:medications]\n puts x[:name]\n end\n\n\n table = Terminal::Table.new :rows => rows\n table.title = \"Your Patients for the Day!\"\n table.headings = ['Bed Number', 'Hospital Number', 'First Name', 'Last Name', 'D.O.B', 'Age', 'Current Diagnosis', 'Medications']\n puts table\nend",
"def print_info\n puts \"#{self.country} (#{self.country_code}):\".light_cyan\n puts \" New Confirmed Cases: #{self.new_confirmed}\".light_red\n puts \" Total Confirmed Cases: #{self.total_confirmed}\".light_red\n puts \" New Deaths: #{self.new_deaths}\".light_red\n puts \" Total Deaths: #{self.total_deaths}\".light_red\n puts \" New Recovered Cases: #{self.new_recovered}\".light_red\n puts \" Total Recovered Cases: #{self.total_recovered}\".light_red\n puts \"This information was last updated at #{self.date}\".light_cyan\n end",
"def print_attributes(object, keys)\n keys.each do |key|\n puts \"#{key}: #{object[key]}\"\n end\n puts \"\\n\"\nend",
"def print_balances(acc_balances)\n acc_balances.keys.sort.each do |acc_no|\n balance = acc_balances[acc_no]\n puts \"#{acc_no}: #{balance} billcoins\" if balance.positive?\n end\nend",
"def statement\n @printer.print(@transactions)\n end",
"def show\n puts \"\n ID: #{id}\n Balance: #{balance}\n Date: #{open_date}\"\n end",
"def index\n @coin_attributes = @coin.coin_attributes\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @coin_attributes }\n end\n end",
"def print_climb(climb)\n\tputs \"\"\n puts \"Name: #{climb.name}\"\n puts \"Grade: #{climb.grade}\"\n puts \"Type: #{climb.type}\"\n puts \"URL: #{climb.url}\"\n puts \"\"\n puts \"---------------Description--------------\"\n puts \"\"\n puts \"#{climb.description}\"\n puts \"\"\nend",
"def table(opts = { print: true })\n require \"inspec/ui_table_helper\"\n\n the_table = TableHelper.new\n yield(the_table)\n\n colorizer = proc do |data, row, _col|\n if color? && row == 0\n ANSI_CODES[:bold] + ANSI_CODES[:color][:white] + data.to_s + ANSI_CODES[:reset]\n else\n data\n end\n end\n render_mode = color? ? :unicode : :ascii\n padding = [0, 1, 0, 1] # T R B L\n result = the_table.render(render_mode, filter: colorizer, padding: padding) + \"\\n\"\n print_or_return(result, opts[:print])\n end",
"def spending_table(hash, total)\n puts \"\".center(80, \"_\")\n hash.each{ |item, value| puts tabled_format(item, value) }\n puts \"\".center(80, \"_\")\n total = hash.values.inject(:+)\n puts tabled_format(\"Total\", total)\n end",
"def show_table_of players, dealer\r\n hit_stay = ['RANDOM']\r\n bet_pattern = ['RANDOM', 'KELLY']\r\n \r\n puts 'Dealer: ' + players[dealer][:name] + '($' + players[dealer][:total_chips].to_s + ')'\r\n puts ''\r\n \r\n turn = (dealer + 1) % players.length\r\n \r\n name_width = 10\r\n hit_stay_width = 15\r\n bet_pattern_width = 20\r\n chips_width = 15\r\n rate_width = 15\r\n puts 'Name'.ljust(name_width) + 'Hit/Stay'.rjust(hit_stay_width) + 'Bet Pattern'.rjust(bet_pattern_width) + 'Chips'.rjust(chips_width) + 'Rate'.rjust(rate_width)\r\n while turn != dealer\r\n player = players[turn]\r\n\tname = player[:name] + ((if_bankrupt(player))? ' (X)' : '')\r\n\thit_stay_string = (player[:is_human] == 1)? 'x' : hit_stay[player[:hit_stay]]\r\n\tbet_pattern_string = (player[:is_human] == 1)? 'x' : bet_pattern[player[:bet_pattern]]\r\n\tchips_string = player[:total_chips].to_s\r\n\trate_string = (player[:rate] * 100.0).round(2).to_s + '%' \r\n\t\r\n\tputs name.ljust(name_width) + hit_stay_string.rjust(hit_stay_width) + bet_pattern_string.rjust(bet_pattern_width) + chips_string.rjust(chips_width) + rate_string.rjust(rate_width)\r\n\t\r\n\tturn = (turn + 1) % players.length\r\n end\r\n puts ''\r\nend",
"def display_port\n @port.each do |x|\n puts \"Company: #{x.name}\"\n puts \"Shares: #{x.shares}\"\n puts \"Price: #{x.price}#{x.currency}\"\n puts \"To USD: $#{sprintf('%.2f', x.con)}\"\n puts \"Total: #{x.total}#{x.currency}\"\n puts\n end\n end",
"def display_total (person)\n puts \"#{person.name}'s total is #{person.hand_value(person.hand)}.\" \n end",
"def inspect\n pairs = []\n # Use the table's column list to order our columns\n @table.columns.each { |name| pairs << \"#{name}: #{@attributes[name].inspect}\"}\n inspection = pairs.compact.join(', ')\n \"#<#{self.class} #{inspection}>\"\n end",
"def print_table(n)\n printer = Printer.new(first n)\n printer.print\n end",
"def inspect\n str = \"<#{self.class}\"\n for k,v in (@__table__ ||= {})\n str << \" #{k}=#{v.inspect}\"\n end\n str << \">\"\n end",
"def to_s; @coins.join \",\" end",
"def costs\n font \"Helvetica\"\n fill_color \"555555\"\n text \"Costs Log\", align: :center, size: 12, style: :bold\n fill_color \"000000\"\n table([\n [\"Consumable/Part name\", \"Individual price\", \"Quantity\", \"Total\"],\n [\"\",\"\",\"\",\"\"],\n [\"\",\"\",\"\",\"\"],\n [\"\",\"\",\"\",\"\"],\n [\"\",\"\",\"\",\"\"]\n ], :header => true,\n :position => :center,\n :column_widths => [212, 106, 106, 106],\n :cell_style => {:font => \"Helvetica\", :size => 12, :height => 35, :align => :center}\n )\n end",
"def print_inventory\n @inventory.each do |couple|\n puts couple.first.name + \" (#{couple.second})\"\n end\n print \"\\n\"\n end",
"def preetify\n preety_print do |instance|\n instance['users'].each_with_index do |user, index|\n puts \"user_#{index}\".to_s.ljust(30) + user['name'].to_s\n end\n\n instance['tickets'].each_with_index do |ticket, index|\n puts \"ticket_#{index}\".to_s.ljust(30) + ticket['subject'].to_s\n end\n end\n end",
"def table \n table = data.map do |slot|\n slot.position.to_s.ljust(12) + slot.license_plate.ljust(19) + slot.color + \"\\n\" if slot\n end.join('')\n end",
"def crystal_info(crystal)\n puts \"* * * * *About #{crystal.name} * * * * *\"\n puts '- - - - - - - - - - - - - - - - - - - - - - - -'\n puts \"Color(s): #{crystal.colors.join(', ').gsub(' Gemstones', '').downcase}\"\n puts \"\\nMetaphysical Use(s): #{crystal.purposes.join(', ').downcase}\"\n puts \"\\nTo learn more about #{crystal.name.downcase}, visit #{crystal.crystal_url}.\\n\\n\"\n puts ' - - - - - - - - - - - - - - - - - - - - - - -'\n end",
"def print_attribute(*) end",
"def print_price hash\n\thash[:price]\nend",
"def print_items\n @items.each do |item|\n puts item.name + \" (#{item.price} gold)\"\n end\n print \"\\n\"\n end",
"def available_bin_space(current_house)\n rows = [] \n # loop through the houses array, displaying available space in both kinds of bins\n self.houses.each do |house|\n if house.contact_name != current_house.contact_name\n rows << [house.house_number, house.street.name, house.contact_name, house.general_bin_space, house.recycle_bin_space, house.green_bin_space] \n end\n end \n \n # Drawing and styling the table\n table = Terminal::Table.new :rows => rows\n table = Terminal::Table.new :title => ' Your neighbours available bin space '.light_white.on_light_red, :alignment => :center, \n :headings => ['House number'.light_white, 'Street name'.light_white, 'Contact name'.light_white, 'General'.red, 'Recycle'.light_yellow, 'Green'.green], :rows => rows, :style => {:width => 100, :padding_left => 1, :border_x => \"=\"}\n puts table\n end",
"def print_player_outcomes\n @players.each{ |p|\n puts \"#{p.name}:\"\n p.hands.each_with_index{ |h, i|\n print \"Hand #{i+1}: \"\n eval_hand(p, h)\n }\n puts \"#{p.name} total: $#{p.wallet}\"\n linebreak\n }\n end",
"def show_trains\n @trains.each do |train| \n puts train\n end\n end",
"def view_all_tenants(tenants)\n puts `clear`\n puts \"View All Apartments\"\n puts\n printf(\" %10s %-30s %6s %10s \\n\",\"ID\",\"Name\",\"Age\",\"Apt ID\")\n tenants.each_entry{ |o| printf \" %10s %-30s %8d %10d \\n\",\n o.id,o.name,o.age,\n o.apartment_id }\n puts\n\nend",
"def print_investment\n puts \"\"\n puts \"Your Investment on #{@name} (#{@short_code})\"\n puts \"-------------------------------\"\n \n puts \"Total number of shares: #{total_number_of_shares}\"\n puts \"Value: #{total_value_of_shares.round(2)}\"\n puts \"Return: $#{return_sum.round(2)} / #{increment_status} #{percentage_change.round(2)}% \"\n puts \"\"\n\n puts \"Your Transactions\"\n puts \"-------------------------------\"\n\n @transactions.each do |t|\n t.print_transaction\n puts \"\"\n end\n\n puts \"\"\n end",
"def to_s()\r\n\t\tres = \"Printing Statistic -#{self.object_id}-\\n\\t\"\r\n\t\tres += \" - Time : #{@time}\\n\\t\"\r\n\t\tres += \" - Penalty : #{@penalty}\\n\\t\"\r\n\t\tres += \" - isFinished : #{@isFinished}\\n\\t\"\r\n\t\tres += \" - Used help : #{@usedHelp}\\n\\t\"\r\n\t\tres += \" - Nb Stars : #{@numberOfStars}\\n\\t\"\r\n\t\tres += \" - NbClick : #{@nbClick}\\n\\t\"\r\n\t\treturn res\r\n\tend",
"def info\n return \"#{self.name} $#{self.price}\"\n end",
"def print_price hash \n\thash[:price]\nend",
"def print_trail_info\n puts \"Rating: #{self.rating}\"\n puts \"Distance: #{self.distance} mi\"\n puts \"Surface Type(s): #{self.surface}\"\n puts \"Brief Description: #{self.info}\\n\"\n puts \"--------------------------------------------------------------------------------\\n\"\n end",
"def processa_eth\n puts(format(\"%<n>4i TRANSACOES\\tETH\\t\\tINSERIDAS etht\", n: apies.novtx.empty? ? 0 : dml(etht_ins)))\n puts(format(\"%<n>4i TOKENS\\tETH\\t\\tINSERIDAS ethk\", n: apies.novkx.empty? ? 0 : dml(ethk_ins)))\n end",
"def index\n @coins = Coin.all\n end",
"def print_register\n\t\tputs \"#{name}'s Bank Account\"\n\t\tputs \"-\" * 40\n\n\t\t#prints the description and amount of each transaction in the transaction hash.\n\t\t#applies left formatting and right formatting (ljust(x)/rjust(x))\n\t\tputs \"Description\".ljust(30) + \"Amount\".rjust(10)\n\t\t@transactions.each do |transaction|\n\t\t\tputs transaction[:description].ljust(30) + sprintf(\"%0.2f\", transaction[:amount]).rjust(10)\n\t\tend\n\n\t\t#prints ending balance after all transactions calculated\n\t\tputs \"-\" * 40\n\t\tputs \"Balance:\".ljust(30) + sprintf(\"%0.2f\", balance).rjust(10)\n\t\tputs \"-\" * 40\n\tend",
"def list_table\n rows = @mylist.map do |hash|\n if hash['type'] == 'track' || hash['type'] == 'album'\n [\"#{hash['name']} by #{hash['artist']}\", hash['type'].capitalize]\n else\n [hash['name'], hash['type'].capitalize]\n end\n end\n table = Terminal::Table.new headings: %w[Item Type], rows: rows\n puts table\n end",
"def display\n total_tax, total = 0.0, 0.0\n @item_hash.each do |key|\n item_tax, item_price = @tax_hash[key[0].to_s].to_f, @item_hash[key[0].to_s].to_f\n puts \"#{key[0].to_s}: %.2f\" % (item_tax + item_price).round(2)\n total_tax += item_tax\n total += (item_price + item_tax).round(2)\n end\n\n puts \"Sales Tax: %.2f\" % total_tax.round(2)\n puts \"Total: %.2f\" % total.round(2)\n end",
"def print_secondary_attributes\n \"Sanity:#{san}, Health:#{health}, Luck:, Know: Magic:, \"\n end",
"def to_string\r\n @id.to_s + ': ' + @billcoins.to_s + ' billcoins '\r\n end",
"def print_list(fund_hash)\n fund_hash[:list].each do |item|\n puts \"Name: #{item[:name]}\"\n puts \"Description: #{item[:description]}\"\n puts \"Target: $#{item[:target]}\"\n puts \"Balance: $#{item[:balance]}\"\n puts \"Percentage: #{item[:percentage]}%\"\n puts \"Importance: #{item[:importance]}\"\n puts \"-------------------------\"\n end\n end",
"def to_s\n\t\t puts \"Bank Account:\\t#{name}\\n\"\n\t\t puts \"Your current balance is:\\t#{sprintf(\"%0.2f\", balance)} USD\" \n\tend",
"def pretty_balance\n puts \"You have $#{balance} in the bank\"\n end",
"def printItem\n print @category,\", \"\n print @batteryLife,\", \"\n print @modelNum,\", \"\n print @color,\", \"\n print @manufacturer,\", \"\n print @status,\", \"\n print @yearBuilt,\", \"\n print @price,\", \"\n print @features\n end",
"def print_billing_details\n puts \"--------------Final Bill-------------------------\"\n puts \"User type: #{self.user.class}\"\n puts \"-------------------------------------------------\"\n puts \"Category | Item | Price \"\n puts \"-------------------------------------------------\"\n billing_items.each do |billing_item_category, billing_items_with_price|\n billing_items_with_price.each do |billing_item, price|\n puts \"#{billing_item_category} | #{billing_item} | $ #{price}\"\n end\n end\n puts \"-------------------------------------------------\"\n puts \"Total payable amount: $ #{total_price}\"\n puts \"Total percentage discount: $ #{discount.percentage_discounted_price}\"\n puts \"Total every hundred discount: $ #{discount.every_hundred_discount_price}\"\n puts \"Total Saving: $ #{discount.total_net_discount_price}\"\n puts \"Total net price after discount: $ #{net_payable_price}\"\n end",
"def pretty\n out = ''\n\n self.each do |line|\n out << line.line + ' : ' + line.commit + \"\\n\"\n out << ' ' + line.summary + \"\\n\"\n out << \" author:\\n\"\n out << ' ' + line.author + \"\\n\"\n out << ' ' + line.author_email + \"\\n\"\n out << ' @ ' + line.author_timestamp + \"\\n\"\n out << ' ' + line.author_timezone + \"\\n\"\n out << \"\\n\"\n out << \" committer:\\n\"\n out << ' ' + line.committer + \"\\n\"\n out << ' ' + line.committer_email + \"\\n\"\n out << ' @ ' + line.committer_timestamp + \"\\n\"\n out << ' ' + line.committer_timezone + \"\\n\"\n out << \"\\n\"\n end\n\n out\n end",
"def to_s\n \"Table #{self.id} (Seats: #{self.capacity})\"\n end",
"def print_stats_table()\n res = @db.query(\"SELECT * FROM UserStats;\")\n while row = res.fetch_row do\n printf \"%s %s\\n\", row[0], row[1], row[2], row[3]\n end\n end",
"def available_balances_table\n <<EOF\n\\\\section{Available Balances}\n\\\\begin{tabulary}{0.9\\\\textwidth}{R | r r c}\nAccount & Balance & Available & Type\\\\\\\\\n\\\\hline\\\\Tstrut\n #{\n [:Equity, :Asset, :Liability].map{|type|\n @accounts.find_all{|acc| acc.type == type}.map{|acc|\n [acc.name_c, acc.balance(@today).to_tex, acc.available(@today).to_tex, type.to_s].join(\" & \")\n }.join(\"\\\\\\\\ \\n\")\n }.join(\"\\\\\\\\ \\n\\n\")\n }\n\\\\end{tabulary}\nEOF\n end",
"def display_branch_list\n table = build_table_view\n\n puts \"\\n\\n\"\n puts table\n end",
"def pretty_output #two columns\n alphabetical_keys = @concordance_hash.keys.sort\n half = (alphabetical_keys.length - 1) / 2\n alphabetical_keys[0..half].each_with_index do |key, idx|\n value = \"{\" + @concordance_hash[key][0].to_s + \":\" +\n @concordance_hash[key][1..-1].to_s.delete(\"[] \") + \"}\"\n\n key2 = alphabetical_keys[1 + idx + half]\n value2 = \"{\" + @concordance_hash[key2][0].to_s + \":\" +\n @concordance_hash[key2][1..-1].to_s.delete(\"[] \") + \"} \\n\"\n if 1 + idx + half >= alphabetical_keys.length\n value2 = \"\\n\"\n end\n\n printf \"%-15s %-20s %-15s %s\", key, value, key2, value2\n end\n end",
"def print_header(nlen, clen)\n print_line(nlen, \"Name\", clen, \"Craft\")\n puts \"%-#{nlen}s-|-%-#{clen}s-\" % [\"-\" * nlen, \"-\" * clen]\n end",
"def inspect\n \"#{\"%0.02f\" % @amount} #{@base_currency}\"\n end",
"def display_attributes\n puts\n puts @str.tr(NULL, \"!\")\n bit = 1\n 16.times do |bno|\n line = \"\"\n @str.length.times do |i|\n if (@attrs[i] & bit) == 0\n line << \" \"\n else\n if bno.zero?\n line << \"S\"\n else\n line << (\"%d\" % (bno+1))\n end\n end\n end\n puts(line) unless line =~ /^ *$/\n bit <<= 1\n end\n end",
"def pretty_list(hash)\r\n puts \"Grocery List:\"\r\n puts \" \"\r\n hash.each do |item_name, quantity|\r\n puts \"#{item_name}: #{quantity}\"\r\n end\r\nend",
"def to_s\n\t\t puts \"\\nEnding balance:\\nBank Account Name:\\t#{name}\\nBalance:\\t#{balance}\"\n\tend",
"def show\n coin = Coin.find(params[:id]) \n require 'net/http'\n url = url = \"https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=#{coin.coin_api_id}&order=market_cap_desc&per_page=100&page=1&sparkline=false&price_change_percentage=1h\"\n request = URI.parse(url)\n response = Net::HTTP.get_response(request)\n crypto_hash = JSON.parse(response.body)\n coin.image = crypto_hash[0]['image']\n coin.current_price = crypto_hash[0]['current_price']\n coin.price_change_percentage_1h_in_currency = crypto_hash[0]['price_change_percentage_1h_in_currency']\n coin.high_24h = crypto_hash[0]['high_24h']\n coin.low_24h = crypto_hash[0]['low_24h']\n coin.total_volume = crypto_hash[0]['total_volume']\n coin.market_cap = crypto_hash[0]['market_cap']\n coin.market_cap_rank = crypto_hash[0]['market_cap_rank']\n coin.circulating_supply = crypto_hash[0]['circulating_supply']\n\n # Serializer\n # render json: CoinSerializer.new(coin)\n render json: coin\n end",
"def display_info\n \n puts \"\\nPlayer Name: #{self.name}\"\n puts \"Current Rank: #{self.rank}\"\n puts \"Position: #{self.position}\"\n puts \"School/Club: #{self.schoolclub}\"\n # binding.pry\n #if there is no class_year, nothing is displayed\n puts \"Year: #{self.class_year}\"\n #\n puts \"Height/Weight: #{self.height}, #{self.weight} \"\n puts \"Age: #{self.age}\"\n puts \"Last rank: #{self.last_rank}\"\n puts \"Scouting Report: #{self.blurb}\"\n puts \"------------------------------------\"\n end",
"def print_player_bankrupt(player)\n print_separator\n puts \"Player #{player.id}: Bankrupt\"\n print_separator\n end",
"def print_tree(out = $stdout)\n out.puts \"## Class: #{name}\"\n out.puts \" Visible Name: #{visible_name}\"\n out.puts \" Description : #{description}\"\n tables.each do |table|\n table.print_tree(out)\n end\n end",
"def print_statement\n account_statement = StatementDisplay.new(@transaction)\n account_statement.print_statment_header\n account_statement.display\n end",
"def display\n print(\"Card: #{@id} \")\n print(\"Number: #{@number} \")\n print(\"Color: #{@color} \")\n print(\"Shape: #{@shape} \")\n puts(\"Shade: #{@shade}\")\n end"
] | [
"0.70183617",
"0.68653435",
"0.6565183",
"0.651299",
"0.647336",
"0.6469669",
"0.63120645",
"0.629826",
"0.62857366",
"0.6111504",
"0.6110223",
"0.5978575",
"0.59607655",
"0.59492505",
"0.59262216",
"0.58954006",
"0.58858734",
"0.588126",
"0.5869724",
"0.58365005",
"0.58061355",
"0.58048916",
"0.5791933",
"0.57680684",
"0.57569706",
"0.57499325",
"0.57207966",
"0.5672356",
"0.565649",
"0.5652836",
"0.5649708",
"0.5636034",
"0.56245416",
"0.56041175",
"0.5598068",
"0.55975914",
"0.5591285",
"0.5585437",
"0.55810326",
"0.5575129",
"0.55666274",
"0.5555385",
"0.5548225",
"0.5532198",
"0.551391",
"0.5513249",
"0.5512764",
"0.5512603",
"0.55103385",
"0.55005187",
"0.54944146",
"0.54799366",
"0.5475826",
"0.5468018",
"0.5467477",
"0.5455822",
"0.54508394",
"0.5448742",
"0.5444018",
"0.54427844",
"0.5440192",
"0.54197204",
"0.541894",
"0.5415537",
"0.5414658",
"0.54082316",
"0.54077",
"0.54067206",
"0.5401946",
"0.5400265",
"0.5396711",
"0.53891397",
"0.53879994",
"0.53824043",
"0.5371737",
"0.53713936",
"0.5369553",
"0.53677565",
"0.5365304",
"0.5363642",
"0.53581375",
"0.53532946",
"0.53500926",
"0.5348801",
"0.53480685",
"0.53477424",
"0.5341232",
"0.533984",
"0.53372526",
"0.5333734",
"0.5329619",
"0.5328324",
"0.53275555",
"0.53272265",
"0.53249174",
"0.532446",
"0.5323583",
"0.5313721",
"0.53130424",
"0.53067875"
] | 0.746819 | 0 |
(marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottomright corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths are there? input: m (rows), n(cols) output: number, representing number of unique paths from start to end x x x x x x x x x x x x x x x x x x x x x represent as [ [x,x,x,x,x,x,x], [x,x,x,x,x,x,x], [x,x,x,x,x,x,x] ] start: rows=1, cols=1 end: rows=3, cols=7 invalid: col > 7, row > 3 rows=2, cols=4 x x x x x x x x paths(m, n) if m == 0, return 0 if n == 0, return 0 if m == 1 && n == 1, return 1 if memo[row][col] doesnt yet exist, set it memo[row][col] = paths(m 1, n) + paths(m, n 1) return memo[row][col] create_memo for row in rows initialize [] and add it to outer array | def create_memo(rows)
memo = []
(rows + 1).times { |_| memo << []}
memo
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_paths_iterative(m, n)\n return 0 if m == 0 || n == 0\n\n grid = Array.new(m) { Array.new(n) {0} }\n grid[0][0] = 1\n\n row = 0\n column = 0\n\n while row < m\n while column < n\n # check top\n if row > 0\n grid[row][column] += grid[row - 1][column]\n end\n # check left\n if column > 0\n grid[row][column] += grid[row][column - 1]\n end\n\n column += 1\n end\n column = 0\n row += 1\n end\n\n grid[row - 1][column - 1]\nend",
"def unique_paths(cols, rows)\n cache = {}\n\n (0...rows).each do |row| # iterate from 0 to rows - 1\n (0...cols).each do |col| # iterate from 0 to cols - 1\n coord = [row, col] # for each coord, calculate the unique paths\n next cache[coord] = 1 if (row == 0 || col == 0)\n cache[coord] = cache[[row - 1, col]] + cache[[row, col - 1]]\n end\n end\n\n last_coord = [rows - 1, cols - 1]\n return cache[last_coord]\nend",
"def unique_paths_with_obstacles(obstacle_grid)\n return 0 if obstacle_grid.empty?\n n = obstacle_grid.size\n m = obstacle_grid[0].size\n dp = Array.new(m, 0)\n dp[0] = 1\n (0..n-1).each do |r|\n (0..m-1).each do |c|\n if obstacle_grid[r][c] == 1\n dp[c] = 0\n elsif c > 0\n dp[c] += dp[c - 1]\n end\n end\n end\n dp[m - 1]\nend",
"def unique_paths_with_obstacles(obstacle_grid)\n m, n = obstacle_grid.length, obstacle_grid[0].length\n m.times do |i|\n n.times do |j|\n if obstacle_grid[i][j] == 1\n obstacle_grid[i][j] = 0\n elsif i == 0 && j == 0\n obstacle_grid[i][j] = 1\n elsif i == 0\n obstacle_grid[i][j] = obstacle_grid[i][j-1] * 1\n elsif j == 0\n obstacle_grid[i][j] = obstacle_grid[i-1][j] * 1\n else \n obstacle_grid[i][j] = obstacle_grid[i-1][j] + obstacle_grid[i][j - 1]\n end \n end \n end \n\n obstacle_grid[m-1][n-1]\nend",
"def unique_paths(m, n)\n return 0 if m == 0 && n == 0\n return 1 if m == 0 || n == 0\n\n arr = [0] * n\n matrix = []\n m.times do \n matrix << arr\n end\n\n for i in 0...m do \n for j in 0...n do \n if i == 0 && j == 0\n matrix[i][j] *= 1\n elsif i == 0 && j != 0\n matrix[i][j] = matrix[i][j - 1]\n elsif j == 0\n matrix[i][j] = matrix[i - 1][j]\n else\n matrix[i][j] = matrix[i - 1][j] + matrix[i][j - 1]\n end\n end\n end\n\n matrix[m-1][n-1]\nend",
"def unique_path(rows, columns)\n # build the grid\n grid = Array.new(rows)\n grid.map! { |row| Array.new(columns) }\n \n # populate the first column\n rows.times { |row| grid[row][0] = 1 }\n\n # populate the first row\n columns.times { |col| grid[0][col] = 1 }\n \n # populate the whole grid\n (1...rows).each do |row|\n (1...columns).each do |col|\n grid[row][col] = grid[row - 1][col] + grid[row][col - 1]\n end\n end\n\n # return the value for down-right corner\n grid[rows - 1][columns - 1]\nend",
"def count_paths(grid_size)\n factorial(2*grid_size) / (factorial(grid_size) * factorial(grid_size))\nend",
"def calculate_total_paths(m,n)\n return 1 if m == 1 and n == 1\n paths = []\n for i in (0..m)\n paths << Array.new(0,n)\n end\n\n # initialze borders\n for j in (0...n)\n paths[0][j] = 1\n end\n\n for i in (0...m)\n paths[i][0] = 1\n end\n\n paths[0][0] = 0\n\n for i in (1...m)\n for j in (1...n)\n paths[i][j] = paths[i][j-1] + paths[i-1][j]\n end\n end\n paths[m-1][n-1]\nend",
"def count_paths(grid, x, y, w, h)\n\tcount = 0\n\n\tputs \"Visiting x:#{x}, y:#{y}\"\n\n\t# if already visited, return so we can do down a different path\n\treturn count if grid[x][y]\n\n\t#puts \"Valid move\"\n\t# mark tile as visited\n\tgrid[x][y] = true\n\n\t# how this works is we only count the path once we have hit our end point\n\t# otherwise keep calling the function\n\n\t# We can go in all directions but we are constrained by the grid and we can't go to a visited\n\t# square\n\t# if x = 0, try to go right\n\n\t# Always prefer to go right\n\tcount += count_paths(grid, x+1, y, w, h) if x < w - 1\n\n\t# Go down, if allowed\n\tcount += count_paths(grid, x, y+1, w, h) if y < h - 1\n\n\t# Go left\n\tcount += count_paths(grid, x-1, y, w, h) if x > 0\n\n\t# Go up\n\tcount += count_paths(grid, x, y-1, w, h) if y > 0\n\n\n\n\n\t#count += count_paths(grid, x, y, w, h) if \n\n\t# if we are on the left, we can only go (down,right, up)\n\t# if we are on top we can only go (down right or up)\n\t# if we have reached the bottom, (up, right or left)\n\t#count += count_paths(grid, x, y, w, h) if \n\n\t# We have reached the destination\n\t#puts \"Reached destination\" if (x == w - 1) && (y == h -1)\n\tcount += 1 if (x == w - 1) && (y == h -1)\n\n\tcount\nend",
"def find_paths(grid_size)\n # array/list sums records the sum of paths in a grid of size sums[i+1]\n sums = [1] * 20\n for i in 0...grid_size\n for j in 0...i do\n sums[j] = (sums[j] + sums[j-1])\n end\n sums[i] = 2 * sums[i-1]\n end\n sums[grid_size - 1]\nend",
"def unique_paths(m, n, cache = {})\n return 0 if m < 0 || n < 0\n return 1 if m == 1 || n == 1\n\n result = (cache[[m - 1, n]] || unique_paths(m - 1, n, cache)) + (cache[[m, n - 1]] || unique_paths(m, n -1, cache))\n cache[[m, n]] = result\n result\nend",
"def unique_paths_with_obstacles(obstacle_grid)\n row = obstacle_grid.size\n col = obstacle_grid.first.size\n result = Array.new(col + 1, 0)\n result[0] = 1 if obstacle_grid[0][0] == 0\n for i in 0...row\n for j in 0...col\n result[j] += result[j - 1]\n result[j] = 0 if obstacle_grid[i][j] == 1\n end\n end\n result[col - 1]\nend",
"def unique_paths_recursive(m, n, store = {})\n return store[[m, n]] if store[[m, n]]\n\n if m == 1 && n == 1\n store[[m, n]] = 1\n return 1\n end\n\n above = m > 1 ? unique_paths_recursive(m - 1, n, store) : 0\n left = n > 1 ? unique_paths_recursive(m, n - 1, store) : 0\n\n store[[m - 1, n]] = above\n store[[m, n - 1]] = left\n total = above + left\nend",
"def unique_path(m, n, cache = {})\n return 1 if m == 1 || n == 1\n if cache[[m, n]]\n return cache[[m,n]]\n end\n cache[[m,n]] = unique_path(m-1, n) + unique_path(m, n-1)\nend",
"def build_paths(start)\n step = 0\n visited = []\n unvisited = [[board_node_by_location(start),step]]\n \n while !unvisited.empty?\n node = unvisited[0][0]\n step = unvisited[0][1] + 1\n \n node.neighbors.each do |x|\n if not_visited(board_node_by_location(x),visited, unvisited)\n unvisited << [board_node_by_location(x),step]\n end\n end\n visited << unvisited.shift\n end\n return visited\nend",
"def min_path_sum2(grid)\n m = grid.size - 1 \n n = grid[0].size - 1 \n arr = Array.new(m+1) {Array.new(n+1, 0)}\n # Two dimensional array , initialization has a trap\n # if arr = Array.new(m, Array.new(n, 0)) , change one element , all lines' elements will be changed.\n (n+1).times do |i| \n if i == 0\n arr[0][0] = grid[0][0]\n else\n arr[0][i] = arr[0][i-1] + grid[0][i]\n end \n end \n flag = grid.transpose\n (m+1).times do |i| \n if i == 0\n arr[0][0] = grid[0][0]\n else\n arr[i][0] = arr[i-1][0] + grid[i][0]\n end \n end \n (1..m).each do |i| \n (1..n).each do |j| \n arr[i][j] = [arr[i][j-1], arr[i-1][j]].min + grid[i][j]\n end \n end \n arr.last.last\nend",
"def get_num_paths(grid_width)\n n, r = grid_width * 2, grid_width\n ((n - r + 1)..n).inject(:*) / (1..r).inject(:*)\nend",
"def lattice_paths(n_grid)\n # 1) creat a grid (n+1) x (n+1) with all initialize with 1\n grid = Array.new(n_grid + 1) { Array.new(n_grid + 1, 1) }\n\n # 2) iterate through grid\n for row in (0..n_grid)\n for col in (0..n_grid)\n if row - 1 >= 0 && col - 1 >= 0\n # if row-1, col-1 exists, the sum is the value for gird[row, col]\n grid[row][col] = grid[row][col-1] + grid[row-1][col]\n end\n end\n end\n\n #3) return last element in the array\n return grid[n_grid][n_grid]\nend",
"def lattice_paths(grid_size)\n grid_dimension = grid_size + 1\n grid = Array.new(grid_dimension * grid_dimension) { 1 }\n (grid_size - 1).downto(0) do |x|\n (grid_size - 1).downto(0) do |y|\n pos = (y * grid_dimension) + x\n grid[pos] = grid[pos + 1] + grid[pos + grid_dimension]\n end\n end\n grid[0]\nend",
"def robot_paths(x, y, map={})\n if x == 0 && y == 0\n 0\n elsif (x == 0 && y >= 0) || (x >= 0 && y == 0)\n 1\n elsif map[x] && map[x][y]\n map[x][y]\n else\n result = robot_paths(x - 1, y, map) + robot_paths(x, y - 1, map)\n map[x] ? map[x][y] = result : map[x] = {y => result}\n map[x][y]\n end\nend",
"def unique_paths(h, w)\r\n c = Array.new(h) { Array.new(w, 0) }\r\n c[0][0] = 1\r\n for y in 0..(h-1)\r\n for x in 0..(w-1)\r\n if y > 0 then\r\n c[y][x] += c[y-1][x]\r\n end\r\n if x > 0 then\r\n c[y][x] += c[y][x-1]\r\n end\r\n end\r\n end\r\n return c[h-1][w-1]\r\nend",
"def min_path_sum(grid)\n row = grid.length\n col = grid[0].length\n\n i, j = 0, 0\n\n while i < row && j < col\n if i == 0 && j != 0\n grid[i][j] = grid[i][j] + grid[i][j - 1]\n elsif i != 0 && j == 0\n grid[i][j] = grid[i][j] + grid[i - 1][j]\n elsif i != 0 && j != 0\n grid[i][j] = grid[i][j] + [grid[i][j - 1], grid[i - 1][j]].min\n end\n\n i += 1\n j += 1\n end\n\n grid[-1][-1]\nend",
"def traverse_grid(rows, cols, dead_zones, paths)\n paths ||= Array.new(rows) {Array.new(cols)}\n\n #recursive step\n return traverse_grid(rows-1, cols) || traverse_grid(rows, cols-1)\nend",
"def find_path(start_node, end_node, grid)\n start_node = sanitize(start_node)\n end_node = sanitize(end_node)\n if grid.nil?\n [start_node]\n else\n _max_x = grid.max_x\n _max_y = grid.max_y\n\n @current_grid = grid.inner_grid.clone\n\n raise 'max_x & max_y required' unless _max_x && _max_y\n\n _start_node = start_node.clone\n _end_node = end_node.clone\n\n heuristic = @heuristic.new(_end_node, @weight)\n\n _start_node[:f] = 0 # sum of g and h\n _start_node[:g] = 0 # steps to start node\n _start_node[:h] = nil # steps to end node\n _start_node[:opened] = true\n\n # use heap or tree for better perf\n open = []\n open.push _start_node\n\n while !open.empty? do\n _current_node = open.pop\n\n _current_node[:closed] = true\n @current_grid[node_to_a(_current_node)] = _current_node\n\n if node_to_a(_current_node) == node_to_a(_end_node)\n return final_path(_current_node)\n end\n\n new_g = _current_node[:g] + 1\n\n x = _current_node[:x]\n y = _current_node[:y]\n\n neighbors = []\n\n neighbors << [x-1, y] if x > 0\n neighbors << [x, y-1] if y > 0\n neighbors << [x+1, y] if x < _max_x-1\n neighbors << [x, y+1] if y < _max_y-1\n\n _neighbors = neighbors.map do |position|\n node = @current_grid[position]\n if node.nil? || node[:walkable]\n node ||= {}\n @current_grid[position] = node.merge({\n x: position.first,\n y: position[1],\n closed: false,\n opened: false\n })\n end\n end.compact\n\n _neighbors.each do |neighbor|\n if (!neighbor[:opened] || new_g < neighbor[:g])\n neighbor[:g] = new_g\n neighbor[:h] ||= heuristic.h(neighbor)\n neighbor[:f] = neighbor[:g] + neighbor[:h]\n neighbor[:parent] = node_to_a(_current_node)\n\n if (!neighbor[:opened])\n open.push neighbor\n neighbor[:opened] = true\n else\n # ???\n puts \"got here some how!!!\"\n end\n end\n end\n\n open.sort_by! {|i| [-i[:f], -i[:h]]}\n # grid_p\n end\n end\n end",
"def count_ways_up_stairs(steps)\n return 0 if steps < 0\n return steps if steps <= 2\n\n paths = []\n paths[0] = 1\n paths[1] = 1\n paths[2] = 2\n\n (3...steps).each do |i|\n count = paths[0] + paths[1] + paths[2]\n paths[0] = paths[1]\n paths[1] = paths[2]\n paths[2] = count\n end\n\n paths[2]\nend",
"def lattice_paths(grid_size)\n # Initialization\n intersections = Array.new(grid_size + 1)\n intersections.map! { |r| Array.new(grid_size + 1) }\n\n # Base case - at the bottom and right edges, there is only one route remaining.\n # Technically the bottom-right point has no routes remaining, but it doesn't matter here.\n (0..grid_size).each do |i|\n intersections[i][grid_size] = 1\n intersections[grid_size][i] = 1\n end\n\n calculate_routes(0, 0, intersections)\n\n intersections[0][0]\nend",
"def paths(n)\n return nCr(2*(n-1),n)\nend",
"def steps(maze)\n width = maze[0].length\n height = maze.length\n\n dup = Array.new(height) { Array.new(width) {0} }\n\n i = 0\n # across the top\n while i < width\n if maze[0][i] == 1\n dup[0][i] = 1\n else\n break\n end\n i += 1\n end\n\n j = 0\n # across the left side\n while j < height\n if maze[j][0] == 1\n dup[j][0] = 1\n else\n break\n end\n j += 1\n end\n\n i = 1\n j = 1\n # center\n while j < height\n while i < width\n if maze[j][i] == 1\n counter = 0\n # above\n if maze[j - 1][i] == 1\n counter += dup[j - 1][i]\n end\n # left\n if maze[j][i - 1] == 1\n counter += dup[j][i - 1]\n end\n dup[j][i] = counter\n end\n i += 1\n end\n i = 1\n j += 1\n end\n\n dup[height - 1][width - 1]\nend",
"def maze_maker number_of_nodes\n return_maze = Hash.new{ |h, k| h[k] = [] }\n\n nodes = gen_first_path number_of_nodes\n\n nodes.each do |k, v|\n return_maze[k] = add_nodes_to_node(return_maze, k, 4, nodes)\n end\n\n end_marker return_maze\n\n return_maze\nend",
"def solve_maze\n matrix = @maze[:matrix] # get matrix from maze hash\n exit_found = false # exit not found yet\n room = Room.new(@maze[:start_x], @maze[:start_y], nil) # create new room from start position\n queue = Queue.new # queue to store the current working nodes' children\n queue << room # add the new room to queue\n\n # if path not found and queue not empty\n while !queue.empty? && !exit_found\n room = queue.pop # get the next room to search for a path\n x = room.x\n y = room.y\n if (x == @maze[:stop_x] && y == @maze[:stop_y]) # if found\n exit_found = true\n else # if not found\n matrix[y][x] = '*' # Mark node as visited sto we do not check it again (bfs algorithm)\n\n # push to queue the children of node room. We are pushing the up, down, left or right room if they are not a wall and we\n # we haven't visited them yet\n queue << Room.new(x+1,y,room) if open_room(x+1,y,matrix) and !visited(x+1, y, matrix)\n queue << Room.new(x-1,y,room) if open_room(x-1,y,matrix) and !visited(x-1,y,matrix)\n queue << Room.new(x,y+1,room) if open_room(x,y+1,matrix) and !visited(x, y+1, matrix)\n queue << Room.new(x,y-1,room) if open_room(x,y-1,matrix) and !visited(x, y-1, matrix)\n end\n end\n\n # if goal found store the last room to @maze[:path]. The last room has a reference(:parent) to the previous room. So we can trace the path\n if exit_found\n @status.found = true\n @maze[:path] = room\n else\n @status.found = false\n end\n\n # yields x, y coordinates of path starting from goal to start\n def yield_path\n room = @maze[:path]\n while room.parent\n yield room.x, room.y\n room = room.parent\n end\n end\n\n # get an array of path\n def path_array\n path = []\n yield_path do |x, y|\n path << [x,y]\n end\n path.reverse\n end\n end",
"def robot_paths_with_obstacles(x, y, obstacles=[], map={})\n obstacles.each do |obstacle|\n blocked_x = obstacle.first\n blocked_y = obstacle.last\n if map[blocked_x]\n map[blocked_x][blocked_y] = 0\n else\n map[blocked_x] = {blocked_y => 0}\n end\n end\n\n if (x == 0 && y == 0) || x < 0 || y < 0\n 0\n elsif map[x] && map[x][y]\n map[x][y]\n elsif (x == 0 && y == 1) || (x == 1 && y == 0)\n 1\n else\n result = robot_paths_with_obstacles(x - 1, y, [], map) +\n robot_paths_with_obstacles(x, y - 1, [], map)\n map[x] ? map[x][y] = result : map[x] = {y => result}\n map[x][y]\n end\nend",
"def traverse_maze(maze)\n def get_path(maze, row, col, current_path)\n return false if row.negative? || row >= maze.length || col.negative? || col >= maze[0].length # out of bounds\n return false if maze[row][col] == 1 # impassable\n\n current_path << Point.new(row, col)\n at_end = row == maze.length - 1 && col == maze[0].length - 1\n if at_end || get_path(maze, row, col += 1, current_path) || get_path(maze, row += 1, col, current_path)\n @viable_path = current_path\n return true\n end\n false\n end\n @viable_path = nil\n return nil if maze.nil? || maze.empty?\n\n get_path(maze, 0, 0, [])\n return false if @viable_path.nil?\n\n @viable_path.map { |p| [p.row, p.col].join(',') }.join(' -> ')\nend",
"def occupy_grid(from_x, from_y, the_direction, the_distance, wire_index, the_base_steps, in_grid_hash)\n if the_direction.upcase == \"U\"\n the_step_x, the_step_y = 0, 1\n elsif the_direction.upcase == \"D\"\n the_step_x, the_step_y = 0, -1\n elsif the_direction.upcase == \"L\"\n the_step_x, the_step_y = -1, 0\n elsif the_direction.upcase == \"R\"\n the_step_x, the_step_y = 1, 0\n end\n the_walk_x, the_walk_y = from_x, from_y\n\n 0.upto(the_distance - 1) do |the_step_num|\n the_key = \"#{the_walk_x}_#{the_walk_y}\"\n in_grid_hash[the_key] ||= [-1,-1]\n\n in_grid_hash[the_key][wire_index] = the_base_steps + the_step_num if in_grid_hash[the_key][wire_index] < 1\n\n the_walk_y += the_step_y\n the_walk_x += the_step_x\n end\n return the_walk_x, the_walk_y\nend",
"def find_path(x, y, path = [])\n if x.zero? && y.zero?\n @results << path\n return 1\n elsif x < 0 || y < 0\n return 0\n elsif @grid[x][y] == 1\n return 0\n end\n\n new_path = path.dup\n new_path.insert(0, [y, x])\n\n @cache[[x - 1 , y]] ||= find_path(x - 1, y, new_path)\n @cache[[x, y - 1]] ||= find_path(x, y - 1, new_path)\n end",
"def num_routes(x,y)\n unless @num_routes[x][y]\n if (x == size - 1) # right side\n @num_routes[x][y] = num_routes(x,y+1)\n elsif (y == size - 1) # bottom side\n @num_routes[x][y] = num_routes(x+1,y)\n else\n @num_routes[x][y] = num_routes(x+1,y) + num_routes(x,y+1)\n end\n end\n @num_routes[x][y]\n end",
"def do_part2(lines)\n map, _, end_loc = map_from(lines)\n remove_inaccessible_cells(map, end_loc)\n paths = []\n map.height.times do |row|\n map.width.times do |col|\n paths << a_star(map, [row, col], end_loc) if map.at(row, col) == 0\n end\n end\n\n paths.compact.map(&:length).min\n end",
"def number_of_paths(n)\n return 0 if n < 0\n return 1 if n == 1 || n == 0\n number_of_paths(n - 1) + number_of_paths(n - 2) + number_of_paths(n - 3)\nend",
"def maze_escape(maze, start, path_cache = Hash.new { |hash, key| hash[key] = {} })\n row, col = start[0], start[1]\n\n return path_cache[row][col] if path_cache[row][col]\n\n if at_edge?(maze, row, col)\n path_cache[row][col] = 1\n return path_cache[row][col]\n end\n\n test_moves = get_test_moves(maze, row, col)\n best_count = nil\n\n test_moves.each do |test_move|\n test_maze = place_test_move(maze, test_move)\n new_count = maze_escape(test_maze, test_move, path_cache)\n\n if new_count && (best_count.nil? || new_count < best_count)\n best_count = 1 + new_count\n end\n end\n\n path_cache[row][col] = best_count\n path_cache[row][col]\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 enum_moves\n @scratch = dup_maze(@maze)\n @locs.each_with_index do |loc, robot|\n @cost = 1\n leading_edge = [loc]\n loop do\n next_edge = []\n leading_edge.each do |x, y|\n next_edge.concat search_from(x, y, robot)\n end\n break if next_edge.empty?\n leading_edge = next_edge\n @cost += 1\n end\n end\n\n @moves\n end",
"def update_memo(memo, x, y, n, grid)\n add_right = grid[x + n - 1].slice(y, n).reduce(:+)\n add_bottom = (0...n).reduce(0) do |sum, x_offset|\n sum + grid[x + x_offset][y + n - 1]\n end\n memo[x][y] += add_right + add_bottom\nend",
"def path_finder(start_node=START_NODE, goal_node=GOAL_NODE)\n\t\n\t# INITIALIZE\n\tvalid = valid_nodes # largest set\n\treachable = [start_node] # nodes we can reach from current node\n\texplored = [] # nodes we've already considered\n\t# nodes reachable, valid, and not explored\n\topen_nodes = valid.select{|node| reachable.include?(node)}.select{|node| !explored.include?(node)} \n\t# record node path {node => previous_node}\n\tnodes_path = {start_node => nil} \n\t\n\twhile !open_nodes.empty?\n # node = choose_node(reachable)\n\t\tnode = open_nodes.sample # random node in open_nodes\n\t\t\n\t\treturn build_path(goal_node, nodes_path) if node==goal_node # STOP if reached goal! \n \n # Don't repeat ourselves.\n reachable.delete(node) # remove current node from reachable\n explored.push(node) # add node to explored\n \n # What nodes are now open from this node?\n # Adjacent, not in explored, and valid (not an obstacle and in maze)\n new_reachable = (get_adjacent_nodes(node) - explored) & valid\n\t\t# ADD new nodes to reachable\n new_reachable.each do |adj_node|\n if !reachable.include?(adj_node)\n # adjacent.previous = node # Remember how we got there.\n nodes_path[adj_node] = node # {[0,3] => [0,2]}\n reachable << adj_node\n end\n end\n \n\t\t# REFRESH OPEN NODES\n open_nodes = valid.select{|node| reachable.include?(node)}.select{|node| !explored.include?(node)} \n \n end\n \n\treturn nil # open_nodes empty - no path found\nend",
"def paths_list(file)\n maze = Maze.new\n maze.create_maze(file)\n pathways = Hash.new\n my_paths = maze.path_arr()\n my_course = maze.get_course\n if my_paths.size == 0\n puts \"None\" \n end\n (0...my_paths.size).each {|i|\n sum = 0\n temp = my_paths[i]\n location_x = temp.get_x\n location_y = temp.get_y\n my_directions = temp.get_directions\n (0...my_directions.size).each{ |counter|\n move = my_directions[counter]\n current = my_course[location_x][location_y]\n the_weight = current.get_directions\n sum+= the_weight[move]\n if move =~ /[u]/\n location_y-= 1\n end\n if move =~ /[d]/\n location_y+= 1\n end\n if move =~ /[l]/\n location_x-= 1\n end\n if move =~ /[r]/\n location_x+= 1\n end\n }\n pathways[temp.get_name] = sum\n }\n sorted_list = pathways.sort {|a,b| a[1]<=>b[1]}\n (0...sorted_list.size).each{ |i|\n if i == sorted_list.size-1\n print sorted_list[i][0]\n else\n print sorted_list[i][0]+\", \"\n end\n }\nend",
"def test_fill_grid\n final_count_array = [1, 3, 5, 7]\n t = TreeShape.new(4)\n t.fill_grid()\n tmp_array = []\n t.grid.each_index do |xi|\n count = 0\n t.grid[xi].each_index do |yi|\n count += 1 if t.grid[xi][yi] == '*'\n end\n tmp_array << count\n end\n assert_equal(final_count_array, tmp_array)\n end",
"def game_of_life2(rows,columns,grid,generations)\n puts \"#{grid}\"\n temp2 = Marshal.dump(grid)\n temp = Marshal.load(temp2)\n future = Marshal.load(temp2)\n for x in 1..generations\n puts \"Generation #{x}\"\n\n #Loop through each cell\n for i in 0..temp.length-1\n for j in 0..temp[i].length-1\n alive_neighbours = 0\n\n #Finding number of neighbours for current cell\n for a in -1..1\n for b in -1..1\n\n #Variables for counting Neighbors\n x = 0\n y = 0\n\n #Current number of rows and columns\n nx = temp.length-1\n ny = temp[i].length-1\n\n #Corner Cases including cyclic neighbors\n\n #Top Left Corner\n if i==0 and j==0\n if i+a<0 and j+b<0\n x=nx\n y=ny\n elsif i+a<0\n x = nx\n y = j+b\n elsif j+b<0\n x = i+a\n y = ny\n else\n x = i+a\n y = j+b\n end\n\n #Top Right Corner\n elsif i==0 and j==ny\n if i+a<0 and j+b>ny\n x = nx\n y = 0\n elsif i+a<0\n x = nx\n y = j+b\n elsif j+b>ny\n x = i+a\n y = 0\n else\n x = i+a\n y = j+b\n end\n\n #Bottom Right Corner\n elsif i==nx and j==ny\n if i+a>nx and j+b>ny\n x = 0\n y = 0\n elsif i+a>nx\n x = 0\n y = j+b\n elsif j+b>ny\n x = i+a\n y = 0\n else\n x = i+a\n y = j+b\n end\n\n #Bottom Left Corner\n elsif i==nx and j==0\n if i+a>nx and j+b<0\n x = 0\n y = ny\n elsif i+a>nx\n x = 0\n y = j+b\n elsif j+b<0\n x = i+a\n y = ny\n else\n x = i+a\n y = j+b\n end\n\n #Edge Cases\n\n #Top Edge\n elsif i==0 and i+a<0\n x = nx\n y = j+b\n\n #Bottom Edge\n elsif i==nx and i+a>nx\n x = 0\n y = j+b\n\n #Left Edge\n elsif j==0 and j+b<0\n x = i+a\n y = ny\n\n #Right Edge\n elsif j==ny and j+b>ny\n x = i+a\n y = j\n\n #Internal life\n else\n x = i+a\n y = j+b\n end\n alive_neighbours = alive_neighbours + temp[x][y]\n end\n end\n\n #Current cell to be subtracted to avoid duplicates\n alive_neighbours = alive_neighbours- temp[i][j]\n\n #Implenting rules of GOF\n\n #Lonely Cell dies\n if temp[i][j]==1 and alive_neighbours<=2\n future[i][j] = 0\n\n #Cell dies due to overcrowding\n elsif temp[i][j]==0 and alive_neighbours>3\n future[i][j] = 0\n\n #A new cell is born if there are 3 neighbors\n elsif temp[i][j]==0\n future[i][j] = 1\n end\n end\n end\n\n #Display the new generation\n for a in 0..future.length-1\n for b in 0..future[a].length-1\n if future[a][b]==1\n print \"@ \"\n else\n print \". \"\n end\n end\n puts \"\"\n end\n\ttemp3 = Marshal.dump(future)\n\ttemp = Marshal.load(temp3)\n end\n return future\nend",
"def find_path(positions, start, finish)\n # Will hold MoveTiles that form a path from start to finish\n path = [finish]\n # Get finish tile first so that we can work backwards in making the path\n chosen = finish\n movetile = chosen\n # Endless loop ZOMG\n while true\n t_x, t_y = movetile.x, movetile.y\n # Generate list of tiles surrounding this tile\n surrounding = []\n surrounding.push(positions[t_x][t_y+1]) if valid?(t_x, t_y+1)\n surrounding.push(positions[t_x][t_y-1]) if valid?(t_x, t_y-1)\n surrounding.push(positions[t_x+1][t_y]) if valid?(t_x+1, t_y)\n surrounding.push(positions[t_x-1][t_y]) if valid?(t_x-1, t_y)\n \n surrounding.compact!\n surrounding.delete(0)\n consider = []\n lowest_cost = 99\n # Evaluate surrounding tiles to find lowest cost\n surrounding.each{|tile|\n # If tile has a total move cost that is at least equal to the current best\n if tile.total_cost <= lowest_cost\n # If even lower, remove previous considerations and set new best\n if tile.total_cost < lowest_cost\n consider.clear\n lowest_cost = tile.total_cost\n end\n # Add this tile to be considered\n consider.push(tile)\n end\n }\n # Choose a tile from list\n chosen = consider[rand(consider.size)]\n # Return path if that last tile was the final one\n return path.reverse! if [chosen.x, chosen.y] == [start.x, start.y]\n # Add chosen tile to path\n path.push(chosen)\n # Evaluate this tile next\n movetile = chosen\n end\n end",
"def find_path(positions, start, finish)\n # Will hold MoveTiles that form a path from start to finish\n path = [finish]\n # Get finish tile first so that we can work backwards in making the path\n chosen = finish\n movetile = chosen\n # Endless loop ZOMG\n while true\n t_x, t_y = movetile.x, movetile.y\n # Generate list of tiles surrounding this tile\n surrounding = []\n surrounding.push(positions[t_x][t_y+1]) if valid?(t_x, t_y+1)\n surrounding.push(positions[t_x][t_y-1]) if valid?(t_x, t_y-1)\n surrounding.push(positions[t_x+1][t_y]) if valid?(t_x+1, t_y)\n surrounding.push(positions[t_x-1][t_y]) if valid?(t_x-1, t_y)\n \n surrounding.compact!\n surrounding.delete(0)\n consider = []\n lowest_cost = 99\n # Evaluate surrounding tiles to find lowest cost\n surrounding.each{|tile|\n # If tile has a total move cost that is at least equal to the current best\n if tile.total_cost <= lowest_cost\n # If even lower, remove previous considerations and set new best\n if tile.total_cost < lowest_cost\n consider.clear\n lowest_cost = tile.total_cost\n end\n # Add this tile to be considered\n consider.push(tile)\n end\n }\n # Choose a tile from list\n chosen = consider[rand(consider.size)]\n # Return path if that last tile was the final one\n return path.reverse! if [chosen.x, chosen.y] == [start.x, start.y]\n # Add chosen tile to path\n path.push(chosen)\n # Evaluate this tile next\n movetile = chosen\n end\n end",
"def path_count(steps, current=0)\n if current == steps\n 1\n elsif current > steps\n 0\n else\n path_count(steps, current + 1) +\n path_count(steps, current + 2) +\n path_count(steps, current + 3)\n end\nend",
"def test_find_path_to_goal_1\n w = 6\n h = 6\n walls = [Position.new(1, 3), Position.new(2, 3), Position.new(3, 3), Position.new(3, 2),\n Position.new(3, 5), Position.new(4, 5), Position.new(5, 5), Position.new(5, 3),\n Position.new(6, 5), Position.new(6, 3)]\n start = Position.new(1, 1)\n goal = Position.new(5, 6)\n maze = Maze.new(w, h, walls, start, goal)\n path_to_goal = maze.find_path_to_goal\n outcome = [Position.new(1, 1), Position.new(1, 2), Position.new(2, 2), Position.new(2, 1),\n Position.new(3, 1), Position.new(4, 1), Position.new(4, 2), Position.new(4, 3),\n Position.new(4, 4), Position.new(3, 4),\n Position.new(2, 4), Position.new(2, 5), Position.new(2, 6), Position.new(3, 6),\n Position.new(4, 6), Position.new(5, 6)]\n assert_equal outcome.size, path_to_goal.size\n\n assert_equal outcome, path_to_goal\n end",
"def pathfind begTile, endTile\n @traveled_tiles = [begTile]\n @current_tiles = [begTile]\n @next_tiles = Array.new\n #iterate through the maze one movement at a time, hard stop when all tiles have been exhausted\n while (!@current_tiles.include? endTile) && @traveled_tiles.length < @maze.size\n @current_tiles.each do |tile|\n (get_adjacent_floors tile).each do |next_tile|\n #makes sure no tiles are double counted, the first to hit will always be the shortest\n if (next_tile.is_floor) && (!@next_tiles.include? next_tile) && (!@traveled_tiles.include? next_tile)\n @next_tiles.push next_tile\n next_tile.previous_tile tile\n end\n end\n end\n @traveled_tiles.concat @next_tiles\n @current_tiles = @next_tiles.dup\n @next_tiles.clear\n end\n endTile.get_path\n end",
"def redesign\n @waiting = []\n @maze_table = Array.new(2*@m+1){Array.new(2*@n+1, \"1\")}\n for i in 0..2*@m\n for j in 0..2*@n\n @maze_table[i][j] = \"w\" if i%2==1 && j%2==1\n end\n end\n sx = 2*rand(@m)+1\n sy = 2*rand(@n)+1\n @maze_table[sx][sy] = \"0\"#set cell\n add_neighbor(sx, sy)\n until @waiting.empty?\n wall, cell, dir = @waiting.delete_at(rand(@waiting.length))\n pre = [cell[0]-2, cell[1]] if dir == \"down\"\n pre = [cell[0]+2, cell[1]] if dir == \"up\"\n pre = [cell[0], cell[1]-2] if dir == \"right\"\n pre = [cell[0], cell[1]+2] if dir == \"left\"\n if @maze_table[cell[0]][cell[1]] == \"w\" && count_walls(pre[0],pre[1]) > 1\n @maze_table[cell[0]][cell[1]] = \"0\"\n @maze_table[wall[0]][wall[1]] = \"0\"\n add_neighbor(cell[0], cell[1]) \n end\n end\n end",
"def num_islands(grid)\n return 0 if grid.empty?\n\n count = 0\n\n grid.each_with_index do |row, i|\n row.each_with_index do |_col, j|\n if grid[i][j] == '1'\n dfs(i, j, grid)\n count += 1\n end\n end\n end\n count\nend",
"def build_graph\n @matrix.each_with_index do |row, x|\n row.each_with_index do |move, y|\n move = Coordinate.new(x,y)\n @matrix[x][y] = possible_moves(move)\n end\n end\n\tend",
"def num_paths\n @num_paths ||= begin\n self[width - 1, height - 1]\n end\n end",
"def pathfinder(maze, counter=0, unexplored_territory=true, starting_cell=[])\n\n # This while loop goes over the maze once, looking for a 'F' in a cell (maze[row][col]), and adding 0 to ENWS if possible\n while counter==0\n maze.each_with_index do |array, row|\n array.each_with_index do |cell, col|\n if cell == 'F' # Looking for the first starter cell\n [[0,1],[-1,0],[0,-1],[1,0]].each do |mod|# east, north, west, south checked one at a time\n maze[row+mod[0]][col+mod[1]] = counter if maze[row+mod[0]][col+mod[1]] == ' '\n end\n end\n end\n end\n counter+=1\n end\n\n print_maze(maze).inspect if $debug\n no_solution = false\n\n\n # This while loop goes through and looks for either blank spaces adjacent to numbers, or 'S' in a cell.\n while unexplored_territory\n dig_dug = true\n maze.each_with_index do |array, row|\n array.each_with_index do |cell, col|\n if cell == (counter-1) # mapping out the maze, one by one\n [[0,1],[-1,0],[0,-1],[1,0]].each do |mod|# east, north, west, south checked one at a time\n if maze[row+mod[0]][col+mod[1]] == 'S'\n unexplored_territory, starting_cell, dig_dug = false, [row, col], false\n elsif maze[row+mod[0]][col+mod[1]] == ' '\n maze[row+mod[0]][col+mod[1]], dig_dug = counter, false\n end\n end\n end\n end\n end\n unexplored_territory, no_solution = false, true if dig_dug # check for progress, no solutions found if true\n counter+=1\n if $debug\n system('clear') or system('cls')\n print_maze(maze)\n sleep(1.0/4.0) if $slow\n end\n end\n\n counter = counter - 3 # Getting the counter ready for reverse mapping\n return [['No Solution']] if no_solution # 5.\tIF there is no solution, then print an appropriate message and re-display the menu\n unless no_solution\n\n\n # This while loop goes and looks for the route back following descending numbers.\n while counter >= 0\n maze[starting_cell[0]][starting_cell[1]] = '*'\n [[0,1],[-1,0],[0,-1],[1,0]].each do |mod|# east, north, west, south checked one at a time\n if maze[starting_cell[0]+mod[0]][starting_cell[1]+mod[1]].is_a?(Integer) && maze[starting_cell[0]+mod[0]][starting_cell[1]+mod[1]] == counter\n starting_cell = [starting_cell[0]+mod[0],starting_cell[1]+mod[1]]\n end\n end\n counter -= 1\n end\n\n maze[starting_cell[0]][starting_cell[1]] = '*' # Sets the last cell to *\n\n\n # This set of loops goes through and clears out integers from the maze\n maze.each_with_index do |row, r|\n row.each_with_index do |col, c|\n if col.is_a?(Integer)\n maze[r][c] = ' '\n end\n end\n end\n\n # Return the finished product\n maze\n end\nend",
"def measure map, x, y \n if map[x][y] != 'land' || x >= 6 || y >= 6 #Ensures water, counted land, and coordinates\n return 0 #off the grid aren't counted.\n end\n \n size = 1\n map[x][y] = 'counted land' #Marks the starting tile as something bedsides Land. Every tile surrounding the starting tile becomes the \"new starting tile\" as the the recursion happens.\n \n size = size + measure(map, x-1, y-1) #Each of these lines is run again and again until\n size = size + measure(map, x, y-1) #a non-land square is encountered. \n size = size + measure(map, x+1, y-1) #That's the recursive part.\n size = size + measure(map, x-1, y)\n size = size + measure(map, x+1, y)\n size = size + measure(map, x-1, y+1)\n size = size + measure(map, x, y+1)\n size = size + measure(map, x+1, y+1)\n \n size\nend",
"def sudoku2(grid)\n \n i = 0\n \n while i < grid.length\n hash = Hash.new(0)\n j = 0\n\n while j < grid[0].length\n hash[grid[i][j]] += 1\n return false if hash[grid[i][j]] > 1 && grid[i][j] != '.'\n j += 1\n end\n i += 1\n end\n\n i = 0\n\n while i < grid[0].length\n hash = Hash.new(0)\n j = 0\n\n while j < grid.length\n hash[grid[j][i]] += 1\n return false if hash[grid[j][i]] > 1 && grid[j][i] != '.'\n j += 1\n end\n i += 1\n end\n\n true && grid_builder(grid)\nend",
"def connect_cells\n @grid.each_with_index do |columns, col_i|\n columns.each_with_index do |cell, cell_i|\n cell.left = @grid[col_i-1][cell_i] if col_i != 0 \n cell.up = @grid[col_i][cell_i+1] if cell_i + 1 < columns.length\n cell.right = @grid[col_i+1][cell_i] if col_i + 1 < @grid.length\n cell.down = @grid[col_i][cell_i-1] if cell_i != 0\n cell.lu = @grid[col_i-1][cell_i+1] if col_i != 0 && cell_i + 1 < columns.length\n cell.ld = @grid[col_i-1][cell_i-1] if col_i != 0 && cell_i != 0\n cell.ru = @grid[col_i+1][cell_i+1] if col_i + 1 < @grid.length && cell_i + 1 < columns.length\n cell.rd = @grid[col_i+1][cell_i-1] if col_i + 1 < @grid.length && cell_i != 0\n end\n end\n end",
"def generate\n cells.destroy_all\n \n x = 0\n while x < width do\n y = 0\n while y < height do\n cells.create(:x => x, :y => y)\n y += 1\n end\n x += 1\n end\n \n # A wall is like this: [cell1,cell2]\n walls = []\n \n cells.each do |cell|\n walls += ([cell]*4).zip(cell.neighbours)\n end\n \n walls.shuffle!\n \n walls.each do |cell, neighbour|\n cell.create_edge_to_and_from(neighbour) unless neighbour.nil? || cell.reachable?(neighbour)\n end\n \n @solution ||= cells.first.shortest_path_to(cells.last)\n end",
"def sim(m, w, h)\n\to = m.map{|x|x.clone}\n\t(1..w-2).each do |x|\n\t\t(1..h-2).each do |y|\n\t\t\tnext if m[y][x] == ?.\n\t\t\toccupied=[-1,0,1].product([-1,0,1]).count{|dx,dy|\n\t\t\t\tif dx != 0 || dy != 0 then\n\t\t\t\t\tpx=x+dx\n\t\t\t\t\tpy=y+dy\n\t\t\t\t\tpx,py=px+dx,py+dy until 'L#'[m[py][px]]\n\t\t\t\t\tm[py][px] == ?#\n\t\t\t\telse\n\t\t\t\t\tfalse\n\t\t\t\tend\n\t\t\t}\n\t\t\to[y][x] = ?# if m[y][x] == ?L && occupied == 0\n\t\t\to[y][x] = ?L if m[y][x] == ?# && occupied >= 5\n\t\tend\n\tend\n\treturn o\nend",
"def number_of_paths_to_end_from_point(start_point)\n \n tabs = \"\\t\" * ([start_point.x, start_point.y].max)\n puts \"#{tabs} (#{start_point.x}, #{start_point.y})\"\n \n # only 1 path to end from the edges\n return 1 if (start_point.y == 2 || start_point.x == 2)\n \n # last point\n return 0 if (start_point.x == 2 && start_point.y == 2)\n \n # otherwise, it's the sum of the paths that can be taken when adding the ones from right and the ones from below\n right_point = Point.new(start_point.x + 1, start_point.y)\n down_point = Point.new(start_point.x, start_point.y + 1)\n \n right = number_of_paths_to_end_from_point(right_point)\n down = number_of_paths_to_end_from_point(down_point)\n \n # puts \"From: (#{start_point.x}, #{start_point.y}) -> #{right + down} \"\n \n return right + down\nend",
"def walk(grid, x, y)\n [N, S, E, W].shuffle.each do |dir|\n nx, ny = x + DX[dir], y + DY[dir]\n if nx >= 0 && ny >= 0 && ny < grid.length && nx < grid[ny].length && grid[ny][nx] == 0\n grid[y][x] |= dir\n grid[ny][nx] |= OPPOSITE[dir]\n \n return [nx, ny]\n end\n end\n \n nil\nend",
"def find_path\n current_node = @cells_visited.last\n while current_node.parent != nil do\n @solved_path << current_node.cell\n current_node = current_node.parent\n end\n @solved_path << current_node.cell\n end",
"def find_path(source, target, map)\n @main_loop_count = 0\n\n max_y = map.size - 1\n max_x = map[0].size - 1\n target_x = target[0]\n target_y = target[1]\n # target heuristic is 0\n target = [target_x, target_y, 0]\n\n # Sets up the search to begin from the source\n source = source.dup.push((target_x - source[0]).abs + (target_y - source[1]).abs)\n came_from = {}\n came_from[source] = nil\n frontier = [source]\n\n # Until the target is found or there are no more cells to explore from\n until came_from.has_key?(target) || frontier.empty?\n @main_loop_count += 1\n\n # Take the next frontier cell\n new_frontier = frontier.shift\n\n # Find the adjacent neighbors\n adjacent_neighbors = []\n\n # Gets all the valid adjacent_neighbors into the array\n # From southern neighbor, clockwise\n nfx = new_frontier[0]\n nfy = new_frontier[1]\n adjacent_neighbors << [nfx , nfy - 1, (target_x - nfx).abs + (target_y - nfy + 1).abs] unless nfy == 0\n adjacent_neighbors << [nfx - 1, nfy - 1, (target_x - nfx + 1).abs + (target_y - nfy + 1).abs] unless nfx == 0 || nfy == 0\n adjacent_neighbors << [nfx - 1, nfy , (target_x - nfx + 1).abs + (target_y - nfy).abs] unless nfx == 0\n adjacent_neighbors << [nfx - 1, nfy + 1, (target_x - nfx + 1).abs + (target_y - nfy - 1).abs] unless nfx == 0 || nfy == max_y\n adjacent_neighbors << [nfx , nfy + 1, (target_x - nfx).abs + (target_y - nfy - 1).abs] unless nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy + 1, (target_x - nfx - 1).abs + (target_y - nfy - 1).abs] unless nfx == max_x || nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy , (target_x - nfx - 1).abs + (target_y - nfy).abs] unless nfx == max_x\n adjacent_neighbors << [nfx + 1, nfy - 1, (target_x - nfx - 1).abs + (target_y - nfy + 1).abs] unless nfx == max_x || nfy == 0\n\n new_neighbors = adjacent_neighbors.select do |neighbor|\n # That have not been visited and are not walls\n unless came_from.has_key?(neighbor) || map[neighbor[1]][neighbor[0]] != '.'\n # Add them to the frontier and mark them as visited\n # frontier << neighbor\n came_from[neighbor] = new_frontier\n end\n end\n\n # Sort the frontier so cells that are close to the target are then prioritized\n if new_neighbors.length > 0\n new_neighbors = merge_sort(new_neighbors)\n if frontier.length > 0 && new_neighbors[0][2] >= frontier[0][2]\n frontier = merge_sort(new_neighbors.concat(frontier))\n else\n frontier = new_neighbors.concat(frontier)\n end\n end\n end\n\n # If the search found the target\n if came_from.has_key?(target)\n # Calculates the path between the target and star for the greedy search\n # Only called when the greedy search finds the target\n path = []\n next_endpoint = came_from[target]\n while next_endpoint\n path << [next_endpoint[0], next_endpoint[1]]\n next_endpoint = came_from[next_endpoint]\n end\n path\n else\n return nil\n end\n end",
"def make_paths\n visited = {}\n path = []\n return path if @nmap.empty? || @nnmap.empty?\n\n # 0 is false\n @nmap.each do |k, _|\n visited[k] = 0\n end\n\n # for each node that is not an end node to an end node\n @nnmap.each do |s, _|\n # if s is an end node\n @paths << [s] if @ends.include? s\n\n # for each end node as desintation\n @ends.each do |d|\n get_allpaths(s, d, visited, path)\n end\n end\n @paths.sort_by(&:length).reverse\n end",
"def fill_until(grid, target)\n limit = grid.size - 1\n # Four sides to do:\n # a b c\n # d • e\n # f g h\n\n # Right:\n (limit-1).downto(0) do |x|\n grid[x][limit] = [\n grid[x-1][limit-1].to_i, # a\n grid[x ][limit-1].to_i, # d\n grid[x+1][limit-1].to_i, # f\n grid[x+1][limit ].to_i, # g\n ].sum\n return grid[x][limit] if grid[x][limit] > target\n end\n\n # Top:\n (limit-1).downto(0) do |y|\n grid[0][y] = [\n grid[0 ][y+1].to_i, # e\n y.zero? ? 0 : grid[0+1][y-1].to_i, # f\n grid[0+1][y ].to_i, # g\n grid[0+1][y+1].to_i, # h\n ].sum\n return grid[0][y] if grid[0][y] > target\n end\n\n # Left:\n 1.upto(limit) do |x|\n grid[x][0] = [\n grid[x-1][0 ].to_i, # b\n grid[x-1][0+1].to_i, # c\n grid[x ][0+1].to_i, # e\n x == limit ? 0 : grid[x+1][0+1].to_i, # h\n ].sum\n return grid[x][0] if grid[x][0] > target\n end\n\n # Bottom:\n 1.upto(limit) do |y|\n grid[limit][y] = [\n y.zero? ? 0 : grid[limit-1][y-1].to_i, # a\n grid[limit-1][y ].to_i, # b\n grid[limit-1][y+1].to_i, # c\n y.zero? ? 0 : grid[limit ][y-1].to_i, # d\n ].sum\n return grid[limit][y] if grid[limit][y] > target\n end\n\n expand! grid\n fill_until(grid, target)\nend",
"def path_empty?(diff, board)\n distance = 0\n path = []\n\n #gets the distance between from and to\n diff.each {|num| distance = num.abs if num!= 0}\n #gets the coordinate change for each step along the path\n step = diff.map {|num| num/distance}\n path_square = @pos.dup\n \n distance.times do |dist|\n path << path_square.dup\n \n unless dist == 0\n return false unless board[path_square[0]][path_square[1]].nil?\n end\n #moves path_square one step along the path\n 2.times {|i| path_square[i] += step[i]}\n end\n \n path\n end",
"def path(c,r, matrix_map)\n \n \n\nend",
"def check_path_open (from, to, board)\n #refine\n\n #Check if diagonal\n if (to[1]-from[1]).abs == (to[0]-from[0]).abs\n iterations_y = (to[1]-from[1])\n iterations_x = (to[0]-from[0])\n\n if (iterations_x > 0) && (iterations_y > 0)\n iterations_x.times do |x|\n if !is_spot_open([from[0]+x,from[1]+x],board)\n return false\n end\n end\n\n elsif (iterations_x > 0) && (iterations_y < 0)\n iterations_x.times do |x|\n if !is_spot_open([from[0]+x,from[1]-x],board)\n return false\n end\n end\n\n elsif (iterations_x < 0) && (iterations_y > 0)\n iterations_x.times do |x|\n if !is_spot_open([from[0]-x,from[1]+x],board)\n return false\n end\n end\n\n elsif (iterations_x < 0) && (iterations_y < 0)\n iterations_x.times do |x|\n if !is_spot_open([from[0]-x,from[1]-x],board)\n return false\n end\n end\n end\n\n return true\n\n\n\n #check if it moves vertical\n elsif ((to[0]==from[0])&&(to[1]!=from[1]))\n\n iterations = (to[1]-from[1])\n if iterations > 0\n iterations.times do |x|\n if !is_spot_open([from[0],from[1]+x],board)\n return false\n end\n end\n elsif iterations < 0\n iterations.times do |x|\n if !is_spot_open([from[0],from[1]-x],board)\n return false\n end\n end\n end\n\n return true\n\n #check if it moves horizontal\n elsif ((to[1]==from[1])&&(to[0]!=from[0]))\n iterations = (to[0]-from[0])\n if iterations > 0\n iterations.times do |x|\n if !is_spot_open([from[0]+x,from[1]],board)\n return false\n end\n end\n elsif iterations < 0\n iterations.times do |x|\n if !is_spot_open([from[0]-x,from[1]],board)\n return false\n end\n end\n end\n\n return true\n\n end\n\n end",
"def max_sum_path(arr)\n queue = [[0, 0]]\n n = arr.size\n sums = Array.new(n) { |cell| Array.new(n, -100) }\n sums[0][0] = arr[0][0]\n\n while !queue.empty? do\n row, col = queue.shift\n directions = [[0, 1], [1, 0]]\n directions.each do |drow, dcol|\n nrow, ncol = row + drow, col + dcol\n if nrow.between?(0, n - 1) && ncol.between?(0, n - 1)\n sums[nrow][ncol] = [sums[nrow][ncol], sums[row][col] + arr[nrow][ncol]].max\n queue << [nrow, ncol]\n end\n end\n end\n sums[n - 1][n - 1]\nend",
"def adjacent_mines(row, col)\n count = 0\n if col < @column_count-1\n count+=1 unless @grid[row][col+1].fill.nil?\n end\n if col > 0\n count +=1 unless @grid[row][col-1].fill.nil?\n end\n if row < @row_count-1\n count+=1 unless @grid[row+1][col].fill.nil?\n end\n if row > 0\n count+=1 unless @grid[row-1][col].fill.nil?\n end\n if row < @row_count-1 && col < @column_count-1\n count+=1 unless @grid[row+1][col+1].fill.nil?\n end\n if row > 0 && col > 0\n count+=1 unless @grid[row-1][col-1].fill.nil?\n end\n if row > 0 && col < @column_count-1\n count +=1 unless @grid[row-1][col+1].fill.nil?\n end\n if row < @row_count-1 && col > 0\n count +=1 unless @grid[row+1][col-1].fill.nil?\n end\n count\n end",
"def solve( n = 2_000 )\n # We can classify every tile according to its angular position around the\n # unit circle, setting position 0 at the top since that's where each row\n # starts in the problem statement. Positions 1-5 then follow every 60° as\n # we work our way counter-clockwise. Depending on which of these positions\n # each tile falls (or between which pair of positions), we use different\n # formulae to calculate its six neighbors to the N, NW, SW, S, SE, and NE:\n # \n # Pos 0: n even = fhp\n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n + ring - 1 (f)\n # SW = n + 1 NE = n + (2*ring + 5) (p)\n #\n # Pos 0-1: n even = bh, n odd = ag \n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + 1 NE = n - 1\n #\n # Pos 1: n even = bh, n odd = gi\n # N = n + ring (g) S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - 1\n #\n # Pos 1-2: n even = bh, n odd = ci\n # N = n - 1 S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2: n even = hj\n # N = n - 1 S = n + ring + 3 (j)\n # NW = n + ring + 1 (h) SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2-3: n even = dj, n odd = ci\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 3: n even = dj, n odd = ik\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + ring + 4 (k)\n # SW = n + ring + 2 (i) NE = n + 1\n #\n # Pos 3-4: n even = dj, n odd = ek\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + 1\n #\n # Pos 4: n even = jl\n # N = n + 1 S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + ring + 5 (l)\n #\n # Pos 4-5: n even = fl, n odd = ek\n # N = n + 1 S = n - 1\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5: n even = fl, n odd = km\n # N = n + ring + 6 (m) S = n - 1\n # NW = n + 1 SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, except last: n even = fl, n odd = gm\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n + 1 SE = n - 1\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, only last: n even = flo, n odd = gmo\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n - ring + 1 (f) SE = n - 1\n # SW = n - (2*ring - 7) (o) NE = n + ring + 5 (l)\n #\n # From these formula, we can derive the difference between a tile and each\n # of its neighbors. If we arrange all potential differences in ascending\n # order, it becomes obvious that for n even or odd, some deltas will al-\n # ways be even, and thus can never be prime (>2).\n #\n # Furthermore, we can see that only in certain positions will a tile ever\n # differ from three neighbors by odd amounts (position 0 and just to the\n # right of position 0). In all other cases, at most two deltas will be\n # odd, meaning PD(n) will be 2 or less.\n #\n # n even n odd\n # a = ring - 6 even a\n # b = ring - 5 b even\n # c = ring - 4 even c\n # d = ring - 3 d even\n # e = ring - 2 even e\n # f = ring - 1 f even\n # g = ring even g\n # h = ring + 1 h even\n # i = ring + 2 even i\n # j = ring + 3 j even\n # k = ring + 4 even k\n # l = ring + 5 l even\n # m = ring + 6 even m\n # o = 2ring - 7 o o\n # p = 2ring + 5 p p\n pd3 = [1, 2]\n base, ring = 8, 12\n \n while pd3.size < n\n # Only at position 0 and one tile to the right will there ever be three\n # odd deltas, so those are the only ones we have to check for primality.\n # Both share a delta of f = ring - 1.\n if (ring - 1).prime?\n # Check the other odd deltas for position 0. \n pd3 << base if (ring + 1).prime? && (2*ring + 5).prime?\n\n # Check the other odd deltas for one tile to the right of position 0.\n pd3 << base + ring - 1 if (ring + 5).prime? && (2*ring - 7).prime?\n end\n\n # Advance the first tile of the current ring (base), and the number of\n # tiles it contains (ring). \n base += ring\n ring += 6\n end\n\n pd3[-1]\n end",
"def calculate_path_size\n t0 = Time.now\n path_sizes = {0 => 0.0, 1 => 0.0, 2 => 0.0, 4 => 0.0, 10 => 0.0, Float::INFINITY => 0.0}\n\n # Retrieves all routes provenient from the same trip\n sibling_routes = AlternateRoute.where(:trip_id => @route.trip_id)#.where(\"state != 'discarded'\")\n\n # Get segment-based mileage for all sibling routes\n sibling_routes_mileage = calculate_routes_mileage(sibling_routes)\n\n # Remove the main route from sibling routes group\n sibling_routes = (sibling_routes.map{|r| r.id} - [@route.id])\n\n # Generate frequencies of each route segment over alternate routes\n frequencies = {}\n appearances = Segment.where(:osm_way_id => @segment_ids).group_by {|s| s.osm_way_id}\n appearances.each do |k, v|\n frequencies[k] = v.map{|e| e.alternate_route_id}.uniq - [nil]\n end\n\n @route.segments.each do |segment|\n segment_length = segment.length\n\n impedance = segment_length/sibling_routes_mileage[@route.id]\n\n # Get all sibling routes where the current segment is used\n ocurrences = frequencies[segment.osm_way_id] & sibling_routes\n #ocurrences = AlternateRoute.joins(:segments).where(:id => sibling_routes).where(\"segments.osm_way_id = ?\", segment.osm_way_id).references(:segments).pluck(:id).uniq\n\n path_sizes.keys.each do |gamma|\n sums = {0 => 1.0, 1 => 1.0, 2 => 1.0, 4 => 1.0, 10 => 1.0, Float::INFINITY => 1.0}\n\n ocurrences.each do |route|\n if gamma == Float::INFINITY\n # if (sibling_routes_mileage[@route.id]/sibling_routes_mileage[route]) > 1.0\n if (sibling_routes_mileage.values.min/sibling_routes_mileage[route]) > 1.0\n sums[gamma] = 0.0\n end\n else\n # sums[gamma] += (sibling_routes_mileage[@route.id]/sibling_routes_mileage[route])**gamma\n # sums[gamma] += (sibling_routes_mileage.values.min/sibling_routes_mileage[route])**gamma\n sums[gamma] += (sibling_routes_mileage.values.min/sibling_routes_mileage[route])**gamma**@route.systems_suggested\n end\n end\n\n if gamma == Float::INFINITY\n path_sizes[gamma] += (impedance * sums[gamma])\n else\n path_sizes[gamma] += (impedance * (1.0/sums[gamma]))\n end\n end\n end\n puts \"[#{@route.id}] Completed in #{(Time.now - t0)* 1000.0} ms\"\n puts \"[#{@route.id}] Path Size: #{path_sizes}\"\n path_sizes\n end",
"def solve(args)\n @seen_stack, @need_to_check, solved = [], [], false\n current_cell, finish = map[args[:begX]][args[:begY]], map[args[:endX]][args[:endY]]\n @seen_stack.push(current_cell)\n @need_to_check.push(current_cell)\n\n until @need_to_check.empty? || solved\n current_cell = @need_to_check.shift\n @seen_stack.push(current_cell)\n check_possible_paths(current_cell, finish)\n solved = true if current_cell == finish\n end\n solved\n end",
"def paths(arr, s, d)\n if invalid?(arr, s, d)\n return\n end\n\n if s == d\n $path_count = $path_count + 1\n return\n end\n\n cells = valid_cells(arr, s)\n cells.each do |cell|\n paths(arr, cell, d)\n end\nend",
"def get_move_path(start_cell, end_cell)\n start_coordinates = board.chess_notation_to_coordinates(start_cell)\n end_coordinates = board.chess_notation_to_coordinates(end_cell)\n start_y, start_x = start_coordinates[0], start_coordinates[1]\n end_y, end_x = end_coordinates[0], end_coordinates[1]\n path = []\n\n if horizonal_move?(start_cell, end_cell)\n path = build_horizonal_path(start_y, start_x, end_y, end_x)\n elsif vertical_move?(start_cell, end_cell)\n path = build_vertical_path(start_y, start_x, end_y, end_x)\n else\n path = build_diagonal_path(start_y, start_x, end_y, end_x)\n end\n\n path.map { |coordinates| board.coordinates_to_chess_notation(coordinates) }\n end",
"def generateBoard(row, col, num_mines)\n# Step 1 create board\n board = Array.new(row) { Array.new(col) {-1}}\n# Step 2 place random mines on board\n until num_mines < 1\n temp_x = rand(row)\n temp_y = rand(col)\n \n if board[temp_x][temp_y] != \"*\"\n board[temp_x][temp_y] = \"*\" \n num_mines -= 1 \n end\n end\n \n# Step 3 Iterate each tile skipping mines\n board.each_index do |x|\n board.each_index do |y|\n next if board[x][y] == \"*\"\n count = 0\n \n # Step 3a\n # check within bounds and count mines\n min_x = x - 1\n max_x = x + 1\n min_y = y - 1\n max_y = y + 1\n \n (min_x..max_x).each do |x|\n (min_y..max_y).each do |y|\n if (x >= 0 && x < row) && (y >= 0 && y < col)\n count += 1 if board[x][y] == \"*\"\n end\n end\n end\n \n board[x][y] = count\n end\n end\n \n # return board\n board\nend",
"def max_path_sumI arr\n for i in (arr.length-2).downto(0)\n for j in 0...arr[i].length\n arr[i][j] += (arr[i+1][j] > arr[i+1][j+1] ? arr[i+1][j]: arr[i+1][j+1])\n end\n end\n arr[0][0]\nend",
"def paths(i,j)\n\t\t#decidir donde moverse\n \t\tpossible_path = []\n\t \tpath = false\n \t\t\n \t\t#arriba\n \t\tif i-1 > -1\n\t\t\tpath = can_move(i-1,j)\n \t\t\tif path == true\n \t\t\t\tpossible_path.push([i-1,j])\n \t\t\tend\n \t\tend\n \t\t#abajo\n\t\tif i+1 < @laberinto.column_count\n \t\t\tpath = can_move(i+1,j)\n\t\t\tif path == true\n\t\t\t\tpossible_path.push([i+1,j])\n\t\t\tend\n\t\tend \t\n\t\t#izquierda\n\t\tif j-1 > -1\n\t\t\tpath = can_move(i,j-1)\n \t\t\tif path == true\n \t\t\t\tpossible_path.push([i,j-1])\n \t\t\tend\n \t\tend \t\n \t\t#derecha\n\t \tif j+1 < @laberinto.column_count\n \t\t\tpath = can_move(i,j+1)\n \t\t\tif path == true\n \t\t\t\tpossible_path.push([i,j+1])\n\t \t\tend\n \t\tend \t\n\n \t\treturn possible_path\n\tend",
"def adjacent_mines(row, col)\n\n count = 0\n\n count += 1 if (row + 1) < row_count && grid[row+1][col].fill == 1\n count += 1 if (row - 1) >= 0 && grid[row-1][col].fill == 1\n count += 1 if (col + 1) < column_count && grid[row][col+1].fill == 1\n count += 1 if (col -1) >= 0 && grid[row][col-1].fill == 1\n count += 1 if (row + 1) < row_count && (col + 1) < column_count && grid[row+1][col+1].fill == 1\n count += 1 if (row + 1) < row_count && (col -1) >= 0 && grid[row+1][col-1].fill == 1\n count += 1 if (row - 1) >= 0 && (col + 1) < column_count && grid[row-1][col+1].fill == 1\n count += 1 if (row - 1) >= 0 && (col -1) >= 0 && grid[row-1][col-1].fill == 1\n\n return count\n end",
"def grid_builder(m, n)\n ## Builds a grid MXN filled with 1's.\n grid = Array.new(m) { Array.new(n) {1} }\n ## m times randomly populate it with some 0's\n m.times { grid[rand(m)][rand(n)] = 0 }\n\n ## Using for manual testing\n # grid[0][0] = 0\n # grid[1][0] = 0\n # grid[2][0] = 0\n # grid[3][0] = 0\n\n cols_to_zero = []\n rows_to_zero = []\n\n #Go through columns\n grid.each do |array|\n array.each_with_index do |element, index|\n if element == 0\n cols_to_zero << index\n end\n end\n end\n\n #Go through Rows\n grid.each_with_index do |array, index|\n if array.include?(0)\n rows_to_zero << index\n end\n end\n\n ## Make the deletions\n ## For each of the columns in cols_to_zero amend the grid to zero's.\n for i in cols_to_zero.uniq\n 0.upto(grid.size - 1) do |row|\n grid[row][i] = 0\n end\n end\n\n ## For each of the values in the rows_to_zero array amend the existing grid using map!\n for i in rows_to_zero.uniq\n grid[0].map! { |element| 0 }\n end\n\n grid\nend",
"def step_through_iterative_division_maze_generator(grid, state)\n unless state[:finished_init]\n draw_canvas_border(grid)\n state[:finished_init] = true\n end\n new_chamber = divide(grid, state[:current_chamber])\n if new_chamber\n state[:current_chamber] = new_chamber[0]\n state[:todo_chamber].push(new_chamber[1])\n elsif !state[:todo_chamber].empty?\n state[:current_chamber] = state[:todo_chamber].pop\n elsif !state[:generation_complete]\n state[:generation_complete] = true\n end\nend",
"def change_grid(grid, list, starting_pos, i, hash)\n\tpos = starting_pos.dup\n\ttotal_steps = 0\n\tlist.each do |command|\n\t\tdir = command[0]\n\t\tmag = command[1..-1].to_i\n\t\tdraw_path(grid, pos, dir, mag, i, total_steps, hash)\n\t\ttotal_steps += mag\n\tend\nend",
"def sim(m, w, h)\n\to = m.map{|x|x.clone}\n\t(1..w-2).each do |x|\n\t\t(1..h-2).each do |y|\n\t\t\tnext if m[y][x] == ?.\n\t\t\toccupied=[-1,0,1].product([-1,0,1]).count{|dx,dy|(dx!=0||dy!=0) && m[y+dy][x+dx]==?#}\n\t\t\to[y][x] = ?# if m[y][x] == ?L && occupied == 0\n\t\t\to[y][x] = ?L if m[y][x] == ?# && occupied >= 4\n\t\tend\n\tend\n\treturn o\nend",
"def build_path(start, finish)\n path = [finish]\n loop do\n vertex = path.last\n d = graph[*vertex]\n neighbours = get_neighbours(*vertex)\n next_vertex = neighbours.select{|n_vert| graph[*n_vert] == d - 1}.first\n path << next_vertex if next_vertex\n break if vertex == start\n end\n path\n end",
"def countFills(rows, start = 0, memoizer = Hash.new{false})\n\treturn memoizer[start] if memoizer[start]\n\treturn 1 if start >= rows\n\n\ttotal = 0\n\ttotal += countFills(rows, start + SPACE_BETWEEN_BLOCK, memoizer)\n\tfor i in MINIMUM_BLOCK..(rows - start)\n\t\ttotal += countFills(rows, start + i + SPACE_BETWEEN_BLOCK, memoizer)\n\tend\n\tmemoizer[start] = total\n\treturn total\nend",
"def possible_moves \n row = @current_row\n column = @current_column\n values = Hash.new \n if (row + 1) <= @matrix.length \n values[@matrix[row + 1][column]] = [(row + 1),column]\n end \n if (row - 1) >= 0\n values[@matrix[row - 1][column]] = [(row - 1),column]\n end \n if (column + 1) <= @matrix[0].length \n values[@matrix[row][column + 1]] = [row,(column + 1)]\n end\n if (column - 1) >= 0 \n values[@matrix[row][column - 1]] = [row,(column - 1)]\n end \n highest_value_square(values)\nend",
"def ROOK_long_path(position, target)\n now = getposition(position)\n moves = ['move_down', 'move_up', 'move_right', 'move_left']\n\n steps = 0\n long_position = ''\n for i in moves do\n path = inpath(position, i)\n # print path\n long_tile = path_len_tile(path, target)\n # print long_tile\n if long_tile.any? && long_tile[1] > steps\n steps = long_tile[1]\n long_position = long_tile[0]\n end\n end\n return [long_position, steps + 1]\n # print ROOK_long_path('h5')\n end",
"def generate_solution\n ary = (\"0\" * tile_count).chars.map(&:to_i)\n until ary.count(0).zero?\n ary.each_with_index do |num, ind|\n row = calculate_area(ind + 1, :row)\n col = calculate_area(ind + 1, :col)\n box = calculate_area(ind + 1, :box)\n row_neighbours = tile_range.to_a.select {|n| calculate_area(n, :row).eql? row}\n col_neighbours = tile_range.to_a.select {|n| calculate_area(n, :col).eql? col}\n box_neighbours = tile_range.to_a.select {|n| calculate_area(n, :box).eql? box}\n neighbours = (row_neighbours + col_neighbours + box_neighbours).uniq!.map {|n| n -= 1}\n neighbouring_values = []\n neighbours.each {|n| neighbouring_values << ary[n]}\n options = (0..area_size).to_a.reject! {|x| neighbouring_values.compact.include?(x)}\n if options == []\n ary = (\"0\" * tile_count).chars.map(&:to_i)\n break\n end\n ary[ind] = options.sample\n end\n end\n return ary.join\n end",
"def next_step_from(paths)\n paths.map do |path|\n possible_neighbours(path.most_recent_step.coordinate, @max_x, @max_y) \n .map { |c| coord_to_step_on_path(c, path) }\n .reject { |p| p == nil }\n end\n .flatten\n end",
"def get_path(s, e, maze)\n if maze[s[0]][s[1]] == 1 || # found a wall or visited area\n s[0] < 0 || s[1] < 0 || # top or left edge\n s[0] >= maze.length || s[1] >= maze[0].length # bottom or right edge\n\n path = nil\n\n elsif s[0] == e[0] && s[1] == e[1] # exit spot\n\n path = [s]\n\n else\n\n maze[s[0]][s[1]] = 1 # visit current node\n path =\n get_path([s[0] - 1, s[1]], e, maze) ||\n get_path([s[0], s[1] + 1], e, maze) ||\n get_path([s[0], s[1] - 1], e, maze) ||\n get_path([s[0] + 1, s[1]], e, maze)\n\n path << s unless path.nil?\n\n end\n \n return path\nend",
"def number_cells\n n = 1\n for row in 0...height\n for col in 0...width\n cell = self[row, col]\n west, north, east, south = DIRS.map{|dx, dy| self[row + dx, col + dy] and self[row + dx, col + dy].empty }\n if cell.empty and ((!west and east) or (!north and south))\n cell.number = n\n n += 1\n end\n end\n end\n end",
"def build_path(start, end_pos)\n node = Node.new(start[0], start[1])\n target = Node.new(end_pos[0], end_pos[1])\n visited_nodes = []\n next_moves = [node]\n until next_moves.empty? do\n node = next_moves.shift\n puts \"Current node: #{node.x}, #{node.y}\"\n if node.x == target.x && node.y == target.y \n return node\n end\n visited_nodes.push(node)\n node.moves = get_moves(node)\n node.moves.reject do |square|\n visited_nodes.include?(square)\n end\n node.moves.each do |move| \n next_moves.push(move)\n end\n end\n return node\nend",
"def build_steps\n row = col = 0 \n dir = -1\n\n prev = 0\n @steps = []\n\n # since we don't know where the smallest square should start, we reverse\n # and calculate from large to small\n @series.reverse.each do |size|\n case(dir)\n when 0\n col += prev - 1\n when 1\n row += prev - 1\n col += prev - size\n when 2\n row += prev - size\n col -= size - 1\n when 3\n row -= size - 1\n end\n\n @steps << [size, row, col]\n\n prev = size\n dir += 1\n dir %= 4\n end\n\n # flip our steps so they run from small to large\n @steps.reverse!\n\n @built = true\n end",
"def run\n closed_squares = []\n opened_squares = [@start]\n\n @start.current_path_cost = 0\n\n while opened_squares.any?\n current_square = opened_squares.sort do |a, b|\n a.estimated_total_cost(@finish) <=> b.estimated_total_cost(@finish)\n end.first\n\n if current_square == @finish\n return find_path(current_square)\n end\n\n closed_squares.push(current_square)\n opened_squares.delete(current_square)\n\n @board.neighbours(current_square).each do |neighbour|\n if closed_squares.include?(neighbour)\n next\n end\n\n if !opened_squares.include?(neighbour)\n opened_squares.push(neighbour)\n end\n\n if current_square.current_path_cost + neighbour.move_cost >= neighbour.current_path_cost\n next\n end\n\n neighbour.path_via = current_square\n neighbour.current_path_cost = current_square.current_path_cost + neighbour.move_cost \n end\n end\n end",
"def reachable_cells(x, y, world)\n visited = []\n queue = [[x, y]]\n\n while !queue.empty?\n start = queue.pop\n neighbors = DIRECTIONS.values.\n map {|d| [start[0] + d[:x], start[1] + d[:y]]}.\n select {|x,y| world[y][x] == '.' }\n new_cells = neighbors - visited\n queue = queue + new_cells\n visited.push(start)\n end\n\n visited\nend",
"def knights_moves(start, finish)\n board = create_board\n\n path = []\n queue = []\n\n queue << start\n\n loop do\n \tcurrent_node = board[queue[0][0]][queue[0][1]]\n\n current_node.moves.each do |node|\n unless node == start || board[node[0]][node[1]].parent != nil\n board[node[0]][node[1]].parent = queue[0] \n queue << node\n end\t\n end\n\n if queue.include? finish\n\n parent = board[finish[0]][finish[1]].parent\n path << parent\n\n loop do\n \tparent = board[parent[0]][parent[1]].parent\n \tbreak if parent == nil\n \tpath.unshift(parent)\n end\n\n path << finish\n break\n end\n\n \tqueue.shift\n end\n puts \"You can make it in #{path.length-1} steps!\"\n path\nend",
"def walk_grid(g, n)\n Enumerator.new do |enum|\n 0.upto(g.size-1) do |y|\n 0.upto(g.size-1) do |x|\n x_ok = x < (g.size-n)\n y_ok = y < (g.size-n)\n enum.yield :horizontal, fetch_tuple(g, x, y, 1, 0, n) if x_ok\n enum.yield :vertical, fetch_tuple(g, x, y, 0, 1, n) if y_ok\n enum.yield :diagonal, fetch_tuple(g, x, y, 1, 1, n) if x_ok && y_ok\n end\n end\n end.lazy\nend",
"def total_resouce_value(minutes = 10)\n changes, area, holds, cycles = {}, @data, [], []\n max_x, max_y = area[0].size, area.size\n\n # print_area(area, 0)\n\n (1..minutes).each do |time|\n (0..max_x - 1).each do |x|\n (0..max_y - 1).each do |y|\n adjacents = [\n [x - 1, y - 1],\n [x - 1, y],\n [x - 1, y + 1],\n [x, y - 1],\n [x, y + 1],\n [x + 1, y - 1],\n [x + 1, y],\n [x + 1, y + 1]\n ].select { |k, v| k >= 0 && v >= 0 && k <= max_x - 1 && v <= max_y - 1 }\n .map { |dx, dy| area[dx][dy] }.compact\n\n case area[x][y]\n when '.'\n changes.merge!([x, y] => '|') if adjacents.count('|') >= 3\n when '|'\n changes.merge!([x, y] => '#') if adjacents.count('#') >= 3\n when '#'\n changes.merge!([x, y] => '.') unless adjacents.include?('|') && adjacents.include?('#')\n end\n end\n end\n\n changes.each { |(cx, cy), value| area[cx][cy] = value }\n\n resource = [area.flatten.count('|'), area.flatten.count('#')].reduce(&:*)\n\n if holds.include?(resource)\n unless cycles.include?(resource)\n cycles << resource\n else\n if holds.join.include? cycles.join\n puts \"Part 2: #{cycles[(minutes - holds.size) % cycles.size - 1]}\"\n return\n else\n cycles = []\n end\n end\n end\n\n holds << resource\n\n # print_area(area, time)\n end\n\n puts \"Part 1: #{area.flatten.count('|') * area.flatten.count('#')}\"\n end",
"def maximum_path_sum(array, number_of_rows)\r\n x = array.map{|num| num.to_i }\r\n new_array = []\r\n j = 0 \r\n number_of_rows.times do |i|\r\n new_array << x.slice(j, i + 1)\r\n j += i + 1\r\n end \r\n new_array = new_array.map{|arr| arr.map{|x| x.to_i}}\r\n new_array = new_array.reverse\r\n \r\n a = new_array[0].each_cons(2).to_a\r\n b = new_array[1]\r\n c = b.zip(a)\r\n d = c.map{|arr| arr[0] + arr[1].max}\r\n\r\n (number_of_rows - 3).times do |i|\r\n a = d.each_cons(2).to_a \r\n d.clear \r\n b = new_array[i + 2]\r\n c = b.zip(a)\r\n d = c.map{|arr| arr[0] + arr[1].max}\r\n end \r\n \r\n return d.max + new_array.last.join.to_i\r\nend",
"def neighbour_count row,col\n neighbours=0\n \n # iterate around the neighbours\n (-1..1).each do |i|\n (-1..1).each do |j|\n\t# Wrap lower right edge of matrix back to 0\n\tnrow=(row==@current_state.length-i) ? 0 : row+i\n\tncol=(col==@current_state[row].length-j) ? 0 : col+j\n\t# Do not count current cell\n\t# Treat illegal values as 0\n\tif (nrow!=row or ncol!=col) and @current_state[nrow][ncol]==1\n\t neighbours += 1\n\tend\n end\n end\n return neighbours\n end"
] | [
"0.767142",
"0.7289165",
"0.7219978",
"0.71513057",
"0.7142519",
"0.71173",
"0.71154433",
"0.7064094",
"0.701067",
"0.696083",
"0.68123895",
"0.6756051",
"0.66763",
"0.65197337",
"0.6501298",
"0.644206",
"0.6408541",
"0.6405648",
"0.62281775",
"0.62185156",
"0.6189234",
"0.6130779",
"0.60925907",
"0.6075265",
"0.6065246",
"0.6035636",
"0.6030754",
"0.59949994",
"0.59683174",
"0.5923113",
"0.5908927",
"0.58654416",
"0.5855485",
"0.58395624",
"0.58298755",
"0.58291405",
"0.5821788",
"0.58056694",
"0.5802099",
"0.57918745",
"0.57877463",
"0.57782704",
"0.5759909",
"0.57582843",
"0.57395667",
"0.5715418",
"0.5715418",
"0.5711979",
"0.56636393",
"0.5662844",
"0.5655796",
"0.5646333",
"0.5640018",
"0.56400114",
"0.56349653",
"0.5622796",
"0.5598613",
"0.5585035",
"0.55764514",
"0.5576058",
"0.5566758",
"0.5551622",
"0.5546249",
"0.55296546",
"0.55228674",
"0.5519674",
"0.55159265",
"0.5514193",
"0.55121064",
"0.55080277",
"0.5496219",
"0.54905576",
"0.54870844",
"0.5470089",
"0.5466602",
"0.5465399",
"0.54644006",
"0.54561615",
"0.5446514",
"0.54438585",
"0.54345703",
"0.5431648",
"0.5414513",
"0.5413781",
"0.5413028",
"0.541061",
"0.5398201",
"0.5392207",
"0.53862756",
"0.53842026",
"0.534709",
"0.53451544",
"0.5341492",
"0.53414536",
"0.5340404",
"0.53333664",
"0.5321134",
"0.5316691",
"0.53151476",
"0.53126776",
"0.53092414"
] | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.